BYTE
RSTP RESTART TO LOCATION P
1 1 T 1 1 1
P T
Fig. 4-14 . Modified page zero OOH 0
addressing in restart instruction. 08H 1
10H 2
18H 3
20H 4
28H 5
301{ 6
38H 7
11211112.0P CODE
30H, or 38H as shown. This instruction is discussed more fully in
the next chapter.
RELATIVE ADDRESSING
Relative addressing is primarily used in minicomputers or micro-
computers to shorten instructions and reduce the amount of memory
that programs occupy. If direct (extended) addressing is used to en-
able addressing all of memory, the address portion of the instruction
is two bytes long (16 bits can address 64K). In both page zero and
relative addressing, the address portion of the instruction is one byte
long, reducing the instruction size from three bytes (op code plus
address) to two bytes. Page zero addressing allows addressing only
of page zero; relative addressing allows addressing of 256 memory
locations grouped around the current instruction. Fig. 4-15 shows
how this scheme is implemented. The second byte of the instruction
is a signed value of -12810 to +12710 (100000002 to 011111112).
When this value is added to the current contents of the program
counter, a memory location -126 to +129 bytes away is addressed
since the program counter points to the instruction after the relative
addressing instruction. As the current instruction moves through
BYTE 0
BYTE 1
MEMORY
CURRENT
INSTRUCTION
LOCATION
OP CODE
DISPLACEMENT VALUE
-12810 TO +12710
-12610 LOCATIONS BACK
+12410 LOCATIONS FORWARD
Fig. 4- 15. Relative addressing.
49
Need help?
Do you have a question about the Z80 and is the answer not in the manual?
Questions and answers