AMD amd64 architecture User Manual

Page of 336
64-Bit Media Programming
223
24592—Rev. 3.15—November 2009
AMD64 Technology
5.6.10 Save and Restore State
These instructions save and restore the processor state for 64-bit media instructions.
Save and Restore 64-Bit Media and x87 State
FSAVE—Save x87 and MMX State
FNSAVE—Save No-Wait x87 and MMX State
FRSTOR—Restore x87 and MMX State
These instructions save and restore the entire processor state for x87 floating-point instructions and
64-bit media instructions. The instructions save and restore either 94 or 108 bytes of data, depending
on the effective operand size.
Assemblers issue FSAVE as an FWAIT instruction followed by an FNSAVE instruction. Thus, FSAVE
(but not FNSAVE) reports pending unmasked x87 floating-point exceptions before saving the state.
After saving the state, the processor initializes the x87 state by performing the equivalent of an FINIT
instruction.
Save and Restore 128-Bit, 64-Bit, and x87 State
FXSAVE—Save XMM, MMX, and x87 State
FXRSTOR—Restore XMM, MMX, and x87 State
The FXSAVE and FXRSTOR instructions save and restore the entire 512-byte processor state for 128-
bit media instructions, 64-bit media instructions, and x87 floating-point instructions. The architecture
supports two memory formats for FXSAVE and FXRSTOR, a 512-byte 32-bit legacy format and a
512-byte 64-bit format. Selection of the 32-bit or 64-bit format is determined by the effective operand
size for the FXSAVE and FXRSTOR instructions. For details, see “FXSAVE and FXRSTORInstructions” in Volume 2.
FXSAVE and FXRSTOR execute faster than FSAVE/FNSAVE and FRSTOR. However, unlike
FSAVE and FNSAVE, FXSAVE does not initialize the x87 state, and like FNSAVE it does not report
pending unmasked x87 floating-point exceptions. For details, see “Saving and Restoring State” on
page 234.
5.7
Instruction Summary—Floating-Point Instructions
This section summarizes the functions of the floating-point (3DNow! and a few SSE and SSE2)
instructions in the 64-bit media instruction subset. These include floating-point instructions that use an
MMX register for source or destination and data-conversion instructions that convert from floating-
point to integers formats. For a summary of the integer instructions in the 64-bit media instruction
subset, including data-conversion instructions that convert from integer to floating-point formats, see
“Instruction Summary—Integer Instructions” on page 207.