8-18 Vol. 1
PROGRAMMING WITH THE X87 FPU
8.3.4
Load Constant Instructions
The following instructions push commonly used constants onto the top [ST(0)] of the x87 FPU register stack:
FLDZ
Load +0.0
FLD1
Load +1.0
FLDPI
Load π
FLDL2T
Load log
2
10
FLDL2E
Load log
2
e
FLDLG2
Load log
10
2
FLDLN2
Load log
e
2
The constant values have full double extended-precision floating-point precision (64 bits) and are accurate to
approximately 19 decimal digits. They are stored internally in a format more precise than double extended-preci-
sion floating point. When loading the constant, the x87 FPU rounds the more precise internal constant according
to the RC (rounding control) field of the x87 FPU control word. The inexact-result exception (#P) is not generated
as a result of this rounding, nor is the C1 flag set in the x87 FPU status word if the value is rounded up. See
Section 8.3.8, “Approximation of Pi,” for information on the π constant.
8.3.5
Basic Arithmetic Instructions
The following floating-point instructions perform basic arithmetic operations on floating-point numbers. Where
applicable, these instructions match IEEE Standard 754:
FADD/FADDP
Add floating point
FIADD
Add integer to floating point
FSUB/FSUBP
Subtract floating point
FISUB
Subtract integer from floating point
FSUBR/FSUBRP
Reverse subtract floating point
FISUBR
Reverse subtract floating point from integer
FMUL/FMULP
Multiply floating point
FIMUL
Multiply integer by floating point
FDIV/FDIVP
Divide floating point
FIDIV
Divide floating point by integer
FDIVR/FDIVRP
Reverse divide
FIDIVR
Reverse divide integer by floating point
FABS
Absolute value
FCHS
Change sign
FSQRT
Square root
FPREM
Partial remainder
FPREM1
IEEE partial remainder
FRNDINT
Round to integral value
FXTRACT
Extract exponent and significand
The add, subtract, multiply and divide instructions operate on the following types of operands:
•
Two x87 FPU data registers
•
An x87 FPU data register and a floating-point or integer value in memory
See Section 8.1.2, “x87 FPU Data Registers,” for a description of how operands are referenced on the data register
stack.
Operands in memory can be in single-precision floating-point, double-precision floating-point, word-integer, or
doubleword-integer format. They are converted to double extended-precision floating-point format automatically.