A83: Re: jr and jp


A83: Re: jr and jp

JR = 38 XX           ; 2 bytes, 12 t-states

XX is a signed byte, indicating a relative number of bytes to jump to,
backwards or forwards.  The jump takes place after the program counter is
incremented, so a value of 0 would be the instruction following the JR.  JR
should be used anytime to move inside the program, if possible.  It can be
used at all times, since the assembler will (should) warn if the relative
jump is too long.  In that case, it can be changed to a JP.

JP = C3 XX XX     ; 3 bytes, 10 t-states

XX XX is a word value, indicating an absolute address to jump to.  This can
be used to make jumps of any distance, anywhere in memory.  It should be
used when jumping to ROM calls, or memory locations too far away for JR to
be used.

The difference in a large program could be several hundred bytes, but in a
small program would not likely be very noticable.  However, all effort
should be made to use JR when possible.  The differences in speed do not
warrant using JP in even the most tightly optimized code (no code I have
ever seen or written would be sped up enough to make JP useful over
JR...including the ROM linking routines).

> i know ASMhuru explains these commands but..how do i know which one to
> use...and will using jr make any significant size differences in the