CPDR¶
- 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
flagSet if A
=(HL)
; else resetH
flagSet if borrow from bit 4; else reset P/V
flagSet if BC
≠ 0 after the operation; else resetN
flagSet C
flagNot 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
- CP, CPD, CPI, CPIR, LDDR