Intel 64 and IA-32 Architectures Software Developers Manual Volume 1, Basic Architecture
Vol. 1 9-11
PROGRAMMING WITH INTEL® MMX™ TECHNOLOGY
9.5.1 MMX Instructions and the x87 FPU Tag Word
After each MMX instruction, the entire x87 FPU tag word is set to valid (00B). The
EMMS instruction (empty MMX state) sets the entire x87 FPU tag word to empty
(11B).
Chapter 11, “Intel® MMX™ Technology System Programming,” in the Intel® 64 and
IA-32 Architectures Software Developer’s Manual, Volume 3A, provides additional
information about the effects of x87 FPU and MMX instructions on the x87 FPU tag
word. For a description of the tag word, see Section 8.1.7, “x87 FPU Tag Word.”
9.6 WRITING APPLICATIONS WITH MMX CODE
The following sections give guidelines for writing application code that uses MMX
technology.
9.6.1 Checking for MMX Technology Support
Before an application attempts to use the MMX technology, it should check that it is
present on the processor. Check by following these steps:
1. Check that the processor supports the CPUID instruction by attempting to
execute the CPUID instruction. If the processor does not support the CPUID
instruction, this will generate an invalid-opcode exception (#UD).
2. Check that the processor supports the MMX technology
(if CPUID.01H:EDX.MMX[bit 23] = 1).
3. Check that emulation of the x87 FPU is disabled (if CR0.EM[bit 2] = 0).
If the processor attempts to execute an unsupported MMX instruction or attempts to
execute an MMX instruction with CR0.EM[bit 2] set, this generates an invalid-opcode
exception (#UD).
Example 9-1 illustrates how to use the CPUID instruction to detect the MMX tech-
nology. This example does not represent the entire CPUID sequence, but shows the
portion used for detection of MMX technology.
Example 9-1. Partial Routine for Detecting MMX Technology with the CPUID Instruction
... ; identify existence of CPUID instruction
... ; identify Intel processor
mov EAX, 1 ; request for feature flags
CPUID ; 0FH, 0A2H CPUID instruction
test EDX, 00800000H ; Is IA MMX technology bit (Bit 23 of EDX) set?
jnz ; MMX_Technology_Found