cmp

8086 and later

Compare Two Operands

cmp r/m8, reg8 | cmp r/m16, reg16 | cmp r/m32, reg32 | cmp r/m64, reg64 | cmp reg8, r/m8 | cmp reg16, r/m16 | cmp reg32, r/m32 | cmp reg64, r/m64 | cmp r/m16, imm8 | cmp r/m32, imm8 | cmp r/m64, imm8 | cmp al, imm8 | cmp ax, imm16 | cmp eax, imm32 | cmp rax, imm32 | cmp r/m8, imm8 | cmp r/m16, imm16 | cmp r/m32, imm32 | cmp r/m64, imm32

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.

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. In these cases, the BYTE qualifier is necessary to force NASM to generate this form of the instruction.

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.

Loading...

Forms

Every form of cmp the assembler accepts, from NASM's own instruction table. The second column is the processor that introduced the form; a badge marks a form that needs an extension, that is lockable, or that long mode dropped.

FormSinceNotes
cmp r/m8, reg88086lock
cmp r/m16, reg168086lock
cmp r/m32, reg32386lock
cmp r/m64, reg64x86-64locklong
cmp reg8, r/m88086
cmp reg16, r/m168086
cmp reg32, r/m32386
cmp reg64, r/m64x86-64long
cmp r/m16, imm88086lock
cmp r/m32, imm8386lock
cmp r/m64, imm8x86-64locklong
cmp al, imm88086
cmp ax, imm168086
cmp eax, imm32386
cmp rax, imm32x86-64long
cmp r/m8, imm88086lock
cmp r/m16, imm168086lock
cmp r/m32, imm32386lock
cmp r/m64, imm32x86-64locklong