News:

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

FpuFLtoA

Started by agathon, April 20, 2005, 08:47:15 AM

Previous topic - Next topic

agathon

Hi,

Alternate invocations of this procedure with known good data fail as though the data were bad.

What's up?

Cordially,
Agathon

Ghirai

I've been having some problems too, can't say if it's FpuFLtoA or my coding, though fpu registers showm by olly seem ok  ::)
MASM32 Project/RadASM mirror - http://ghirai.com/hutch/mmi.html

raymond

Would both of you be kind enough to indicate which version of the Fpulib you are using (as indicated in the Help file), and also show some of the snippets where you are invoking that function.

Some of the modifications in the latest version 2.1 were made to prevent some of the potential shortcomings of previous versions. My goal is to make those library functions as "idiot-proof" as possible but I do need specific feedback. And please don't take that "idiot-proof" expression in any personal way. :naughty: It's just the "ultimate" goal. :wink

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

agathon

Hi,

Thank you for the response.

Where is the help file hidden?

Where can one find the most recent version of fpulib?

The header of the procedure says that it was written in December, 2002.

display_flt proc value:QWORD, handle:DWORD

    fld value
    invoke FpuFLtoA,NULL,4,ADDR outStr,SRC1_FPU
    invoke SetWindowText, handle, ADDR outStr
    ret

display_flt endp

If outStr is preset to some known string, the string is unchanged on even numbered invocations of this procedure.

Thanks for your assistance.
RWM

Ghirai

I'm using 2.0.

Here's my code:

fild mlen
fild flen
fsubp st(1),st
fild bHun ;this is 100
fmulp st(1),st
fild mlen
fdivp st(1),st

fwait
invoke FpuFLtoA,0,2,addr Buf,SRC1_FPU or SRC2_DIMM
fstp st


Very simple, just calculates a procentage.

Now, i have this in a loop, that gets called when i push a button.
The first time the procedure that contains the loop is called it works great.
But after that, it always returns 0.

Oh, i added v2.1 to my mirror site here: http://ghirai.com/hutch/mmi.html
Let me know if it's ok.
MASM32 Project/RadASM mirror - http://ghirai.com/hutch/mmi.html

agathon

A minor oops - the uID in my code snippet should be SRC1_FPU or SRC2_DIMM. The behavior of the procedure is unaffected by this change.

thomasantony

A tiny question. You used finit? :bdg

Thomas :U :boohoo: :boohoo:
There are 10 types of people in the world. Those who understand binary and those who don't.


Programmer's Directory. Submit for free

Ghirai

Quote from: thomasantony on April 21, 2005, 03:55:00 PM
A tiny question. You used finit? :bdg

Thomas :U :boohoo: :boohoo:


Obviously... :P
MASM32 Project/RadASM mirror - http://ghirai.com/hutch/mmi.html

raymond

agathon

You are probably using the original version of the library. You can get the latest version from the following site which I maintain personally.

http://www.ray.masmcode.com/fpu.html#fpulib

If you are using MASM32, be sure to copy the .lib and .inc files to their respective LIB and INCLUDE folders. You should normally find the Help file wherever you unzip the package along with the above files and the source code for the modules.

Having no knowledge of the remainder of your code, try inserting the following instruction immediately before the "fld value" instruction:

ffree st(7)

That will guarantee that the "value" will be properly loaded by the FPU. And to prevent problems elsewhere in your program, add the following instruction after you invoke the FpuFLtoA:

fstp st

Let me know if you still have problems.


Ghirai

Your snippet seems to indicate that you are managing the "occupancy" of the FPU registers with the "fstp st" instruction after invoking the FpuFLtoA function. I cannot assume at this point that you are doing the same in other parts of your program.

If you are not "storing" any other values on the FPU before you compute the percentage, try inserting the "finit" instruction immediately before you start that computation. If it solves the problem, you may then want to review the remainder of your code for FPU register management. Otherwise, let me know if the problem persists.

(And having the latest version of FPULIB on your site if OK with me.)

Raymond

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

agathon

Hi,

Thank you very much Raymond and Thomas.

Ultimately, all problems were solved with a strategically placed finit.

Since the problem was clearly improper stack management, which was in turn a consequence of a very superficial reading of TFM, I would have expected the ffree and/or fstp to have cured the problem, but they simply postponed the failure.

FPULIB21 is in and I'm happy.

Again, thanks
RWM

raymond


Quoteall problems were solved

Thanks. It is always appreciated to get such feedback. :clap: :clap: :clap: :clap:

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

Ghirai

Well, i use no other fpu code in my app, and adding a fpinit in before the computation doesn't seem to help :'(
MASM32 Project/RadASM mirror - http://ghirai.com/hutch/mmi.html

raymond

Quote from: Ghirai on April 24, 2005, 12:03:24 PM
Well, i use no other fpu code in my app, and adding a fpinit in before the computation doesn't seem to help :'(

You have also posted the following:
Quotethough fpu registers showm by olly seem ok
and
The first time the procedure that contains the loop is called it works great.
But after that, it always returns 0.

Using olly, are you maintaining that you also stepped in each fpu instruction of the loop to assure yourself that the computation was as you expected and that the FpuFLtoA function then returned 0?

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

Ghirai

Mainly yes.

Sadly it's a little more complicated (the following happens inside olly): when i first push the button, and step through the registers, everything is ok, and the result is ok too.
The second time i press the button, somewhere there's an exception before the computation, and my debugged app gets terminated.

Since nothing changes between the 1st time i push the button (all fpu regs are free after the computation) and the 2nd time, i duno what's really wrong here.

Thanks for your help  :wink
MASM32 Project/RadASM mirror - http://ghirai.com/hutch/mmi.html

raymond

If your app is not too big, I'm willing to have a look at it to try and locate the source of your problem. Simply zip the .exe AND the source file and post it.

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