User Guide
x87 Floating-Point Programming 243
24592—Rev. 3.15—November 2009 AMD64 Technology
Overflow Exception (OE). Bit 3. The processor sets this bit to 1 when the absolute value of a
rounded result is larger than the largest representable normalized floating-point number for the
destination format. (See “Normalized Numbers” on page 254.)
Underflow Exception (UE). Bit 4. The processor sets this bit to 1 when the absolute value of a
rounded non-zero result is too small to be represented as a normalized floating-point number for the
destination format. (See “Normalized Numbers” on page 254.)
The underflow exception has an unusual behavior. When masked by the UM bit (bit 4 of the x87
control word), the processor only reports a UE exception if the UE occurs together with a precision
exception (PE).
Precision Exception (PE). Bit 5. The processor sets this bit to 1 when a floating-point result, after
rounding, differs from the infinitely precise result and thus cannot be represented exactly in the
specified destination format. The PE exception is also called the inexact-result exception.
Stack Fault (SF). Bit 6. The processor sets this bit to 1 when a stack overflow (due to a push or load
into a non-empty stack register) or stack underflow (due to referencing an empty stack register) occurs
in the x87 stack-register file. When either of these conditions occur, the processor also sets the invalid-
operation exception (IE) flag, and the processor distinguishes overflow from underflow by writing the
condition-code 1 (C1) bit (C1 = 1 for overflow, C1 = 0 for underflow). Unlike the flags for the other
x87 exceptions, the SF flag does not have a corresponding mask bit in the x87 control word.
If, subsequent to the instruction that caused the SF bit to be set, a second invalid-operation exception
(IE) occurs due to an invalid operand in an arithmetic instruction (i.e., not a stack fault), and if software
has not cleared the SF bit between the two instructions, the SF bit will remain set.
Exception Status (ES). Bit 7. The processor calculates the value of this bit at each instruction
boundary and sets the bit to 1 when one or more unmasked floating-point exceptions occur. If the ES
bit has already been set by the action of some prior instruction, the processor invokes the #MF
exception handler when the next non-control x87 or 64-bit media instruction is executed. (See
“Control” on page 273 for a definition of control instructions).
The ES bit can be written, but the written value is ignored. Like the SF bit, the ES bit does not have a
corresponding mask bit in the x87 control word.
Top-of-Stack Pointer (TOP). Bits 13–11. The TOP contains the physical register index of the
location of the top of stack, ST(0). It thus specifies the mapping of the x87 stack registers,
ST(0)–ST(7), onto the x87 physical registers, FPR0–FPR7. The processor changes the TOP during any
instructions that pushes or pops the stack. For details on how the stack works, see “Stack
Organization” on page 240.
Condition Codes (C3–C0). Bits 14 and 10–8. The processor sets these bits according to the result of
arithmetic, compare, and other instructions. In certain cases, other status-word flags can be used
together with the condition codes to determine the result of an operation, including stack overflow,
stack underflow, sign, least-significant quotient bits, last-rounding direction, and out-of-range