User Guide

x87 Floating-Point Programming 241
24592—Rev. 3.15—November 2009 AMD64 Technology
not empty (as indicated by the register’s tag bits). To prevent overflow, the FXCH (floating-point
exchange) instruction can be used to access stack registers, giving the appearance of a flat register file,
but all x87 programs must be aware of the register file’s stack organization.
The FINCSTP and FDECSTP instructions can be used to increment and decrement, respectively, the
TOP, modulo-8, allowing the stack top to wrap around to the bottom of the eight-register file when
incremented beyond the top of the file, or to wrap around to the top of the register file when
decremented beyond the bottom of the file. Neither the x87 tag word nor the contents of the floating-
point stack itself is updated when these instructions are used.
6.2.2 x87 Status Word Register (FSW)
The 16-bit x87 status word register contains information about the state of the floating-point unit,
including the top-of-stack pointer (TOP), four condition-code bits, exception-summary flag, stack-
fault flag, and six x87 floating-point exception flags. Figure 6-3 on page 242 shows the format of this
register. All bits can be read and written, however values written to the B and ES bits (bits 15 and 7) are
ignored.
The FRSTOR and FXRSTOR instructions load the status word from memory. The FSTSW, FNSTSW,
FSAVE, FNSAVE, FXSAVE, FSTENV, and FNSTENV instructions store the status word to memory.
The FCLEX and FNCLEX instructions clear the exception flags. The FINIT and FNINIT instructions
clear all bits in the status-word.