7-51
FLOATING-POINT UNIT
Other typical exception handler actions include:
Examining stored FPU state information (control, status, and tag words, and FPU
instruction and operand pointers) to determine the nature of the error.
Correcting the condition that caused the error.
Clearing the exception bits in the status word.
Returning to the interrupted program and resuming normal execution.
If the faulting floating-point instruction is followed by one or more non-floating-point instruc-
tions, it may not be useful to re-execute the faulting instruction. Refer to Section 7.9., Floating-
Point Exception Synchronization, for more information on synchronizing floating-point excep-
tions.
In cases where the handler needs to restart program execution with the faulting instruction, the
IRET instruction cannot be used directly. The reason for this is that because the exception is not
generated until the next floating-point or WAIT/FWAIT instruction following the faulting
floating-point instruction, the return instruction pointer on the stack may not point to the faulting
instruction. To restart program execution at the faulting instruction, the exception handler must
obtain a pointer to the instruction from the saved FPU state information, load it into the return
instruction pointer location on the stack, and then execute the IRET instruction.
In lieu of writing recovery procedures, the exception handler can do the following:
Increment an exception counter for later display or printing.
Print or display diagnostic information (such as, the FPU environment and registers).
Halt further program execution.
Refer to Section E.3.3.4., FPU Exception Handling Examples in Appendix E, Guidelines for
Writing FPU Exceptions Handlers for general examples of floating-point exception handlers
and for specific examples of how to write a floating-point exception handler when using the MS-
DOS compatibility mode.
7.8.FLOATING-POINT EXCEPTION CONDITIONS
The following sections describe the various conditions that cause a floating-point exception to
be generated and the masked response of the FPU when these conditions are detected. Chapter
3, Instruction Set Reference, in the Intel Architecture Software Developers Manual, Volume 2,
lists the floating-point exceptions that can be signaled for each floating-point instruction.
7.8.1.Invalid Operation Exception
The floating-point invalid operation exception occurs in response to two general types of oper-
ations:
Stack overflow or underflow (#IS).
Invalid arithmetic operand (#IA).