Re: A82: saving hl


[Prev][Next][Index][Thread]

Re: A82: saving hl




>All that stuff you wrote below looks really neat, but I am confused as 
>to how it works?! Could you please email another, smaller and simpler 
>example of this code, and explain what it does, thanks.

It is a space and speed (speed optimization is minimal) optimization.
It works on the principle that you are working from RAM as opposed to
ROM, and how an ld hl,1234 is stored in memory.  It is stored like this:

.db $21,$34,$12

21 is the opcode, 34 12 is the operand.  If you had a label before the
.db, to write to the 2 bytes of the operand you'd write to (label+1).
This changes the command to mean ld hl,whatever, and at the same time,
it saves 2 bytes of space, because you don't have to have a separate
.dw.  And when this executes instead of the replaced ld hl,(something),
it still works because the operand is automatically "something".

-- Barubary