Do we really have to use this instruction nowadays?
It's only used in the days when the FPU and processor EDIT:CPU were separate units right?
Posted on 2003-06-24 19:53:45 by david
Well, you could use FNINIT instead, and not execute the FWAIT intrinsic before the instruction. This has problems on a 486 in DOS mode though.
Posted on 2003-06-24 21:01:19 by donkey
So...on pentium and above no need for this opcode?
( I can ignore it? )
Posted on 2003-06-25 05:59:06 by david
Yes, you can

From agner.hlp, chapter 26

The assembler automatically inserts a WAIT for this purpose before the following instructions: FCLEX, FINIT, FSAVE, FSTCW, FSTENV, FSTSW. You can omit the WAIT by writing FNCLEX, etc. My tests show that the WAIT is unneccessary in most cases because these instructions without WAIT will still generate an interrupt on exceptions except for FNCLEX and FNINIT on the 80387. (There is some inconsistency about whether the IRET from the interrupt points to the FN.. instruction or to the next instruction).
Posted on 2003-06-25 06:47:06 by greenant
good. thanks. :)
Posted on 2003-06-25 07:25:58 by david

So...on pentium and above no need for this opcode?
( I can ignore it? )

No. The FPU requires finit. However, as long as your target OS is not DOS, you can ignore it. The OS is supposed to handle it for you, be it Windows, Unix or linux.

In fact, a sane OS issues finit at the OS init time, and then, uses f(n)save/frstor combination to provide appropriate environment for an app. So, as a programmer, you don't have to worry about finit unless you are building your own OS.
Posted on 2003-06-25 17:45:06 by Starless
That was enlightening info. thanks!
Posted on 2003-06-25 18:07:29 by david
I agree you may not need finit unless you make heavy use of the FPU. If you have several procedures using it, any leftover data in the data registers could rapidly fill up the very limited number of registers and render all calculations useless.

It's just a simple precaution to initialize the FPU within each procedure to ensure you have a clean system to work with. And it is even more important if you also use MMX/SSE instructions.

Raymond
Posted on 2003-06-25 23:20:22 by Raymond