If the application contains floating-point and MMX instructions, follow these guidelines:
Partition the MMX technology module and the floating-point module into separate
instruction streams (separate loops or subroutines) so that they contain only instructions of
one type.
Do not rely on register contents across transitions.
When the MMX state is not required, empty the MMX state using the EMMS
instruction.
Exit the floating-point code section with an empty stack.
Example 8-2. Floating-point (FP) and MMX Code
FP_code:
..
.. (*leave the FPU stack empty*)
MMX_code:
..
EMMS (*mark the FPU tag word as empty*)
FP_code 1:
..
.. (*leave the FPU stack empty*)
8.5.5.Using MMX Code in a Multitasking Operating System
Environment
An application needs to identify the nature of the multitasking operating system on which it
runs. Each task retains its own state which must be saved when a task switch occurs. The
processor state (context) consists of the general-purpose registers and the floating-point and
MMX registers.
Operating systems can be classified into two types:
Cooperative multitasking operating system.
Preemptive multitasking operating system.
The behavior of the two operating-system types in context switching is described in Section
10.4., Designing Operating System Task and Context Switching Facilities in Chapter 10,
MMX Technology System Programming, of the Intel Architecture Software Developers
Manual, Volume 3.