E-27
GUIDELINES FOR WRITING FPU EXCEPTIONS HANDLERS
E.4.2.Changes with Intel486, Pentium
®
, and P6 Family
Processors with CR0.NE=1
With these latest three generations of the IA, more enhancements and speedup features have
been added to the corresponding FPUs. Also, the FPU is now built into the same chip as the pro-
cessor, which allows further increases in the speed at which the FPU can operate as part of the
integrated system. This also means that the native mode of FPU exception handling, selected by
setting bit NE of register CR0 to 1, is now entirely internal.
If an unmasked exception occurs during an FPU instruction, the FPU records the exception in-
ternally, and triggers the exception handler through interrupt 16 immediately before execution
of the next WAIT or FPU instruction (except for no-wait instructions, which will be executed as
described in Section E.4.1., Origin with the Intel 286 and Intel 287, and Intel386 and Intel
387 Processors).
An unmasked numerical exception causes the FERR# output to be activated even with NE=1,
and at exactly the same point in the program flow as it would have been asserted if NE were
zero. However, the system would not connect FERR# to a PIC to generate INTR when operating
in the native, internal mode. (If the hardware of a system has FERR# connected to trigger IRQ13
in order to support MS-DOS, but an O/S using the native mode is actually running the system,
it is the O/Ss responsibility to make sure that IRQ13 is not enabled in the slave PIC.) With this
configuration a system is immune to the problem discussed in Section E.2.1.3., No-Wait FPU
Instructions Can Get FPU Interrupt in Window, where for Intel486 and Pentium
®
processors
a no-wait FPU instruction can get an FPU exception.
E.4.3.Considerations When FPU Shared Between Tasks Using
Native Mode
The protocols recommended in Section E.3.5., Considerations When FPU Shared Between
Tasks for MS-DOS compatibility FPU exception handlers that are shared between tasks may
be used without change with the native mode. However, the protocols for a handler written spe-
cifically for native mode can be simplified, because the problem of a spurious floating-point ex-
ception interrupt occurring while the kernel is executing cannot happen in native mode.
The problem as actually found in practical code in a MS-DOS compatibility system happens
when the DNA handler uses FNSAVE to switch FPU contexts. If an FPU exception is active,
then FNSAVE triggers FERR# briefly, which usually will cause the FPU exception handler to
be invoked inside the DNA handler. In native mode, neither FNSAVE nor any other no-wait in-
structions can trigger interrupt 16. (As discussed above, FERR# gets asserted independent of the
value of the NE bit, but when NE=1, the O/S should not enable its path through the PIC.) An-
other possible (very rare) way a floating-point exception interrupt could occur while the kernel
is executing is by an FPU immediate exception case having its interrupt delayed by the external
hardware until execution has switched to the kernel. This also cannot happen in native mode be-
cause there is no delay through external hardware.
Thus the native mode FPU exception handler can omit the test to see if the kernel is the FPU
owner, and the DNA handler for a native mode system can omit the step of setting the kernel as
the FPU owner at the handlers beginning. Since however these simplifications are minor and