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.
Posted on 2000-11-06 13:54:00 by Hiroshimator
Should be no problem as Real4 IS dWord size. I have uploaded a good OpenGl demo at my page: If you prefer the MASM version, there is a link at my page to "Test Departement" (who is the original author). betov.
Posted on 2000-11-07 04:00:00 by 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 :)
Posted on 2000-11-07 04:06:00 by Hiroshimator
And how did you do the smilies??? much better than (:) ) !!! betov
Posted on 2000-11-07 06:50:00 by 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
Posted on 2000-11-07 07:46:00 by Hiroshimator
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.
Posted on 2000-11-08 00:38:00 by TTom
Ugh... where did my whitespace go? Oh well, at least it caught the linefeeds. ;-)
Posted on 2000-11-08 00:41:00 by TTom
Do you really want to preserve white spaces? I would have to replace each space with   which would make the page loads slower.
Posted on 2000-11-08 04:36:00 by Iczelion
how about only preserving white spaces between a
tag combo?
Posted on 2000-11-08 06:03:00 by Hiroshimator
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)
Posted on 2000-11-08 21:42:00 by TTom
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?
Posted on 2000-11-10 00:55:00 by Satrukaan
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.
Posted on 2000-11-10 02:24:00 by Ernie
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
Posted on 2000-11-10 05:55:00 by scalp
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?
Posted on 2000-11-13 22:00:00 by Satrukaan

What about this?

LowDWord	Equ	0
HighDWord	Equ	4

real1	Dq	1.234

	Push	DWord 
	Push	DWord 
	Invoke	SomeFunction

Posted on 2000-11-14 13:25:00 by sjhenry