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.
~Ilya

Barubary wrote:

> Use self-modifying code.  It's pretty simple to do.  Change ONE of
> the load HLs with (save) to save: ld hl,0.  Then change all the
> (save)s to (save+1).  Example below.
> 
> Change this:
> 
> ld (save),hl
> ...
> ld hl,(save)
> ...
> ld hl,(save)
> ...
> ld (save),hl
> 
> To this (note that changing ANY ld hl,(save) is alright):
> 
> ld (save+1),hl
> ...
> save:
> ld hl,0
> ...
> ld hl,(save+1)
> ...
> ld (save),hl
> 
> This only works with ld de,... ld hl,... and ld bc,...
> 
> -- Barubary


References: