AMD amd64 architecture User Manual

Page of 336
x87 Floating-Point Programming
283
24592—Rev. 3.15—November 2009
AMD64 Technology
For exceptions that occur before the associated operation (pre-operation, as shown in Table 6-19), if an
unmasked exception occurs, the processor suspends processing of the faulting instruction but it waits
until the boundary of the next non-control x87 or 64-bit media instruction to be executed before
invoking the associated exception service routine. During this delay, non-x87 instructions may
overwrite the faulting x87 instruction’s source or destination operands in memory. If that occurs, the
x87 service routine may be unable to perform its job.
To prevent such problems, analyze x87 procedures for potential exception-causing situations and
insert a WAIT or other safe x87 instruction immediately after any x87 instruction that may cause a
problem.
6.8.4 x87 Floating-Point Exception Masking
The six floating-point exception flags in the x87 status word have corresponding exception-flag masks
in the x87 control word, as shown in Table 6-20 on page 284.
Table 6-19.
Priority of x87 Floating-Point Exceptions
Priority
Exception or Operation
Timing
1
Invalid-operation exception (IE) with stack fault
(SF) due to underflow
Pre-Computation
2
Invalid-operation exception (IE) with stack fault
(SF) due to overflow
Pre-Computation
3
Invalid-operation exception (IE) when accessing
unsupported data type
Pre-Computation
4
Invalid-operation exception (IE) when accessing
SNaN operand
Pre-Computation
5
Operation involving a QNaN operand
1
6
Any other type of invalid-operation exception (IE)
Pre-Computation
Zero-divide exception (ZE)
Pre-Computation
7
Denormalized operation exception (DE)
Pre-Computation
8
Overflow exception (OE)
Post-Computation
Underflow exception (UE)
Post-Computation
9
Precision (inexact) exception (PE)
Post-Computation
Note:
1. Operations involving QNaN operands do not, in themselves, cause exceptions but they are
handled with this priority relative to the handling of exceptions.