| |||||||||
| |||||||||
Adding and Subtracting in Multiple Registers:Numbers larger than the register size on your processor can be added and subtracted with the ADC (Add with Carry) and SBB (Subtract with Borrow) instructions.
These instructions work as follows: ADC Dest, Source ; Dest = Dest + Source + Carry Flag SBB Dest, Source ; Dest = Dest - Source - Carry Flag
If the operations prior to an ADC or SBB instruction do not set the carry flag,
these instructions are identical to ADD and SUB. While operating on large values
in more than one register, ADD and SUB are used for the least significant part of
the number and ADC or SBB for the most significant part.
Adding and Subtracting on 64 bit Operands:This technique can also be used with 64-bit operands on the 80386/486 processors. For 32-bit registers on the 80386/486 processors, only two steps are necessary. If your program needs to be assembled for more than one processor, you can assemble the statements conditionally, as shown in this example:
Since the status of the carry flag affects the results of calculations with ADC and SBB, be sure to turn off the carry flag with the CLC (Clear Carry Flag) instruction or use ADD or SUB for the first calculation, when appropriate. |