Guy Sotomayor wrote:
>
> 2. Because it can save a bit of RAM. Remember in the
early days of the
> PC, saving bytes was important for a number of
programs. They had to
> fit in "typical" machines at the time. In
many cases this was on a 16K
> machine, every byte counted and not all of the
functions in the BIOS
> were exported by INT xx entry points. In many ways IBM
made it easy
> because they published the complete assembly listing of
the BIOS ROM.
While I can appreciate this philosophy, I still can't see
how it would
be beneficial on the 5150/5160. For example, let's say I
want to move
the cursor to a new location, say (10,15). Typical way is
something
like this:
mov ah,2 ;set video mode
mov bh,0 ;video page 0
mov dh,15 ;col 15
mov dl,10 ;row 10
int 10h ;do it
That's 10 bytes.
The INT call pushes the flags, CS, and IP onto the stack,
jumps to the
routine, the routine executes, and then *in the ROM routine
itself*
there is an IRET, which POPs IP, CS, and flags and then
continues from
that point. It is the IRET that is causing me trouble on
how to figure
out what better way to do this, because once you hit the
IRET you had
better have the IP, CS, and flags on the stack because
they're going to
get restored whether you want them to or not. And you can't
just patch
in a JMP into the ROM code to return, because it's ROM.
So the only scenario I can think of is something like, maybe
you only
want to move the cursor downward, on the same page, and you
don't want
to set those extra input registers. Let's also assume that
you know the
exact location in ROM where you want to JMP so that the BIOS
routine can
do only what you want it to. You would still have to do
something like
this:
mov bh,0 ;set video page 0
mov dl,10 ;move cursor down only
CALL 1234:5678 (go directly to your magic function)
That's 9 bytes. So you have saved ONE byte, yes, but that
is for an
extremely specific optimized case. The CALL is necessary
because of the
IRET that is coming at the end of the function.
If that was a more common practice than I realize, then I
guess I stand
corrected. But it just doesn't seem worth it. When I'm
*that*
pressured for space, I use code overlays (if the language
allows it) or
something else, like using non-visible video RAM for
storage. (Yes,
that's disgusting, but I'm not going to turn down 12K of
free RAM just
because I'm only using one video page! Remember, even a
monochrome
card, with it's single 80x25 video page, has 96 bytes of
unused ram...)
--
Jim Leonard (trixter oldskool.org) http://www.oldskool.org/
Help our electronic games project: http://www.mobygames.com/
a>
Or check out some trippy MindCandy at http://www.mindcandydvd.
com/
A child borne of the home computer wars: http://trixter.wordpres
s.com/
|