AMD amd64 architecture User Manual

Page of 336
276
x87 Floating-Point Programming
AMD64 Technology
24592—Rev. 3.15—November 2009
Save and Restore x87 and 64-Bit Media 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. For details, see “State-Saving” on page 290.
Save and Restore x87, 128-Bit, and 64-Bit 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 “Media and x87 Processor State” inVolume 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 “State-Saving” on page 290.
6.5
Instruction Effects on rFLAGS
The rFLAGS register is described in “Flags Register” on page 33. Table 6-16 on page 277 summarizes
the effect that x87 floating-point instructions have on individual flags within the rFLAGS register.
Only instructions that access the rFLAGS register are shown—all other x87 instructions have no effect
on rFLAGS.
The following codes are used within the table:
Mod—The flag is modified.
Tst—The flag is tested.
Gray shaded cells indicate the flag is not affected by the instruction.