Intel 80286 Computer Accessories User Manual


 
inter
OVERVIEW OF NUMERIC PROCESSING
Automatic Exception Handling
As
described in the previous section, when the 80287
NPX
encounters an exception condition whose
corresponding mask bit in the
NPX
control word
is
set, the
NPX
automatically performs an internal
fix-up (masked-exception) response. The
80287
NPX
has a default fix-up activity for every possible
exception condition it may encounter
..
These
masked~exception
responses are designed to be safe and
are generally acceptable for most numeric applications.
As
an example of how even severe exceptions can be handled safely and automatically using the NPX's
default exception responses, consider a calculation of the parallel resistance of several values using
only the standard formula (figure
I-II).
If
Rl
becomes zero, the circuit resistance becomes zero. With
the divide-by-zero and precision exceptions masked, the
80287
NPX
will produce the correct result.
By
masking or unmasking specific numeric exceptions in the
NPX
control word,
NPX
programmers
can delegate responsibility for most exceptions to the NPX, reserving the most severe exceptions for
programmed exception handlers. Exception-handling software
is
often difficult to write, and the NPX's
masked responses have been tailored to deliver the most reasonable result for each condition. For the
majority of applications, programmers will find that masking all exceptions other than Invalid Opera-
tion will yield satisfaotory results with the least programming effort. An Invalid Operation exception
normally indicates
afatal
error in a program that must
b~
corrected; this exception should not normally
be.masked.
The exception flags in the
NPX
status word provide a cumulative record of exceptions that have occurred
since these flags were last cleared.
Once set, these flags can be cleared only by executing the FCLEX
(clear exceptions) instruction, by reinitializing the NPX, or
by
overwriting the flags with an
FRSTOR
or·
FLDENV instruction. This allows a programmer to mask all exceptions (except invalid operation),
run a calculation, and then inspect the status word to see
if
any exceptions were detected at any point
in the calculation.
.
R3
EQUIVALENT RESISTANCE -
1
G30108
Figure 1-11. Arithmetic Example Using Infinity
1-37