Assembly-Guidebook

CMP Instruction

Compares the equality of two operands CMP AX,BX
SYNTAX CMP operand1, operand2
NOTE– result is not stored anywhere, flags are set (OF, SF, ZF, AF, PF, CF) according to result

CMP supprts these operands

  1. CMP REG, MEMORY
  2. CMP MEMORY, REG
  3. CMP REG, REG
  4. CMP MEMORY, IMMEDIATE
  5. CMP REG, IMMEDIATE

Example

MOV AL, 5
MOV BL, 5
CMP AL, BL  ; Al = BL = 5 ==> ZF is set to 1
RET