FSTSW Store status word Exceptions: None FNSTSW Store status word, no wait C3 C2 C1 C0: ? ? ? ?
FSTSW destination FNSTSW destination
Logic destination ← status word
FSTSW stores the current value of the status word in destination, a 16-bit memory location, or -- in the 287+ -- the AX register of the 80x86. FSTSW checks for unmasked FP error conditions before storing the status word; FNSTSW does not make this check.
Note FSTSW/FNSTSW are primarily used for conditional branching after a comparison instruction (FPREM, FPREM1, or FXAM). They can also be used to invoke exception handlers (by polling the exception bits) in environments that do not use interrupts.
Example p287 fstsw ax ; read FPU status word sahf ; copy condition codes to flags jc @@c0 ; jc ~ C0, jp ~ C2, jz ~ C3