Hi there,
I'm trying to calculate a floating value and print it.
First of all where can I find a FPU Tutorial for beginners?
I tried searching for one but didn't find almost anything.
My Problem:
.data
dTime dd 0
dSecond dd 500
qVar dq 0
szFormat db "%f", 0
szBuffer db 100 dup(0)
.code
mov [dTime], 3894
fld [dTime]
fld [dSecond]
fdiv st(0), st(1)
fst [qVar]
invoke wsprintf, addr szBuffer, addr szFormat, qVar
I just tried this FPU code, I don't know yet if it's works since I didn't see the output.
I read the wsprintf article from the MSDN and noticed that it hasn't got a parameter named %f.
So how can i print it? :'(
PS: Do I have to clean the FPU Stack after I using it?
Thanks very much!
Hello, n00b!.
Please, take a look at here. (http://www.masm32.com/board/index.php?topic=4646.0)
Your answer is there.
Kind regards,
PauloH
Thanks :bg
But do you know something about my FPU questions?
noob!,
QuotePS: Do I have to clean the FPU Stack after I using it?
You should leave the FPU stack empty.
QuoteFirst of all where can I find a FPU Tutorial for beginners?
Simply FPU (http://www.website.masmforum.com/tutorials/fptute/)
Argh, damnit.
I had that in mind but searched for "simple fpu"....
Thank you :P
the C run time does a good job converting floats to strings
fstp Double
lea eax,[Double]
lea ecx,[Double+4]
Invoke msvcrt.dll:_gcvt, eax, ecx,12, offset szResult
add esp,16[quote][/quote]
QuotePS: Do I have to clean the FPU Stack after I using it?
You should leave the FPU stack empty.
That would be correct under the following circumstances:
- You intend to use other fpu instructions within the same program and you don't need the data which is currently in the FPU registers.
Otherwise, it simply doesn't matter whether you clean it up or not. All other programs running concurrently or afterwards are provided initially with a clean FPU.
As for the tutorial, after you become a bit more familiar with some of the basic instructions, you can eventually also refer to the source code of the Fpulib (available with the MASM32 package) for some of the more complex operations such as exponentiation, logarithms, etc.