SYSTEM-LEVEL NUMERIC PROGRAMMING
8086/87/88/186
MACRO
ASSEMBLER
Test
for
presence
of
a
NUIIOr;cs
Chip. Rev;slon
1.0
PAGE
LOC
OBJ
0039
EB0790
D03C
003C
EB0490
003F
003F
EB0190
004Z
D04Z
LINE
60
61
6Z
63
64
65
66
67
68
69
70
71
7Z
73
74
75
76
77
78
79
80
81
ASSEHBL
Y
COMPLETE,
NO
ERRORS
FOUND
SOURCE
An
80387
Is
present.
If
denormol e.cepttons are
used
for
an
8087/Z87,
they
"",t
be
mosked.
Th.
80387
will
automatically
normalize denormol
operands
faster
than
an
exception handler can.
j""
founct387
set
up
for
no
NPX
j""
e.tt
found_87
_Z87:
.et
up
for
87/Z87
j""
exit
found 387:
- set up
for
387
,
••
tt.
code
end.
end
start,ds.:dgroup,
••
:dgroup:8at
Figure 3-1. Software Routine to Recognize the
80287
(Cont'd.)
Configuring
the
Numerics
Environment
Once the 80286 CPU has determined the presence or absence of the 80287 NPX, the 80286 must set
either the
MP or the
EM
bit
in
its
own
machine status word accordingly. The initialization routine can
either
• Set the
MP
bit
in
the 80286 MSW to allow numeric instructions to be executed directly by the
80287
NPX
component
• Set the EM bit
in
the 80286 MSW to permit software emulation of the 80287 numeric instructions
The Math Present (MP) flag of the 80286 machine status word indicates to the CPU whether an 80287
NPX
is
physically avaiiabie
in
the system. The
MP
flag controls the function of the WAIT instruction.
When executing
aWAIT
instruction, the 80286 tests only the Task Switched (TS) bit if MP
is
set; if
it finds
TS set under these conditions, the 'CPU traps to exception
#7.
The Emulation Mode (EM) bit of the 80286 machine status word indicates to the CPU whether
NPX
functions are to be emulated.
If
the CPU finds
EM
set when it executes an ESC instruction, program
control
is
automatically trapped to exception #7, giving the exception handler the opportunity to emulate
the functions of an
80287.
The
80286 EM flag can be changed only by using the LMSW (load machine
status word) instruction (legal only at privilege ievei
0) ami examiut;d with the aid of
th~
SMSW
(~t0re
machine status word) instruction (legal
at
any privilege level).
The EM bit also controls the function of the WAIT instruction.
If
the CPU finds EM set while
~xecut
ing a WAIT, the CPU does not check the
ERROR
pin for an error indication.
For correct
80286 operation, the
EM
bit must never be set concurrently with MP. The EM and MP
bits of the 80286 are described in more detail
in
the 80286 Operating System Writer's Guide. More
3-4