do I have to something special to pass floating points as a parameter in a routine.
I'm trying to take up OpenGL programming and that uses floating points a lot. Now I've seen C++ example code that passes a float to certain routines, but the same routines are defined as having PROTO :DWORD,:DWORD instead of say :REAL4 as I expected.
How can I pass a REAL4 value to such a function?
anyone experienced in OpenGL programming under MASM.
Should be no problem as Real4 IS dWord size.
I have uploaded a good OpenGl demo at my page:
http://betov.free.fr/SpAsm.html
If you prefer the MASM version, there is a link at my page
to "Test Departement" (who is the original author).
betov.
damn you're right it is :(
are C++ floats REAL8 then?
that would explain it and then I can just
invoke myFunc,label[4],label
that should work just fine.
thanks betov I'll check it out.
Merçi beaucoup :)
And how did you do the smilies???
much better than (:) ) !!!
betov
they are conversed automatically
I might add some more colorfull ones though, these are a bit bland.
:) :( :p :D
don't know exactly which ones are supported and which not
C double float types do translate to a REAL8 type (float is a REAL4). There are a number of ways to handle this, personally I'd define a structure to handle pushing portions of the REAL8, like so:
.data
RealFloat UNION
Value REAL8
STRUCT
LoDword DWORD
HiDword DWORD
ENDS
RealFloat ENDS
MyFloat RealFloat
.code
invoke SomeFunction, MyFloat.HiDword, MyFloat.LoDword
Please note I have not tried this, am not home to check my MASM books, and may have the "little endian" thingie all backwards. But you get the general idea to pusha REAL8 quantity in dword hunks.
Ugh... where did my whitespace go?
Oh well, at least it caught the linefeeds. ;-)
Do you really want to preserve white spaces? I would have to replace each space with which would make the page loads slower.
how about only preserving white spaces between a
tag combo?re whitespace:
Yes, I would appreciate leaving the whitespace in posts. I use it to indent and otherwise help the readability of my code. This assumes anyone else actually reads my code. But I do try.
True fact: People who know me from the VB world think my ASM looks like VB. And ASM people think my VB reads like ASM. (I only write C under pain of torture)
back to the floating point thing.
what if you want to pass constants as a parameter ie:
invoke someFunction, 3.5, 2.9
can you typecast that somehow to convert it from a real8 to two dwords or a real4 to one dword?
A REAL4 *is* a dword.
Generally, you can pass anything by reference (by address) by pushing the lowest address of where the data resides. The ADDR built-in macro does exactly this.
in bizarrecreation (hardcode) site, there is include file for masm32 that define such macro for opengl
i don't remember the url but hutch gived it on this board in an other topic about OpenGL
it's easy to pass a floating point number by reference.
but I want to pass by value, without addressing another part or memory (for efficiency reasons).
If I had a union:
RealFloat UNION
Value REAL8
STRUCT
LoDword DWORD
HiDword DWORD
ENDS
RealFloat ENDS
can I do a:
invoke SomeFunction, (RealFloat Ptr 2.9).HiDword, (RealFloat Ptr 2.9).LoDword
to pass the double precesion number 2.9 into a function without the need for extra memory (even if it is only 8bytes) and dereferencing?
If not, I've seen code in TASM where someone had used stosd to copy memory from the data segment to the stack segment. Would this implementation be faster than pushing a whole bunch of code from the data segment to the stack?
What about this? LowDWord Equ 0 HighDWord Equ 4 .data real1 Dq 1.234 .code Push DWord Push DWord Invoke SomeFunction