The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Farabi on August 31, 2005, 09:55:29 AM

Title: Simple example of FPU.
Post by: Farabi on August 31, 2005, 09:55:29 AM
Here is the example how to use FPU spesific for OpenGL.


;Generate a Float number from integer

IntegerToFloat proc Number:dword

push Number
fild dword ptr[esp]
fstp dword ptr[esp]
pop eax

ret
IntegerToFloat endp ; Return Value is eax=real4 format of Number


Dont use this function on the realtime calculation. fild function can cause the light disable.

Check also fsub, fadd and fmul. Dont use fisub, fadd, fimul.
Title: Re: Simple example of FPU.
Post by: PBrennick on August 31, 2005, 04:23:39 PM
Farabi,
Thank you for this information.  Every little bit helps me as I try to learn this stuff and advice is always appreciated.

Stay well,
Paul
Title: Re: Simple example of FPU.
Post by: Farabi on September 01, 2005, 01:19:04 AM
Whoops I think Im just made the newbie run by that long code.
CHeck the attachment and see the function have name FLxxxxxx. Dont forget to put this on your code.


.elseif uMsg==WM_CREATE
invoke Phase1


Macro can be lot easier.

[attachment deleted by admin]
Title: Re: Simple example of FPU.
Post by: Farabi on September 03, 2005, 04:42:45 PM
I edit my message.