X86-assembly/Instructions/cmp

From aldeid
Jump to navigation Jump to search
You are here:
cmp

Description

  • The cmp instruction is used to perform comparison. It's identical to the sub instruction except it does not affect operands.
  • It impacts the Zero Flag (ZF) as well as the Carry Flag (CF) as follows:
cmp dst, src ZF CF
dst = src 1 0
dst < src 0 1
dst > src 0 0

Syntax

cmp destination, source

Example

cmp [ebp+arg_0], 1     ; compare 1 with [ebp+arg_0]
jnz short loc_402B1D   ; Jump short if not zero (ZF=0)

Comments