
Instruction Set
4-242
SUB
SUB
Tips
To subtract an integer or an unsigned number located in memory from another number of
the same type that is also located in memory, copy one of them to a register before using
SUB.
SUB requires both operands to be the same size. Before subtracting an 8-bit integer from
a 16-bit integer, convert the 8-bit integer to its 16-bit equivalent using CBW. To convert an
8-bit unsigned number to its 16-bit equivalent, use MOV to copy 0 to AH.
To subtract numbers larger than 16 bits, use SUB to subtract the low words, and then use
SBB to subtract each of the subsequently higher words.
Use DEC instead of SUB within a loop when you want to decrease a value by 1 each time
the loop is executed.
The processor does not provide an instruction that performs decimal subtraction. To
subtract decimal numbers, use SBB or SUB to perform binary subtraction, and then convert
the result to decimal using AAS or DAS.
ADC, ADD, SBB, and SUB set AF when the result needs to be converted for decimal
arithmetic. AAA, AAS, DAA, and DAS use AF to determine whether an adjustment is
needed. This is the only use for AF.
Related Instructions
If you want to
See
Convert an 8-bit unsigned binary difference to its unpacked decimal equivalent
AAS
Convert an integer to its 16-bit equivalent
CBW
Compare two components using subtraction and set the flags accordingly
CMP
Convert an 8-bit unsigned binary difference to its packed decimal equivalent
DAS
Decrement an integer or unsigned number by 1
DEC
Change the sign of an integer
NEG
Subtract a number and the value of CF from another number
SBB
Содержание 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...