finit
Initialize FPU
FINIT
Resets FPU to default state.
Details
Initializes the x87 FPU to its default state, clearing the stack, setting control word to 0x037F (round to nearest, all exceptions masked), and clearing all status flags and exception flags. The instruction is preceded by FWAIT (0x9B) to ensure any pending FPU operations complete before reinitializing. This causes full FPU state reset with no impact on integer registers or EFLAGS.
Pseudocode Operation
FPU_Control_Word ← 0x037F;
FPU_Status_Word ← 0x0000;
FPU_Tag_Word ← 0xFFFF;
for (i = 0; i < 8; i++) ST(i) ← 0.0;
FPU_Exception_Flags ← 0;
Example
FINIT
Encoding
Binary Layout
9B
+0
DB
+1
E3
+2
Operands
Reference (Intel® SDM)
Instruction Forms
| Opcode | Instruction | Op/En | 64/32-bit Mode | CPUID | Description |
|---|---|---|---|---|---|
| 9B DB E3 | FINIT | Valid Valid | Initialize FPU after checking for pending unmasked floating-point exceptions. | ||
| DB E3 | FNINIT1 | Valid Valid | Initialize FPU without checking for pending unmasked floating-point exceptions. |
Description
Sets the FPU control, status, tag, instruction pointer, and data pointer registers to their default states. The FPU control word is set to 037FH (round to nearest, all exceptions masked, 64-bit precision). The status word is cleared (no exception flags set, TOP is set to 0). The data registers in the register stack are left unchanged, but they are all tagged as empty (11B). Both the instruction and data pointers are cleared.
The FINIT instruction checks for and handles any pending unmasked floating-point exceptions before performing the initialization; the FNINIT instruction does not.
The assembler issues two instructions for the FINIT instruction (an FWAIT instruction followed by an FNINIT instruction), and the processor executes each of these instructions in separately. If an exception is generated for either of these instructions, the save EIP points to the instruction that caused the exception.
This instruction’s operation is the same in non-64-bit modes and 64-bit mode.
IA-32 Architecture Compatibility
When operating a Pentium or Intel486 processor in MS-DOS compatibility mode, it is possible (under unusual circumstances) for an FNINIT instruction to be interrupted prior to being executed to handle a pending FPU exception. See the section titled “No-Wait FPU Instructions Can Get FPU Interrupt in Window” in Appendix D of the Intel®
64 and IA-32 Architectures Software Developer’s Manual, Volume 1, for a description of these circumstances. An
FNINIT instruction cannot be interrupted in this way on later Intel processors, except for the Intel QuarkTM X1000 processor.
In the Intel387 math coprocessor, the FINIT/FNINIT instruction does not clear the instruction and data pointers.
This instruction affects only the x87 FPU. It does not affect the XMM and MXCSR registers.
Operation
FPUControlWord := 037FH; FPUStatusWord := 0; FPUTagWord := FFFFH; FPUDataPointer := 0; FPUInstructionPointer := 0; FPULastInstructionOpcode := 0;
Exceptions
Protected Mode Exceptions
#NM CR0.EM[bit 2] or CR0.TS[bit 3] = 1.
#MF If there is a pending x87 FPU exception.
#UD If the LOCK prefix is used.
Real-Address Mode Exceptions
Same exceptions as in protected mode.
Virtual-8086 Mode Exceptions
Same exceptions as in protected mode.
Compatibility Mode Exceptions
Same exceptions as in protected mode.
64-Bit Mode Exceptions
Same exceptions as in protected mode.
FINIT/FNINIT—Initialize Floating-Point Unit Vol. 2A 3-346