memory, the block of memory that can be addressed moves (or
floats) along with the current instruction. The premise for this man-
ner of addressing is that in most cases it is sufficient to address mem-
ory in the immediate area of the current instruction; most programs
will operate on data near the current instruction.
Relative addressing on the Z-80 is used only for the jump Group
of instructions, allowing conditional and unconditional jumps back
up to 126 locations or forward 129 locations from the current in-
struction. An example of relative addressing for a jump is shown
in Fig. 4-16.
JR Z, E JUMP RELATIVE IF ZERO
LOCAT ION 0300H
0 0 1 0 1 0 0 0
28H - OP CODE
0301 H
0 0 0 0 1 0 1 0
VALUE - 1010 - AH
PC
0302 H
INSTRUCTION WILL JUMP TO 0302H + AH -030CH
IF ZERO FLAG SET OR WILL EXECUTE NEXT
INSTRUCTION AT 0302H IF NOT SET
Fig. 4-16 . Relative addressing in JR Z,E instruction.
INDEXED ADDRESSING
Indexed addressing is an addressing mode that permits using the
two index registers in the Z-80, IX and IY. Many instruction groups
permit using the indexed addressing mode and it is one of the most
powerful features that the Z-80 offers. The format of this addressing
mode is shown in Fig. 4-17. The op code of the instruction is in
bytes 0 and 1; while the third byte holds an 8-bit signed displace-
ment of -1281D through +12710. This displacement is added to the
contents of the specified index register IX or IY to determine the
effective address of the memory operand.
BYTE 0
BYTE 1
BYTE 2
(BYTE 3)
OP CODE
OP CODE
D
(VARIES OR NONE)
EFFECTIVE ADDRESS - ( IX) + D OR
(IY) + D
Fig. 4-17. Indexed addressing.
16-B IT SIGNED VALUE -128 TO +12710
For example, consider the instruction LD (IY + D ),N that uses
the IY index register. This is shown in Fig. 4-18. The LD (IY + D),N
loads (stores) the immediate value N into the memory location
specified by the effective address. If the contents of IY are 1003H
(the index registers are 16-bit registers), an LD (IY + D),N with a
displacement field of 40H will store N into memory location 1043H.
50
Need help?
Do you have a question about the Z80 and is the answer not in the manual?
Questions and answers