A86: Re: Ram Screen program.


[Next][Index][Thread]

A86: Re: Ram Screen program.




>Don't ask me why hl points so
>high when _puts is used, I have no clue.  Could someone please explain?
>

Your sqrtKEY handler program is essentially a program within a program. When
a key is pressed, the part between "code" and "code_end" will be copied to
_asm_exec_ram and executed. Hence, the label "code", when executed, will be
equivelent to _asm_exec_ram. In the installer program, however, this is
obviously not the case, as there is all that installer code before it. The
assembler doesn't know that this will be run as a separate program, so it
calculates the labels, including "memmenu", in relation to the beginning of
the entire installer program. So what you have to do is subtract the
difference between the start of the handler code ("code") and the start of
the installer code (_asm_exec_ram) every time you give an address in the
handler code (except for relative addresses).

What I like to do is define a macro for this, like:
#define CodeOffset    (code - _asm_exec_ram + 2)

(The +2 is because the 8E28 token will not be copied or executed.)

Then just use:
    ld hl, memmenu - CodeOffset
instead of:
    ld hl, memmenu

Later,
   Jeremy G.



Follow-Ups: