These are the instructions that change the place of execution without saving their own address for a possible return.
jp/jr label or (hl)/(ix)/(iy) (unconditional) or
jp/jr condition,label (conditional)
When arriving at any of these intructions, execution is immediately continued from the location denoted by the label given (you can use numbers instead of labels of course). If the operand is a register reference (e. g.
jp (hl)), it means that the value of the register will be loaded into PC directly; these jumps can be unconditional only. Otherwise, if the condition is not fulfilled, execution continues as if there wasn't any jump. The flags are preserved in all the cases. The conditions can be the following:
|c||carry (C) is set|
|nc||carry is not set|
|z||zero (Z) is set|
|nz||zero is not set|
|m||sign (S) is set|
|p||sign is not set|
|pe||parity/overflow (P/V) is set|
|po||parity/overflow is not set|
The most important difference between the two jumps is that
jr calculates the jump address with respect to itself, and the destination must be in its 128-byte vicinity. Moreover,
jr can only take the first four conditions of those listed above. Besides all these differences,
jr is slower but also smaller than the corresponding
jp, therefore you have to decide whether speed or size is more important in the piece of code you place the jump into.
B is decreased, and a
jr label happens if the result was not zero. The flags are preserved. Since this is a relative jump, it can only point to its 128-byte vicinity.
The two instructions of this section are also jumps, but by taking advantage of the stack, they offer the possibility to create subroutines.
call label (unconditional) or
call condition,label (conditional)
The address of the instruction immediately following the
call (i. e. PC+3) is saved to the stack, and execution is continued from the address given by the label. The conditions are the same as those of the absolute jump, i. e. all the eight conditions can be used. The flags are preserved.
ret (unconditional) or
ret condition (conditional)
The word on the top of the stack is retrieved and it is used as the address of the next instruction from which the execution is to be continued. This is basically a pop pc. The conditions work the same way as above, all of them can be used. The flags are preserved.
Back to the index
|file: /Techref/zilog/z80/app1c.htm, 3KB, , updated: 2018/11/6 16:43, local time: 2023/2/5 22:30,
|©2023 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?|
<A HREF="http://www.ecomorder.com/techref/zilog/z80/app1c.htm"> Z80 Assembly</A>
|Did you find what you needed?|
Welcome to ecomorder.com!
Welcome to www.ecomorder.com!