Floating-Point Add

Encoding

EncodingOperand 1Operand 2
0mST(0)ModRM.r/m[r]
mModRM.r/m[r]N/A
m0ModRM.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-∞-finitesrcsrc±finite or ±0+∞NaN
-0-∞dest-0±0dest+∞NaN
+0-∞dest±0+0dest+∞NaN
+finite-∞±finite or ±0srcsrc+finite+∞NaN
+∞*+∞+∞+∞+∞+∞NaN
NaNNaNNaNNaNNaNNaNNaNNaN

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.