- CPDR
Compare and Decrement with Repeat
- Description
- Performs
cpd
until eitherA
=(HL)
orBC
= 0.cp a,(hl) dec hl dec bc jr nz,-7 ret po jr -10
- Uses
- Finding a certain letter in a string (or other similar tasks)
- Results
Register/Flag 16-bit (non-ADL) 24-bit (ADL) S
flagSet if result is negative; else reset ----------------
Z
flag--------------------------------------------Set if
A
=(HL)
; else reset----------------
H
flag--------------------------------------------Set if borrow from bit 4; else reset
---------------- -------------------------------------------- ---------------------------------------- P/V
flagSet if BC
≠ 0 after the operation; elsereset ----------------
N
flag--------------------------------------------Set
----------------
C
flag--------------------------------------------Not affected
- Allowed Instructions
Instruction Opcode CC (ADL/non-ADL) CC (.S) CC (.L) cpir $ED, $B1 2F + (Iterations)*(1R + 2) - 1
whereIterations
is the number of iterations ofcpd
before eitherA
=(HL)
orBC
= 03F + (Iterations)*(1R + 2) - 1 3F + (Iterations)*(1R + 2) - 1 - Notes
- Interrupts can be triggered while this instruction is in progress (unless they are disabled using
DI
, of course).
- Interrupts can be triggered while this instruction is in progress (unless they are disabled using
- See Also