Opcode | Encoding | 16-bit | 32-bit | 64-bit | CPUID Feature Flag(s) | Description |
---|---|---|---|---|---|---|
D8 /0 FADD m32fp | m | Valid | Valid | Valid | fpu | Add ST(0) to m32fp. Store the result in ST(0) . |
DC /0 FADD m64fp | m | Valid | Valid | Valid | fpu | Add ST(0) to m64fp. Store the result in ST(0) . |
D8 C0+i FADD ST(0), ST(i) | 0m | Valid | Valid | Valid | fpu | Add ST(i) to ST(0) . Store the result in ST(0) . |
DC C0+i FADD ST(i), ST(0) | m0 | Valid | Valid | Valid | fpu | Add ST(0) to ST(i) . Store the result in ST(i) . |
DE C0+i FADDP ST(i), ST(0) | m0 | Valid | Valid | Valid | fpu | Add ST(0) to ST(i) . Store the result in ST(i) . Pop the register stack. |
DE /0 FIADD m16int | m | Valid | Valid | Valid | fpu | Add m16int to ST(0) . Store the result in ST(0) . |
DA /0 FIADD m32int | m | Valid | Valid | Valid | fpu | Add m32int to ST(0) . Store the result in ST(0) . |
Encoding
Encoding | Operand 1 | Operand 2 |
---|---|---|
0m | ST(0) | ModRM.r/m[r] |
m | ModRM.r/m[r] | N/A |
m0 | ModRM.r/m[rw] | ST(0) |
Description
The FADD
instruction (and the FADDP
and FIADD
variants) adds the source operand to the destination operand. Variants that reference memory implicitly use the ST(0)
register as the destination. If the FADDP
variant is used, the FPU stack is popped at the end.
The table below summarizes the result of various operands. The two cells with asterisks in them (one operand is negative infinity and the other is positive infinity) result in a #IA
exception.
dest | ||||||||
---|---|---|---|---|---|---|---|---|
-∞ | -finite | -0 | +0 | +finite | +∞ | NaN | ||
src | -∞ | -∞ | -∞ | -∞ | -∞ | -∞ | * | NaN |
-finite | -∞ | -finite | src | src | ±finite or ±0 | +∞ | NaN | |
-0 | -∞ | dest | -0 | ±0 | dest | +∞ | NaN | |
+0 | -∞ | dest | ±0 | +0 | dest | +∞ | NaN | |
+finite | -∞ | ±finite or ±0 | src | src | +finite | +∞ | NaN | |
+∞ | * | +∞ | +∞ | +∞ | +∞ | +∞ | NaN | |
NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
Operation
public void FADD(F32 src)
{
ST(0) += src;
}
public void FADD(F64 src)
{
ST(0) += src;
}
public void FADD(ref F80 dest, F80 src)
{
dest += src;
}
public void FADDP(ref F80 dest, F80 src)
{
dest += src;
FpuPop();
}
public void FADD(I16 src)
{
ST(0) += src;
}
public void FADD(I32 src)
{
ST(0) += src;
}
Flags Affected
C0
- Undefined.
C1
- Set if the result was rounded up. Cleared otherwise, or if a stack overflow occurs.
C2
- Undefined.
C3
- Undefined.
Exceptions
Legacy Floating-Point
#MF
#D
- Denormal operand.#IA
- Invalid arithmetic operation.#IS
- Stack overflow or underflow.#O
- Numeric overflow.#P
- Inexact result.#U
- Numeric underflow.