User Guide

64-Bit Media Programming 233
24592—Rev. 3.15—November 2009 AMD64 Technology
When the processor executes an FSAVE or FNSAVE (but not FXSAVE) instruction, it changes the
internal 1-bit tag state to its 2-bit architectural tag by reading the data in all 80 bits of the physical data
registers and using the mapping in Table 5-6. For example, if the value in the high 16 bits of the 80-bit
physical register indicate a NaN, the two tag bits for that register are changed to a binary value of 10
before the x87 status word is written to memory.
The tag bits have no effect on the execution of 64-bit media instructions or their interpretation of the
contents of the MMX registers. However, the converse is not true: execution of 64-bit media
instructions that write to an MMX register alter the tag bits and thus may affect execution of
subsequent x87 floating-point instructions.
For a more detailed description of the mapping shown in Table 5-6, see “Deriving FSAVE Tag Field
from FXSAVE Tag Field” in Volume 2 and its accompanying text.
5.13 Mixing Media Code with x87 Code
5.13.1 Mixing Code
Software may freely mix 64-bit media instructions (integer or floating-point) with 128-bit media
instructions (integer or floating-point) a nd general-purpose instructions in a single procedure.
However, before transitioning from a 64-bit media procedure—or a 128-bit media procedure that
accesses an MMX™ register—to an x87 procedure, or to software that may eventually branch to an
x87 procedure, software should clear the MMX state, as described immediately below.
5.13.2 Clearing MMX™ State
Software should separate 64-bit media procedures, 128-bit media procedures, or dynamic link libraries
(DLLs) that access MMX registers from x87 floating-point procedures or DLLs by clearing the MMX
state with the EMMS or FEMMS instruction before leaving a 64-bit media procedure, as described in
“Exit Media State” on page 209.
Table 5-6. Mapping Between Internal and Software-Visible Tag Bits
Architectural State
Internal State
1
State Binary Value
Valid 00
Full (0)
Zero 01
Special
(NaN, infinity, denormal)
2
10
Empty 11 Empty (1)
Note:
1. For a more detailed description of this mapping, see “Deriving FSAVE Tag Field
from FXSAVE Tag Field” in Volume 2.
2. The 64-bit media floating point (3DNow!™) instructions do not support NaNs, infin-
ities, and denormals.