News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Would it be a bad thing...

Started by RedXVII, March 25, 2006, 01:01:34 AM

Previous topic - Next topic

RedXVII

If i "accidently" left floats on the FPU? What would be the consequences?

If i called a function, pushed a value on the stack, and then returned; would it still be there?

Thx  :U

raymond

QuoteIf i "accidently" left floats on the FPU? What would be the consequences?

Effectively NONE if you don't use the FPU for anything else.
Effectively NONE if you always reinitialize the FPU before using it.
Otherwise, you will eventually get trash results if you "accidently" leave too many FPU registers with data in them.

QuoteIf i called a function, pushed a value on the stack, and then returned; would it still be there?

(I have to assume that you mean loading one of the FPU registers with some data.)

If the called function is one which you have written yourself, the condition of the FPU registers will remain the same as you left them before returning from the function.

Whenever you call external functions which you have not written yourself, there is always a risk that the content of the FPU could get affected. For example, some of the functions under WinXP are known to use MMX instructions (even for adding 2+2) which will trash FPU registers.

Raymond
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

Tedd

Floating point return values are normally left on st(0) for the 'return' value - so this is fine.
If only you are using the fpu (ie. one thread within your program), you can leave it in whatever state you choose. When your process exits, it will take this state with it (ie. it won't effect any others.)

[Disclaimer: all of the above is wrong if MMX is involved :bdg]
No snowflake in an avalanche feels responsible.