
Instruction Set
4-34
CMP
Compare Components
CMP
What It Does
CMP compares two components using subtraction and sets the flags accordingly.
Syntax
Description
CMP subtracts the second operand from the first, but does not store the result. CMP only
changes the flag settings. The CMP instruction is typically used in conjunction with
conditional jumps. If an operand greater than one byte is compared to an immediate byte,
the byte value is first sign-extended.
Operation It Performs
Form
Opcode
Description
Clocks
Am186 Am188
CMP AL,
imm8
3C
ib
Compare immediate byte to AL
3
3
CMP AX,
imm16
3D
iw
Compare immediate word to AX
4
4
CMP
r/m8,imm8
80
/7 ib
Compare immediate byte to r/m byte
3/10
3/10
CMP
r/m16,imm16
81
/7 iw
Compare immediate word to r/m word
3/10
3/14
CMP
r/m16,imm8
83
/7 ib
Compare sign-extended immediate byte to r/m word
3/10
3/14
CMP
r/m8,r8
38
/r
Compare byte register to r/m byte
3/10
3/10
CMP
r/m16,r16
39
/r
Compare word register to r/m word
3/10
3/14
CMP
r8,r/m8
3A
/r
Compare r/m byte to byte register
3/10
3/10
CMP
r16,r/m16
3B
/r
Compare r/m word to word register
3/10
3/14
CMP
value1,value2
if (
value2 == imm8)
if (size(
value1) > 8)
/* extend sign of value2 */
if (value2 < 0)
value2 = 0xFF00 | value2;
else
value2 = 0x00FF & value2;
/* compare values */
temp = value1 - value2;
/* don’t store result, but set appropriate flags */
Содержание Am186 Series
Страница 1: ...Am186 and Am188 Family Instruction Set Manual February 1997...
Страница 10: ...Table of Contents x...
Страница 18: ...Programming 1 8...
Страница 40: ...Instruction Set Listing 3 14...