Re: LZ-Adv: JR or JP cc, *


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

Re: LZ-Adv: JR or JP cc, *



>Yes, you're right, JR is jump relative.  This still cannot be done
without
>knowing the relative address of the code that you want to jump to.Let's
say
>that you want to jump to a function.  You count the lines, and figure
that
>it's say 98 bytes from the line that you are jumping from.  Ok, you add
a
>line, remove three lines, add one more, and reomve another.  Then you
have
>to totally re-count the address.  Assuming that you count them
correctly,
>not all asm commands are 2 bytes.  Some are 6, 8, etc.  By this time,
you'd
>have been better off just JUMP_(name)'ing in the beginnig.


But you can use names with jr just like JUMP_.  The compiler is smart
enough to count bytes, so you don't have to.  For example:


START:


jr    SKIP
ld    A,0


SKIP:


add   A,0


----------


START:


JUMP_(SKIP)
ld    A,0


SKIP:


add   A,0


----------


Both sections of code function exactly the same, but the first one takes
up 3 bytes of memory smaller than the second.  Sometimes, though, you
have to use JUMP_, because jr is limited to a maximum range of 128 bytes
in either direction.


Jason "Thursday" Wenger
jwenger@juno.com
Illegitimi no carborundum


References: