7-46
FLOATING-POINT UNIT
7.7.FLOATING-POINT EXCEPTION HANDLING
The FPU detects six classes of exception conditions while executing floating-point instructions:
Invalid operation (#I)
Stack overflow or underflow (#IS)
Invalid arithmetic operation (#IA)
Divide-by-zero (#Z)
Denormalized operand (#D)
Numeric overflow (#O)
Numeric underflow (#U)
Inexact result (precision) (#P)
The nomenclature of # symbol followed by one or two letters (for example, #IS) is used in this
manual to indicate exception conditions. It is merely a short-hand form and is not related to
assembler mnemonics.
Each of the six exception classes has a corresponding flag bit in the FPU status word and a mask
bit in the FPU control word (refer to Section 7.3.2., FPU Status Register and Section 7.3.4.,
FPU Control Word, respectively). In addition, the exception summary (ES) flag in the status
word indicates when any of the exceptions has been detected, and the stack fault (SF) flag (also
in the status word) distinguishes between the two types of invalid operation exceptions.
When the FPU detects a floating-point exception, it sets the appropriate flags in the FPU status
word, then takes one of two possible courses of action:
Handles the exception automatically, producing a predefined (and often times usable
result), while allowing program execution to continue undisturbed.
Invokes a software exception handler to handle the exception.
The following sections describe how the FPU handles exceptions (either automatically or by
calling a software exception handler), how the FPU detects the various floating-point excep-
tions, and the automatic (masked) response to the floating-point exceptions.
7.7.1.Arithmetic vs. Non-arithmetic Instructions
When dealing with floating-point exceptions, it is useful to distinguish between arithmetic
instructions and non-arithmetic instructions. Non-arithmetic instructions have no operands
or do not make substantial changes to their operands. Arithmetic instructions do make signifi-
cant changes to their operands; in particular, they make changes that could result in a floating-
point exception being signaled. Table 7-20 lists the non-arithmetic and arithmetic instructions.
It should be noted that some non-arithmetic instructions can signal a floating-point stack (fault)
exception, but this exception is not the result of an operation on an operand.