News:

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

FPU Question (Only Raymond types need apply)

Started by RotateRight, August 02, 2006, 08:07:28 PM

Previous topic - Next topic

RotateRight

I've got several routines using FPU instructions
that work by leaving the needed value at ST(0).

When return is given back to the calling code,
a value is stored (FSTP) and popped to a memory
location.  So far so good. It's working.

However there are times that the calling code
would like to ignore this return value on the
FPU stack.

So my question is how can I clear ST(0) so that
the next round of calculations has "a clean slate"?

Do I just use FSTP to somewhere and ignore it?

Do I use FINIT (doesn't seem right).

And then there is FFREE.  Raymond explained it
well in the documentation that a good place to
use it is when you have a full stack and need
the place at ST(7).  All I am concerned with here
is ST(0).

Other methods?

Comments from the masses accepted,

Mark

dsouza123

If the state of the FPU queue is acceptable when the value left in ST(0) is stored then popped by using FSTP then
just always do that and just ignore the value when it isn't needed.

raymond

fstp st

Copies to itself and than pops without any need for memory usage. Fast and efficient.

Look at the last example given in the description of the fstp instruction in the FPU tutorial:

http://www.ray.masmcode.com/tutorial/fpuchap4.htm#fstp

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

RotateRight

dsouza123 / Raymond,

Thanks for the help.  Looks like fstp it is.

Quote- when the value in ST(0) has become useless and the register needs to be liberated.

fstp st     ;copied upon itself and popped