Vol. 3 9-7
PROCESSOR MANAGEMENT AND INITIALIZATION
The EM flag determines whether floating-point instructions are executed by the x87
FPU (EM is cleared) or a device-not-available exception (#NM) is generated for all
floating-point instructions so that an exception handler can emulate the floating-
point operation (EM = 1). Ordinarily, the EM flag is cleared when an x87 FPU or math
coprocessor is present and set if they are not present. If the EM flag is set and no x87
FPU, math coprocessor, or floating-point emulator is present, the processor will hang
when a floating-point instruction is executed.
The MP flag determines whether WAIT/FWAIT instructions react to the setting of the
TS flag. If the MP flag is clear, WAIT/FWAIT instructions ignore the setting of the TS
flag; if the MP flag is set, they will generate a device-not-available exception (#NM)
if the TS flag is set. Generally, the MP flag should be set for processors with an inte
-
grated x87 FPU and clear for processors without an integrated x87 FPU and without a
math coprocessor present. However, an operating system can choose to save the
floating-point context at every context switch, in which case there would be no need
to set the MP bit.
Table 2-1 shows the actions taken for floating-point and WAIT/FWAIT instructions
based on the settings of the EM, MP, and TS flags.
The NE flag determines whether unmasked floating-point exceptions are handled by
generating a floating-point error exception internally (NE is set, native mode) or
through an external interrupt (NE is cleared). In systems where an external interrupt
controller is used to invoke numeric exception handlers (such as MS-DOS-based
systems), the NE bit should be cleared.
9.2.2 Setting the Processor for x87 FPU Software Emulation
Setting the EM flag causes the processor to generate a device-not-available excep-
tion (#NM) and trap to a software exception handler whenever it encounters a
floating-point instruction. (
Table 9-2 shows when it is appropriate to use this flag.)
Setting this flag has two functions:
Table 9-2. Recommended Settings of EM and MP Flags on IA-32 Processors
EM MP NE IA-32 processor
1 0 1 Intel486™ SX, Intel386™ DX, and Intel386™ SX processors
only, without the presence of a math coprocessor.
0 1 1 or 0
*
Pentium 4, Intel Xeon, P6 family, Pentium, Intel486™ DX, and
Intel 487 SX processors, and Intel386 DX and Intel386 SX
processors when a companion math coprocessor is present.
0 1 1 or 0
*
More recent Intel 64 or IA-32 processors
NOTE:
* The setting of the NE flag depends on the operating system being used.