Relative addressing, Relative addressing mode, Modified page zero addressing – Zilog Z08470 User Manual
Page 47

UM008007-0715
Modified Page Zero Addressing
Z80 CPU
User Manual
35
Modified Page Zero Addressing
The Z80 contains a special single-byte CALL instruction to any of eight locations in Page
0 of memory. This instruction, which is referred to as a restart, sets the Program Counter to
an effective address in Page 0. The value of this instruction is that it allows a single byte to
specify a complete 16-bit address at which commonly-called subroutines are located,
thereby saving memory space.
Relative Addressing
Relative addressing uses one byte of data following the op code to specify a displacement
from the existing program to which a program jump can occur. This displacement is a
signed two’s complement number that is added to the address of the op code of the follow-
ing instruction.
The value of relative addressing is that it allows jumps to nearby locations while only
requiring two bytes of memory space. For most programs, relative jumps are by far the
most prevalent type of jump due to the proximity of related program segments. Therefore,
these instructions can significantly reduce memory space requirements. The signed dis-
placement can range between +127 and –128 from A+2. This range allows for a total dis-
placement of +129 to –126 from the jump relative op code address. Another major
advantage is that it allows for relocatable code.
Figure 27. Modified Page Zero Addressing Mode
Figure 28. Relative Addressing Mode
One Byte
B7
B0
Op Code
Effective Address is
(B5 B4 B3 000)2
Op Code
Op Code
Jump Relative (One Byte Op Code)
8-bit Two’s Complement
Displacement Added to
Address (A+2)