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 bytes · 16 cycles

SZHP/VNC ●●●●1–
  • ● set from the result
  • 1 always 1
  • – not changed

Forms

  • cpd

    Compares the value of the memory location pointed to by HL with A. Then HL and BC are decremented. p/v is reset if BC becomes zero and set otherwise.

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