Slide 4.15: ADD instruction
Slide 4.17: CALL instruction
Home

SUB Instruction


The SUB subtracts a source operand from a destination operand.

 SUB — Subtract 
Usage: SUB dest, src

Flag O D I S Z A P C
Result *     * * * * *

The source is subtracted from the destination and the result is stored in the destination.
Clocks
Operands 286 386 486 Size Bytes
reg, reg 2 2 1 2
mem, reg 7 6 3 2-4
reg, mem 7 7 2 2-4
reg, immed 3 2 1 3-4
mem, immed 7 7 3 3-6
accum, immed 3 2 1 2-3

Source is unchanged by the operation, and the difference is stored in the destination operand. The set of possible operands is the same as for the ADD and MOV instructions.

 Register & Immediate   Memory & Register   Clear 
 .data
 X   SDWORD  20h
 .code
 mov   eax, X
 sub   eax, 20
 call  WriteInt
 .data
 X   SDWORD  20h
 Y   SDWORD  20
 .code
 mov   eax, Y
 sub   X, eax
 call  WriteInt
 .data
 X   SDWORD  20h
 Y   SDWORD  20
 .code
 sub   eax, eax
 sub   eax, Y
 add   eax, X
 call  WriteInt
 Output   Output   Output