Intel 64 and IA-32 Architectures Software Developers Manual Volume 1, Basic Architecture

8-38 Vol. 1
PROGRAMMING WITH THE X87 FPU
8.5.1.2 Invalid Arithmetic Operand Exception (#IA)
The x87 FPU is able to detect a variety of invalid arithmetic operations that can be
coded in a program. These operations are listed in Table 8-10. (This list includes the
invalid operations defined in IEEE Standard 754.)
When the x87 FPU detects an invalid arithmetic operand, it sets the IE flag (bit 0) in
the x87 FPU status word to 1. If the invalid-operation exception is masked, the x87
FPU then returns an indefinite value or QNaN to the destination operand and/or sets
the floating-point condition codes as shown in Table 8-10. If the invalid-operation
exception is not masked, a software exception handler is invoked (see Section 8.7,
“Handling x87 FPU Exceptions in Software”) and the top-of-stack pointer (TOP) and
source operands remain unchanged.
Table 8-10. Invalid Arithmetic Operations and the
Masked Responses to Them
Condition Masked Response
Any arithmetic operation on an operand that is in
an unsupported format.
Return the QNaN floating-point indefinite
value to the destination operand.
Any arithmetic operation on a SNaN. Return a QNaN to the destination operand (see
Table 4-7).
Ordered compare and test operations: one or both
operands are NaNs.
Set the condition code flags (C0, C2, and C3) in
the x87 FPU status word or the CF, PF, and ZF
flags in the EFLAGS register to 111B (not
comparable).
Addition: operands are opposite-signed infinities.
Subtraction: operands are like-signed infinities.
Return the QNaN floating-point indefinite
value to the destination operand.
Multiplication: by 0; 0 by . Return the QNaN floating-point indefinite
value to the destination operand.
Division: by ; 0 by 0. Return the QNaN floating-point indefinite
value to the destination operand.
Remainder instructions FPREM, FPREM1: modulus
(divisor) is 0 or dividend is .
Return the QNaN floating-point indefinite;
clear condition code flag C2 to 0.
Trigonometric instructions FCOS, FPTAN, FSIN,
FSINCOS: source operand is .
Return the QNaN floating-point indefinite;
clear condition code flag C2 to 0.
FSQRT: negative operand (except FSQRT (–0) = –
0); FYL2X: negative operand (except FYL2X (–0) =
); FYL2XP1: operand more negative than –1.
Return the QNaN floating-point indefinite
value to the destination operand.
FBSTP: Converted value cannot be represented in
18 decimal digits, or source value is an SNaN,
QNaN, ±∞, or in an unsupported format.
Store packed BCD integer indefinite value in
the destination operand.