FSAVE Save FPU state Exceptions: None FNSAVE Save FPU state, no wait C3 C2 C1 C0: 0 0 0 0
FSAVE destination FNSAVE destination
Logic destination ← FPU state
FSAVE/FNSAVE write the FPU state to destination (a 94- or 108-byte memory location), then reinitialize the FPU. FSAVE checks for unmasked FP error conditions before writing the state; FNSAVE does not make this check.
The FPU state includes the environment (14 or 28 bytes) and the register stack, ST(0) thru ST(7) (80 bytes). The environment includes the control word, the status word, the tag word, and an error block (see FSTENV).
FSAVE/FNSAVE are typically used when an operating system needs to perform a context switch, an exception handler needs to use the FPU, or an application program wants to 'clean' the FPU before a subroutine uses it.
Note FSAVE/FNSAVE do not store the FPU state until all FPU activity has finished. To restore a saved state, use the FRSTOR instruction. If a program is to read from the state's memory image following a save instruction, it must issue an FWAIT instruction to ensure that the storage operation is complete.