Float32 Question
parsko
Posts: 501
Hi all,
I would like to work with Float32. My plan is to copy certain routines into my own assy cog and call the appropriate function from within my own assy cog (I only need FMul and FDiv).
What do these routines use for inputs, numerically?
Are they floating point numbers IEEE-754 standard or do they use 16.16 nomenclature?
The methods for Divide and Multiply in PASM use (what I'm calling) the 16.16 nomenclature. The manual calls for IEEE-754 for floating point stuff, but I can't confirm (yet, until I start playing with it) that FLOAT32 uses it as well. I'm assuming IEEE-754 is the answer...
Thanks,
-Parsko
I would like to work with Float32. My plan is to copy certain routines into my own assy cog and call the appropriate function from within my own assy cog (I only need FMul and FDiv).
What do these routines use for inputs, numerically?
Are they floating point numbers IEEE-754 standard or do they use 16.16 nomenclature?
The methods for Divide and Multiply in PASM use (what I'm calling) the 16.16 nomenclature. The manual calls for IEEE-754 for floating point stuff, but I can't confirm (yet, until I start playing with it) that FLOAT32 uses it as well. I'm assuming IEEE-754 is the answer...
Thanks,
-Parsko
Comments
Basically, you'll need to go through the listings and see what each function calls and what is needed. But, once you do that it's easy to use. Here's a little PID routine I wrote that can be embedded in the code:
You can see how easy it is to call the F32 commands from the code. Which brings me to another point: IIRC, F32 is the improved version (faster, smaller) of Float32. You may want to look into that.
Also IIRC, the support routines took about 180 longs.
You might find the floating point routimes in the F32 obect by Lonesock smaller and/or faster.
Note that although Spin does not support floating point opereations you can define floating point constants and use floating point literals:
"A := 4.3424" will result in the correct floating point represenation being stored in A in IEE format.
-Parsko
This is the syntax that this is pulled from, it's the FMul routine in Float32.
'
' _FMul fnumA = fnumA * fNumB
' _FMulI fnumA = fnumA * {Float immediate}
' changes: fnumA, flagA, expA, manA, fnumB, flagB, expB, manB, t1, t2
'
To me, this implies that FnumA is a floating point number, and FnumB is an integer (not floating). Can anyone confirm?
Thanks,
-Parsko
I seem to be getting it. I need to float my values first before sending them to the routines, that got me for the past couple hours.
Thanks Mike!
-Parsko