reader. When a choice must be made between a JP and an uncondi-
tional relative jump JR, the relative jump should be chosen if the
jump address is within the relative addressing range of the instruc-
tion. The JR uses two bytes, as opposed to the three bytes of the JP.
(The JP is faster, however, 2.5 microseconds compared to 3.0 micro-
seconds for the JR.) The relative addressing range of the JR is up to
126 locations back from the JR or up to 129 locations forward from
the JR. The assembler used for the Z-80 will give a diagnostic mes-
sage on the assembly listing, if this range is exceeded, and a JP can
then be substituted for the JR. The JR will be possible in most of
the jump cases.
The conditional extended-addressing jump JP and relative-address-
ing jump JR enable a jump to a location based on the state of the
zero flag, carry flag, parity flag, or sign flag as shown in Table 14-1.
Various assemblers will use different mnemonics for the condition.
NZ, Z, NC, C, P, and M are self-explanatory, but the PO and PE
mnemonics may be replaced with more descriptive mnemonics such
as V or NV for overflow and no overflow; and P and NP for parity
or no parity.
Table 14-1. Conditional Jumps
Flag
Extended Form
Relative Form
NZ nonzero
JP NZ,LOCN
JR Z,LOCN
Z zero
JP Z,LOCN
JR NZ,LOCN
NC no carry
JP NC,LOCN
JR C,LOCN
C carry
JP C,LOCN
JR NC,LOCN
PO parity odd
JP PO,LOCN
none
PE parity even
JP PE,LOCN
none
P sign positive
JP P,LOCN
none
M sign negative
JP M,LOCN
none
Three jump instructions JP (HL), JP (IX), and JP (IY) effec-
tively cause an unconditional jump by loading the program counter
with the contents of the HL, IX, or IY registers. When a multiple
path decision must be made and a jump to one of several points is
effected, these instructions may be used to advantage. As an exam-
ple, suppose that in a large program we have a "mode" word that
indicates what mode the system is in currently. This could be used
to indicate the pass number of a three-pass assembler or any combi-
nation of conditions the programmer desires. For our purposes, let
us assume the mode word MODE represents states of the system as
shown in Fig. 14-1. Note that some combinations of states are not
possible, but that the general range for the four bits of the mode
209
Need help?
Do you have a question about the Z80 and is the answer not in the manual?