cpd

Compare and decrement

Compares A with the byte at (HL), then decrements HL and BC, setting P/V while BC is not zero.

2 bytes16 cycles

SZHP/VNC ●●●●1–
  • ● depends on the result
  • 1 always 1
  • – not changed

Forms

  • cpd

    Compares the value of the memory location pointed to by HL with A. Then decrements HL and BC. Resets the parity/overflow flag if BC becomes zero, and sets it otherwise.

        .org 0x8000
        ld a, 3
        ld hl, source + 3
        ld bc, 4
        cpd
        halt
source: .byte 1, 2, 3, 4