News:

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

Saving FPU registers: fxam, tag word etc

Started by jj2007, June 27, 2009, 10:34:51 PM

Previous topic - Next topic

raymond

Quotein case other parts of the code have put valid entries inside

If that code is entirely yours, I still maintain that you should be aware if those other parts have left valid data. To be more precise, good programming would dictate that those other parts should never leave valid data if there is any possibility that it could be trashed by any other part of your code.
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

jj2007

Quote from: raymond on June 29, 2009, 04:37:46 PM
Quotein case other parts of the code have put valid entries inside

If that code is entirely yours, I still maintain that you should be aware if those other parts have left valid data. To be more precise, good programming would dictate that those other parts should never leave valid data if there is any possibility that it could be trashed by any other part of your code.

It boils down to the same behaviour as the Masm32 FloatToStr routine: ST5-ST7 will be trashed by float$ - if they are really needed, it's up to the calling routine to save and restore them. Checking inside float$ is a waste of 100+ cycles...

raymond

Quoteit's up to the calling routine to save and restore them. Checking inside float$ is a waste of 100+ cycles..

I support that 100%+ :clap: :clap:
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

jj2007

Quote from: raymond on June 29, 2009, 05:40:18 PM
Quoteit's up to the calling routine to save and restore them. Checking inside float$ is a waste of 100+ cycles..

I support that 100%+ :clap: :clap:

Thanks, Raymond :bg

Although JimG also has a point here:

Quote from: Jimg on June 29, 2009, 12:50:17 AM
As a general purpose routine, I'm assuming the user might want to print out any fpu register for debugging purposes, and would be upset if anything about the fpu changed.

My current version of float$ will only trash the last two regs, ST6 and ST7 - I guess 99% of all code does not use them. It is a factor 3 faster than the Masm32 FloatToStr, but I am still fighting with a tiny little bug. We'll see :P