The CPI instruction

The CPI (Compare Immediate) instruction is used to compare the contents of the accumulator with an 8-bit immediate value. Like the CMP instruction, it conceptually performs a subtraction operation, but does not store the result; instead, it updates the flag bits depending on the result of the comparison.

The CPI instruction format

InstructionDescription
CPI imm8 This format is used to compare the value in register A with imm8.

Usage example

; Author: Evgeny Sergeevich Dovgopolov

main:
    mvi     a, 01h  ; Load the hexadecimal value 01h into register A
    cpi     02h     ; Compare the value in register A with 2

    hlt             ; Stop program execution

Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".

Processor status flags

S
Yes
Z
Yes
AC
Yes
P
Yes
CY
Yes