Intel 80286 Computer Accessories User Manual


 
PROGRAMMING NUMERIC APPLICATIONS
F 1ST P
FMUL
Is
updated
before
FMUL
Is
executed
Is
now
safe
to
use
MOV
AX,I
;
Figure 2-10. Documenting Data Synchronization
This
Is
an
ASM286
code
macro
to
redefine
the
FIST
Instruction
to
prevent
any
concurrency
while
the
Instruction
runs.
A
walt
Instruction
Is
placed
Immediately
after
the
escape
to
ensure
the
store
Is
done
before
the
pr09ram
may
continue.
CodeMacro
FIST
memop:
Mw
RflxM
111B,
memop
ModRM
010B,
memop
R W f I x
EndM
FIgure 2-11. Nonconcurrent FIST InstructIon Code Macro
As
an alternative to the
NPX
default fix-up of numeric errors, the 80286 CPU can be notified
whenever an exception occurs. The
CPU can then implement any sort of recovery procedures desired,
for any numeric error detectable
by
the NPX. When a numeric error
is
unmasked
and
the error
occurs, the
NPX stops further execution of the numeric instruction and signals this event to the
CPU. On the next occurrence of an ESC or WAIT instruction, the
CPU
traps
to
a software excep·
tion handler. Some ESC instructions
do
not
check
for
errors. These are the nonwaited
forms
FNINIT,
FNSTENV,
FNSA
VE, FNSTSW, FNSTCW, and FNCLEX.
When
the
NPX
signals an unmasked exception condition, it
is
requesting help. The fact that the error
was
unmasked indicates that further numeric program execution under the arithmetic
and
program·
ming rules of the
NPX
is
unreasonable.
If
concurrent execution
is
allowed, the state of the CPU when it recognizes the exception
is
undefined.
The
CPU may have changed many of its internal registers and be executing a totally different program
by the time the exception occurs. To handle this situation, the
NPX
has special registers updated at
the start of each numeric instruction to describe the state of the numeric program
when
the failed
instruction
was
attempted.
Error synchronization ensures that the
NPX
is
in
a well·defined state after an unmasked numeric error
occurs. Without a well-defined state,
it
would be impossible for exception recovery routines to figure
out
why
the numeric error occurred, or to recover successfully from the error.
2-51