CMP             Compare                              Flags: O D I T S Z A P C
* - - - * * * * *
CMP destination,source

Logic Flags set according to result of
(destination - source)

CMP compares two numbers by subtracting the source from the
destination and updates the flags. None of the operands are
changed by CMP.


Opcode Format
38 /r CMP r/m8,r8
39 /r CMP r/m16,r16
39 /r CMP r/m32,r32
3A /r CMP r8,r/m8
3B /r CMP r16,r/m16
3B /r CMP r32,r/m32
3C ib CMP AL,imm8
3D iw CMP AX,imm16
3D id CMP EAX,imm32
80 /7 ib CMP r/m8,imm8
81 /7 iw CMP r/m16,imm16
81 /7 id CMP r/m32,imm32
83 /7 ib CMP r/m16,imm8
83 /7 ib CMP r/m32,imm8


Length and timing
Operands Bytes 8088 186 286 386 486 Pentium
reg, reg 2 3 3 2 2 1 1 UV
mem, reg 2+d(0,2) 13+EA 10 7 5 2 2 UV
reg, mem 2+d(0,2) 13+EA 10 6 6 2 2 UV
reg, imm 2+i(1,2) 4 4 3 2 1 1 UV
mem, imm 2+d(0,2) 14+EA 10 6 5 2 2 UV*
+i(1,2)
acc, imm 1+i(1,2) 4 4 3 2 1 1 UV

* = not pairable if there is a displacement and immediate