CPDR
Compare and Decrement with Repeat
Operation
repeat {
A–(HL)
HL ← HL – 1
BC ← BC – 1
} while (~Z and BC ≠ 0)
Description
The CPU compares the contents of the accumulator, A, to the memory location that the
HL register points to and outputs the difference. This instruction does not affect the con-
tents of the reference memory location or the accumulator. The HL and BC registers dec-
rement. This operation is repeated until one of the following two conditions is met:
1. A = (HL), which sets the 0 Flag (Z).
2. BC is decremented to 0, which resets the P/V Flag.
In Z80 mode, the BC register is 16 bits, which allows the CPDR instruction to repeat a
maximum of 65536 (64 K) times. In ADL mode, the BC register is 24 bits, which allows
the CPDR instruction to repeat a maximum of 16,777,216 (16 M) times.
Condition Bits Affected
S
Z
H
P/V
N
C
Attributes
Mnemonic
CPDR
CPDR.S
CPDR.L
UM007714-0908
Set if result is negative; reset otherwise.
Set if A = (HL); reset otherwise.
Set if borrow from bit 4; reset otherwise.
Set if BC – 1 ≠ 0; reset otherwise.
Set.
Not affected.
Operand
ADL Mode
—
X
—
1
—
0
Cycle
Opcode (hex)
1 + 3 * BC
ED, B9
2 + 3 * BC
52, ED, B9
2 + 3 * BC
49, ED, B9
®
eZ80
CPU
User Manual
125
CPU Instruction Set
Need help?
Do you have a question about the eZ80 and is the answer not in the manual?
Questions and answers