W X + Y +24 - Z

Figure 3-13 Binary addition and subtraction instructions.

NameMnemonic and FormatDescription
Add
ADD    DST, SRC
(DST)(SRC)+(DST)
Add with carry
ADC    DST, SRC
(DST)(SRC)+(DST)+(CF)
Subtract
SUB    DST, SRC
(DST)(DST)-(SRC)
Subtract with borrow
SBB    DST, SRC
(DST)(DST)-(SRC)-(CF)

Flags: All condition flags are affected.

Addressing modes: Unless the source operand is immediate, one of the operands must be in a register. The other may have any addressing mode.

Figure 3-14 Single-precision example.

Data related directives, input, and other code
X, Y, W, and Z are defined as word variables
     MOV    AX,X      ;PUT (X) IN AX
     ADD    AX,Y      ;ADD (Y) TO AX
     ADD    AX,24     ;ADD 24 TO SUM
     SUB    AX,Z      ;SUBTRACT Z FROM X+Y+24
     MOV    W,AX      ;STORE RESULT IN W
Output and other code

Figure 3-15 Double-precision addition.

Data related directives, input, and other code
DP1, DP2, and DPSUM are defined as word variables
     MOV    AX,DP1      ;ADD THE LOW ORDER
     ADD    AX,DP2      ;WORDS IN DP1 AND DP2
     MOV    DPSUM,AX    ;AND PUT SUM IN DPSUM
     MOV    AX,DP1+2    ;ADD THE HIGH-ORDER WORDS
     ADC    AX,DP2+2    ;IN DP1+2 AND DP2+2 WITH
     MOV    DPSUM+2,AX  ;CARRY AND PUT SUM IN DPSUM+2
Output and other code

Table of Contents | Next page | Previous page

This is page 28.