FXSAVE

Save x87 FPU, MMX Technology, and SSE State

stableVMJITAOTinstruction

Encodings

OpcodeInstructionOp/En64-bitCompat/LegacyDescription
NP 0F AE /0FXSAVE m512byteMValidValidSave the x87 FPU, MMX, XMM, and MXCSR register state to m512byte.
NP REX.W + 0F AE /0FXSAVE64 m512byteMValidNot encodableSave the x87 FPU, MMX, XMM, and MXCSR register state to m512byte.

Operand encoding

Each mode is a value of the Op/En column above. It says which field of the encoded instruction carries each operand, in the order they are written, and whether the instruction reads it, writes it or both.

M

  1. modrm.rm escrituraModRM byte, r/m field (bits 2-0); with the SIB byte and the displacement when the mod field asks for them

Measured cost

Loading measurements from arch-data...

Description

Saves the current state of the x87 FPU, MMX technology, XMM, and MXCSR registers to a 512-byte memory location specified in the destination operand. The content layout of the 512 byte region depends on whether the processor is operating in non-64-bit operating modes or 64-bit sub-mode of IA-32e mode.

Bytes 464:511 are available to software use. The processor does not write to bytes 464:511 of an FXSAVE area.

The operation of FXSAVE in non-64-bit modes is described first.

Non-64-Bit Mode Operation

Table 3-45 shows the layout of the state information in memory when the processor is operating in legacy modes.

Non-64-Bit-Mode Layout of FXSAVE and FXRSTOR Memory Region

1514131211109876543210
RsvdFCSFIP[31:0]FOPRsvdFTWFSWFCW 0

Non-64-Bit-Mode Layout of FXSAVE and FXRSTOR Memory Region (Contd.)

1514131211109876543210
RsvdFCSFIP[31:0]FOPRsvdFTWFSWFCW 0

Recreating FSAVE Format

ExponentExponentFractionJ and MFTWvalidbit
all 1'sall 0'sall 0'sbitsx87 FTW
0000x1Special 10
0001x1Valid 00
001001Special 10
001101Valid 00
0100x1Special 10
0101x1Special 10
011001Zero 01
011101Special 10
1001x1Special 10
1001x1Special 10
101001Special 10
101101Special 10

Layout of the 64-Bit Mode FXSAVE64 Map (Requires REX.W = 1)

1514131211109876543210
FIPFOPReserved FTWFSWFCW0

Layout of the 64-Bit Mode FXSAVE Map (REX.W = 0)

1514131211109876543210
ReservedFCSFIP[31:0]FOPReservedFTWFSWFCW0
MXCSR_MASKMXCSRReservedFDSFDP[31:0]16

Operation

IF 64-Bit Mode
    THEN
          IF REX.W = 1
                THEN
                      DEST := Save64BitPromotedFxsave(x87 FPU, MMX, XMM15-XMM0,
                      MXCSR);
                ELSE
                      DEST := Save64BitDefaultFxsave(x87 FPU, MMX, XMM15-XMM0, MXCSR);
          FI;
    ELSE
          DEST := SaveLegacyFxsave(x87 FPU, MMX, XMM7-XMM0, MXCSR);

FI;

Exceptions

Protected mode
#GP(0)For an illegal memory operand effective address in the CS, DS, ES, FS or GS segments. If a memory operand is not aligned on a 16-byte boundary, regardless of segment. (See the description of the alignment check exception [#AC] below.)
#SS(0)For an illegal address in the SS segment. #PF(fault-code) For a page fault.
#NMIf CR0.TS[bit 3] = 1. If CR0.EM[bit 2] = 1.
#UDIf CPUID.01H:EDX.FXSR[24] = 0.
#UDIf the LOCK prefix is used.
#ACIf this exception is disabled a general protection exception (#GP) is signaled if the memory operand is not aligned on a 16-byte boundary, as described above. If the alignment check exception (#AC) is enabled (and the CPL is 3), signaling of #AC is not guaranteed and may vary with implementation, as follows. In all implementations where #AC is not signaled, a general protection exception is signaled in its place. In addition, the width of the alignment check may also vary with implementation. For instance, for a given implementation, an alignment check exception might be signaled for a 2-byte misalignment, whereas a general protection exception might be signaled for all other misalignments (4-, 8-, or 16-byte misalignments).
Real address mode
#GPIf a memory operand is not aligned on a 16-byte boundary, regardless of segment. If any part of the operand lies outside the effective address space from 0 to FFFFH.
#NMIf CR0.TS[bit 3] = 1. If CR0.EM[bit 2] = 1.
#UDIf CPUID.01H:EDX.FXSR[24] = 0. If the LOCK prefix is used.
Virtual-8086 mode
Same exceptions as in real address mode.
#ACFor unaligned memory reference.
#UDIf the LOCK prefix is used.
Compatibility mode
Same exceptions as in protected mode.
64-bit mode
#SS(0)If a memory address referencing the SS segment is in a non-canonical form.
#GP(0)If the memory address is in a non-canonical form. If memory operand is not aligned on a 16-byte boundary, regardless of segment. #PF(fault-code) For a page fault.
#NMIf CR0.TS[bit 3] = 1. If CR0.EM[bit 2] = 1.
#UDIf CPUID.01H:EDX.FXSR[24] = 0. If the LOCK prefix is used.
#ACIf this exception is disabled a general protection exception (#GP) is signaled if the memory operand is not aligned on a 16-byte boundary, as described above. If the alignment check exception (#AC) is enabled (and the CPL is 3), signaling of #AC is not guaranteed and may vary with implementation, as follows. In all implementations where #AC is not signaled, a general protection exception is signaled in its place. In addition, the width of the alignment check may also vary with implementation. For instance, for a given implementation, an alignment check exception might be signaled for a 2-byte misalignment, whereas a general protection exception might be signaled for all other misalignments (4-, 8-, or 16-byte misalignments). Implementation Note The order in which the processor signals general-protection (#GP) and page-fault (#PF) exceptions when they both occur on an instruction boundary is given in Table 5-2 in the Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3B. This order vary for FXSAVE for different processor implementations.

Sources