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


[Next][Index][Thread]

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



On 30 Oct 96 at 23:02, C.J. Oster wrote:


> >> You cant just say JR, there is a macro defined in the ti-85.h file that
> >> does it correctly for you.
> 
> Ok, JR is an unconditional jump.  What this does is it takes the current
> val in PC (Program Counter, which is the address of the current instruction
> executing), and jumps RELATIVE to that.  Lets say that you want to JR to a
> function...  You have to know how many bytes that the calc needs to 'skip'
> over.  To do this, you have to know where the program beginnig is, which
> you can't know when you compile the program because of the Ti-Os's way of
> defragmenting the ram.  The macro essentiall asks ZShell where the program
> begins, and the jump points to the function address obtained on the
> compilation of the program.  You say...
> 
> JUMP_(addr), which is esentially   call $8C27 \ .dw addr.
>                                         ^^^^^ is the address of a ZShell
> routine that calculates the address of the mem byte to jump to.  'addr' can
> be the name of a function, like 'StoreRam'.  Tasm takes care of this for
> you.


No! You've misunderstood this. Unlike JP, with JR you don't have to
know where you are when you write the code. JR takes an argument and
_adds_ that to the program counter, while JP takes an argument and
_replaces_ the program counter with it.


Of course labels can be used in conjunction with both JR and JP.
Therefore, in ZShell you can in most cases use "JR label" just as well
as "JUMP(label)". There is only one limitation with JR: since the
argument is one byte, it only allows you to jump 127 bytes forwards or
128 bytes backwards. I.e. if the jump address is more than 128 bytes
away you have to use the JUMP macro. 


  Mattias


<pre>
--
 Mattias Lindqvist
 d96mli@efd.lth.se
 www.efd.lth.se/~d96mli
</pre>


References: