Repeats CPD until either:
The carry is preserved, N is set and all the other flags are affected as defined. P/V denotes the overflowing of BC, while the Z flag is set if A=(HL) before HL is decreased.
Say you want to find the last occurrence of 124 in the valid memory space:
LD HL,0000h LD BC,0000h LD A,124 CPDR
Note if you used CPIR it would find the first occurrence of 124 in the valid memory space.
|BC ≠ 0 and A ≠ (HL)||21|
|BC = 0 or A = (HL)||16|