Instruction Set
4-240
SUB
Subtract Numbers
SUB
What It Does
SUB subtracts an integer or an unsigned number from another number of the same type.
Syntax
Description
SUB subtracts the second operand (
subtrahend) from the first operand (difference). The
first operand is assigned the result of the subtraction and the flags are set accordingly. If
an immediate byte value is subtracted from a word operand, the immediate value is first
sign-extended to the size of the destination operand.
Operation It Performs
Form
Opcode
Description
Clocks
Am186 Am188
SUB AL,
imm8
2C
ib
Subtract immediate byte from AL
3
3
SUB AX,
imm16
2D
iw
Subtract immediate word from AX
4
4
SUB
r/m8,imm8
80
/5 ib
Subtract immediate byte from r/m byte
4/16
4/16
SUB
r/m16,imm16
81
/5 iw
Subtract immediate word from r/m word
4/16
4/20
SUB
r/m16,imm8
83
/5 ib
Subtract sign-extended immediate byte from r/m word
4/16
4/20
SUB
r/m8,r8
28
/r
Subtract byte register from r/m byte
3/10
3/10
SUB
r/m16,r16
29
/r
Subtract word register from r/m word
3/10
3/14
SUB
r8,r/m8
2A
/r
Subtract r/m byte from byte register
3/10
3/10
SUB
r16,r/m16
2B
/r
Subtract r/m word from word register
3/10
3/14
SUB
difference,subtrahend
if (size(
difference) == 16)
if (size(
subtrahend) == 8)
/* extend sign of subtrahend */
if (
subtrahend < 0)
subtrahend = 0xFF00 | subtrahend;
else
subtrahend = 0x00FF & subtrahend;
/* subtract */
difference = difference - subtrahend;
Summary of Contents for Am186 Series
Page 1: ...Am186 and Am188 Family Instruction Set Manual February 1997...
Page 10: ...Table of Contents x...
Page 18: ...Programming 1 8...
Page 40: ...Instruction Set Listing 3 14...