7-52
FLOATING-POINT UNIT
The flag for this exception (IE) is bit 0 of the FPU status word, and the mask bit (IM) is bit 0 of
the FPU control word. The stack fault flag (SF) of the FPU status word indicates the type of
operation caused the exception. When the SF flag is set to 1, a stack operation has resulted in
stack overflow or underflow; when the flag is cleared to 0, an arithmetic instruction has encoun-
tered an invalid operand. Note that the FPU explicitly sets the SF flag when it detects a stack
overflow or underflow condition, but it does not explicitly clear the flag when it detects an
invalid-arithmetic-operand condition. As a result, the state of the SF flag can be 1 following an
invalid-arithmetic-operation exception, if it was not cleared from the last time a stack overflow
or underflow condition occurred. Refer to Section 7.3.2.4., Stack Fault Flag, for more infor-
mation about the SF flag.
7.8.1.1.STACK OVERFLOW OR UNDERFLOW EXCEPTION (#IS)
The FPU tag word keeps track of the contents of the registers in the FPU register stack (refer to
Section 7.3.6., FPU Tag Word). It then uses this information to detect two different types of
stack faults:
Stack overflowan instruction attempts to write a value into a non-empty FPU register
Stack underflowan instruction attempts to read a value from an empty FPU register.
When the FPU detects stack overflow or underflow, it sets the IE flag (bit 0) and the SF flag (bit
6) in the FPU status word to 1. It then sets condition-code flag C1 (bit 9) in the FPU status word
to 1 if stack overflow occurred or to 0 if stack underflow occurred.
If the invalid operation exception is masked, the FPU then returns the real, integer, or BCD-
integer indefinite value to the destination operand, depending on the instruction being executed.
This value overwrites the destination register or memory location specified by the instruction.
If the invalid operation exception is not masked, a software exception handler is invoked (refer
to Section 7.7.3., Software Exception Handling) and the top-of-stack pointer (TOP) and
source operands remain unchanged.
The term stack overflow comes from the condition where the a program has pushed eight values
onto the FPU register stack and the next value pushed on the stack causes a stack wraparound
to a register that already contains a value. The term stack underflow refers to the opposite condi-
tion from stack overflow. Here, a program has popped eight values from the FPU register stack
and the next value popped from the stack causes stack wraparound to an empty register.
7.8.1.2.INVALID ARITHMETIC OPERAND EXCEPTION (#IA)
The FPU is able to detect a variety of invalid arithmetic operations that can be coded in a
program. These operations generally indicate a programming error, such as dividing
?
by
?
.
Table 7-21 lists the invalid arithmetic operations that the FPU detects. This group includes the
invalid operations defined in IEEE Standard 854.
When the FPU detects an invalid arithmetic operand, it sets the IE flag (bit 0) in the FPU status
word to 1. If the invalid operation exception is masked, the FPU then returns an indefinite value
to the destination operand or sets the floating-point condition codes, as shown in Table 7-21. If
the invalid operation exception is not masked, a software exception handler is invoked (refer to