OVERVIEW OF NUMERIC PROCESSING
DENORMALIZED OPERAND
If
an instruction attempts to operate
on
a denormal, the
NPX
reports the denormalized operand excep-
tion. This exception allows users to implement in software an option of the proposed
IEEE
standard
specifying that operands must be prenormalized before they are used.
NUMERIC OVERFLOW AND UNDERFLOW
If
the exponent of a numeric result
is
too large for the destination real format, the 80287 signals a
numeric overflow. Conversely, if the exponent of a result
is
too small to be represented in the destina-
tion format, a numeric underflow
is
signaled.
If
either
of
these exceptions occur, the result of the
operation
is
outside the range of the destination real format.
Typical algorithms are most likely to produce extremely large and small numbers in the calculation of
intermediate, rather than final, results. Because of the great range
of
the temporary real format
(recommended
as
the destination format for intermediates), overflow and underflow are relatively rare
events in most
80287 applications.
INEXACT RESULT
If
the result
of
an operation is not exactly representable in the destination format, the 80287 rounds
the number and reports the precision exception. For example, the fraction
113
cannot be precisely repre-
sented in binary form. This exception occurs frequently and indicates
that
some (generally acceptable)
accuracy has been lost; it is provided for applications
that
need to perform exact arithmetic only.
HANDLING NUMERIC ERRORS
When numeric errors occur, the
NPX
takes one of two possible courses of action:
• The
NPX
can itself handle the error, producing the most reasonable result and allowing numeric
program execution to continue undisturbed.
• A software exception handler can be invoked by the
CPU
to handle the error.
Each of the six exception conditions described above has a corresponding flag bit in the
80287 status
word and a mask bit in the
80287 control word.
If
an exception
is
masked (the corresponding mask bit
in the control word = 1), the
80287 takes an appropriate default action and continues with the compu-
tation.
If
the exception
is
unmasked (mask=O), the 80287 asserts the
ERROR
output to the 80286 to
signal the exception and invoke a software exception handler.
The
NPX
reports
ari
exception by setting the corresponding flag in the
NPX
status word to
1.
The
NPX
then checks the corresponding exception mask in the control word to determine
if
it should
"field"
the
exception (mask=
1),
or
if it
sho~it.1
:siguill
the
6x~eptio"
to
the
CPU
to
in~7cke
2.
soft'.l!f!.!e
exception handler (mask=O).
If
the mask
is
set, the exception
is
said to be masked (from user software), and the
NPX
executes its
on-chip masked response for that exception.
If
the mask
is
not set (mask=O), the exception
is
unmasked,
and the
NPX
performs its unmasked response. The masked response always produces a standard result,
then proceeds with the instruction. The unmasked response always traps to a software exception handler,
allowing the
CPU
to recognize and take action
on
the exception. Table
1-17
gives a complete descrip-
tion
of
all exception conditions and the
NPX's
masked response.
1-34