ADD
This instruction adds two operands and stores the result in the destination operand. The source operand remains unchanged.
The flags are modified as follows:
- If the result exceeds the size of the destination operand, then
CF=1. Otherwise,CF=0. - If the result is zero, then
ZF=1. Otherwise,ZF=0. - If the most significant bit of the result is
1, thenSF=1. Otherwise,SF=0. - If the sum of two positive numbers results in a negative number, or the sum of two negative numbers results in a positive number, then
OF=1. Otherwise,OF=0.
Usage
vonsim
ADD dest, sourceThe valid combinations for dest and source are:
- Register, register
- Register, memory address
- Register, immediate
- Memory address, register
- Memory address, immediate
(See operand types)
Encoding
- REGISTER to register
1000100w,00RRRrrr - Memory (direct) to register
1000100w,01000rrr, addr-low, addr-high - Memory (indirect) to register
1000100w,01010rrr - Memory (indirect with offset) to register
1000100w,01100rrr, disp-low, disp-high - Immediate to register
1000100w,01001rrr, data-low, data-high - Register to memory (direct)
1000100w,11000rrr, addr-low, addr-high - Register to memory (indirect)
1000100w,11010rrr - Register to memory (indirect with offset)
1000100w,11100rrr, disp-low, disp-high - Immediate to memory (direct)
1000100w,11001000, addr-low, addr-high, data-low, data-high - Immediate to memory (indirect)
1000100w,11011000, data-low, data-high - Immediate to memory (indirect with offset)
1000100w,11101000, disp-low, disp-high, data-low, data-high
Where w is the operand size bit. w=0 indicates 8-bit operands, and w=1 indicates 16-bit operands. When w=0, data-high is omitted (the instruction length is one byte shorter).
rrr or RRR encodes a register according to the following table:
rrr | w=0 | w=1 |
|---|---|---|
000 | AL | AX |
001 | CL | CX |
010 | DL | DX |
011 | BL | BX |
100 | AH | SP |
101 | CH | -- |
110 | DH | -- |
111 | BH | -- |