9- 26 M68040 USER’S MANUAL MOTOROLA
If a floating-point exception is pending from a previous floating-point instruction, a pre-
instruction exception is taken. After the appropriate exception handler is executed, the
conditional instruction is restarted. When the FPU pipeline is idle (all previous floating-
point instructions have completed) and no exceptions are pending, the processor
evaluates the conditional predicate and checks for a BSUN exception before executing the
22.214.171.124 MASKABLE EXCEPTION CONDITIONS. A BSUN exception occurs if the
conditional predicate is one of the IEEE nonaware branches and the FPCC NAN bit is set.
When the processor detects this condition, it sets the BSUN bit in the FPSR EXC byte.
a. If the user BSUN exception handler is disabled, the floating-point condition is
evaluated as if it were the equivalent IEEE aware conditional predicate. No
exceptions are taken.
b. If the user BSUN exception handler is enabled, the processor takes a floating-point
pre-instruction exception. A $0 stack frame is saved, and vector number 48 is
generated to access the BSUN exception vector. The BSUN entry in the processor’s
vector table points to the M68040FPSP BSUN exception handler.
For MC68881/MC68882 compatibility, the M68040FPSP updates the FPIAR by copying
the PC value in the pre-instruction stack frame to the FPIAR. The M68040FPSP BSUN
exception handler restores the FPU to its exceptional state, cleans up the stack to the
state prior to the M68040FPSP BSUN exception handler’s execution, and continues
instruction execution at the user BSUN exception handler. No parameters are passed to
the user BSUN exception handler since the M68040FPSP BSUN exception handler
provides the illusion that it never existed.
The user BSUN exception handler must execute an FSAVE as its first floating-point
instruction. FSAVE allows other floating-point instructions to execute without reporting the
BSUN exception again, although none of the state frame values are useful in the
execution of the user BSUN exception handler. The BSUN exception is unique in that the
exception is taken before the conditional predicate is evaluated. If the user BSUN
exception handler does not set the PC to the instruction following the one that caused
BSUN exception when returning, the exception is executed again. Therefore, it is the
responsibility of the user BSUN exception handler to prevent the conditional instruction
from taking the BSUN exception again. There are four ways to prevent taking the
1. Incrementing the stored PC in the stack bypasses the conditional instruction. This
technique applies to situations where a fall-through is desired. Note that accurate
calculation of the PC increment requires detailed knowledge of the size of the
conditional instruction being bypassed.
2. Clearing the NAN bit prevents the exception from being taken again. However, this
alone cannot deterministically control the result’s indication (true or false) that would
be returned when the conditional instruction reexecutes.
3. Disabling the BSUN bit also prevents the exception from being taken again. Like the
second method, this method cannot control the result indication (true or false) that
would be returned when the conditional instruction reexecutes.