
Instruction Set
4-218
SBB
SBB
This example subtracts one 32-bit integer in a register (the subtrahend) from another 32-
bit integer in memory (the minuend). This is accomplished by subtracting one word at a
time. The first subtraction uses SUB, and the subsequent subtraction uses SBB in case a
borrow was generated by the previous subtraction. (CF doubles as the borrow flag. If CF
is set, the previous subtraction generated a borrow. Otherwise, the previous subtraction
did not generate a borrow.)
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
SBB.
SBB 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.
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 integer to its 16-bit equivalent
CBW
Convert an 8-bit unsigned binary difference to its packed decimal equivalent
DAS
Change the sign of an integer
NEG
Subtract a number from another number
SUB
SMINUEND
DD
44761089
; 02AB0001h
SSUBTRAHEND
DD
-990838848
; C4F0FFC0h
; 32-bit integer subtraction: SMINUEND = SMINUEND - SSUBTRAHEND
; low word subtraction
MOV
AX,WORD PTR SSUBTRAHEND
; copy subtrahend
SUB
WORD PTR SMINUEND,AX
; subtract
; high word subtraction
MOV
AX,WORD PTR SSUBT 2
; copy subtrahend
SBB
WORD PTR SM 2,AX
; subtract with borrow
; SMINUEND = C79BFFC1h
; = -946077759
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...