Chapter 4. Floating-Point Unit (FPU)
For More Information On This Product,
Go to: www.freescale.com
4-27
FPU Programmer’s Model
When FSAVE executes, the floating-point frame reflects the FPU state at the time of the
FSAVE. Internally, the FPU can be in the NULL, IDLE, or EXCP states. Upon reset, the
FPU is in NULL state, in which all floating-point registers contain NANs and the FPCR,
FPSR, and FPIAR contain zeros. The FPU remains in NULL state until execution of an
implemented floating-point instruction (except FSAVE). At this point, the FPU transitions
from NULL to an IDLE state. A FRESTORE of NULL returns the FPU to NULL state.
EXCP state is entered as a result of a floating-point exception or an unsupported data type
exception. The vector field identifies exception types associated with the EXCP state. This
field and the exception vector taken are determined directly from the exception control
(FPCR) and status (FPSR) bits. An FSAVE instruction always clears FPCR after saving its
state. Thus, after an FSAVE, a handler does not generate further floating-point exceptions
unless the handler re-enables the exceptions. FRESTORE returns FPCR and FPSR to their
previous state before entering the handler, as stored in the state frame. A handler could
alter the state frame to restore the FPU (using FRESTORE) into a different state than that
saved by using FSAVE.
Normally, an exception handler executes FSAVE, processes the exception, clears the
exception bit in the FSAVE state frame status word, and executes FRESTORE. If
appropriate exception bits set in the status word are not cleared, the same exception is
taken again. If multiple exception bits are set in the status word, each should be processed,
cleared, and restored by their respective handlers. In this way, all exceptions are processed
in priority order.
If it is not necessary to handle multiple exceptions, the exception model can be simplified
(after any processing) by the handler manually loading FPCR and FPSR and then
discarding the state frame before executing an RTE. Given that state frames are 4
longwords, it may be quicker to discard the state frame by incrementing the address
pointer (often the system stack pointer, A7) by 16.
Table 4-22. Format Word Field Descriptions
Bits
Name
Description
31–24
Frame format
Defines the format of the frame.
0x00 Null Frame (NULL)
0x05 Idle Frame (IDLE)
0xE5 Exception Frame (EXCP)
23–19
—
Zeros
18–16
Vector
Exception vector
000 BSUN
001 INEX
010 DZ
011 UNFL
100 OPERR
101 OVFL
110 INAN
111 IDE
F
Freescale Semiconductor, Inc.
n
.