cpi

Compare and increment

Compares A with the byte at (HL), then increments HL and decrements 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

  • cpi

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

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