A.5.24 CMP: Compare Integers
CMP r/m8,reg8 ; 38 /r [8086]
CMP r/m16,reg16 ; o16 39 /r [8086]
CMP r/m32,reg32 ; o32 39 /r [386]
CMP reg8,r/m8 ; 3A /r [8086]
CMP reg16,r/m16 ; o16 3B /r [8086]
CMP reg32,r/m32 ; o32 3B /r [386]
CMP r/m8,imm8 ; 80 /7 ib [8086]
CMP r/m16,imm16 ; o16 81 /7 iw [8086]
CMP r/m32,imm32 ; o32 81 /7 id [386]
CMP r/m16,imm8 ; o16 83 /7 ib [8086]
CMP r/m32,imm8 ; o32 83 /7 ib [386]
CMP AL,imm8 ; 3C ib [8086]
CMP AX,imm16 ; o16 3D iw [8086]
CMP EAX,imm32 ; o32 3D id [386]
CMP performs a "mental" subtraction of its second operand from its
first operand, and affects the flags as if the subtraction had taken
place, but does not store the result of the subtraction anywhere. (For
subtraction that does store the result, see section A.5.305.)
In the forms with an 8-bit immediate second operand and a longer first
operand, the second operand is considered to be signed, and is sign-
extended to the length of the first operand. The BYTE qualifier can be
used to force NASM to generate this form of the instruction. Recent
versions of NASM automatically optimise to this form if the immediate
operand's value is known during the assembling of that instruction, and
fits in the range of a signed byte. The longer variant can then still be
forced using the STRICT WORD or STRICT DWORD qualifier.
The destination operand can be a register or a memory location. The
source can be a register, memory location or an immediate value of the
same size as the destination.