i know i can predefine some float values in .data
but if i want to input instant value, how should i write it?
i tried this: invoke functionname,3f800000h,0,bf800000h
here 3f800000h is interpreted into hex 3f800000, but bf800000h can't be assembled.
i also tried -3f800000h, a wrong value was produced. how should i write the right value?
i also tried invoke functionname,1.0,0,-1.0 . this can't be assembled either.
when hexidecimal values begin with a non-numeric character, they must be preceeded with a 0: 0bf800000h
otherwise, the assembler thinks it is a label of some sort
labels, on the other hand, may not begin with a numeric digit
INVOKE can't accept floats directly like that. MASM32 includes some macros for doing what you want called FP4, FP8 and FP10. You use them like this:
INVOKE functionname, FP8(1.0), FP8(0.0), FP8(-1.0)
i didn't know you could write negative numbers in hex using the minus sign :) i thought you just had to make sure the negative bit was set. ... but wikipedia (http://en.wikipedia.org/wiki/Hexadecimal) says you can and they are very reliable :) why do you want to represent a negative number in hex?
From the MASM Programmer's Guide:
; Encoded as hexadecimals
ieeeshort REAL4 3F800000r ; 1.0 as IEEE short
ieeedouble REAL8 3FF0000000000000r ; 1.0 as IEEE long
temporary REAL10 3FFF8000000000000000r ; 1.0 as 10-byte real
I've never done it that way, but I guess it's possible. It doesn't show an example of negatives.
it is very time-consuming to do it that way, but it can be done
for floats, there is no 2's compliment - just take the same positive value and set the sign bit
why do that way when the macros are there for ya - lol
if you do it by hand, you are more likely to make a mistake
i didn't know i could write:
INVOKE functionname, FP8(1.0), FP8(0.0), FP8(-1.0) . now this is great!
i wrote hex only because invoke functionname,1.0,2.0,3.0 can't be assembled.
and some float values are very easy to remember , such as 0, 0.5, 1 and -0.5, -1
MASM Included a macro for FPU, CFLT and CDBL.
i find INVOKE functionname, FP8(1.0), FP8(0.0), FP8(-1.0) can't help the situation when a function PROTO is like this:
function PROTO :dword,:dword,:dword,:dword,:dword,:dword
i still have to predefine 3 double values in .DATA , then
invoke function dword ptr predefined1,dword ptr predefined1+4,dword ptr predefined2,dword ptr predefined2+4,dword ptr predefined3,dword ptr predefined3+4
and FP4(1.0) is actually assembled the same way as if a float value was predefined in .DATA .
Try:
function PROTO :REAL8,:REAL8,:REAL8
or
function PROTO :QWORD,:QWORD,:QWORD
Quote from: supercoollee on May 08, 2010, 07:01:50 AM
and FP4(1.0) is actually assembled the same way as if a float value was predefined in .DATA .
Not by accident:
FP4 MACRO value
LOCAL vname
.data
align 4
vname REAL4 value
.code
EXITM <vname>
ENDM
\masm32\macros\macros.asm is a fascinating lecture :wink
Quote from: MichaelW on May 08, 2010, 07:26:46 AM
Try:
function PROTO :REAL8,:REAL8,:REAL8
or
function PROTO :QWORD,:QWORD,:QWORD
i didn't mean the protos which can be defined by me, i meant the predefined protos such as
gluPerspective proto :dword,:dword,:dword,:dword,:dword,:dword
this function requires 3 real8 value, but in opengl32.inc , it requires 6 dwords :tdown
Quote from: jj2007 on May 08, 2010, 07:35:39 AM
Quote from: supercoollee on May 08, 2010, 07:01:50 AM
and FP4(1.0) is actually assembled the same way as if a float value was predefined in .DATA .
Not by accident:
FP4 MACRO value
LOCAL vname
.data
align 4
vname REAL4 value
.code
EXITM <vname>
ENDM
\masm32\macros\macros.asm is a fascinating lecture :wink
now that i find out this fact, i will stick to my way - writing immediate HEX value in the code, that's faster than FP4(1.0) in runtime, although the difference is small.
It will likely be easier for you to use FP4/8/10/etc(x.x)
Reason being that once you start entering 'normal' numbers you dont have to convert.... ie point:
What is 608.735629 in HEX in the time it takes you to type FP4(608.735629)?
Further when you read that number in hex how long does it take you to know what the value is
Quote from: supercoollee on May 08, 2010, 07:44:43 AM
i didn't mean the protos which can be defined by me, i meant the predefined protos such as
gluPerspective proto :dword,:dword,:dword,:dword,:dword,:dword
this function requires 3 real8 value, but in opengl32.inc , it requires 6 dwords :tdown
You'll have to ask Farabi on this.... I think he uses glu.inc instead.... I wrote navigation some more complex way without which I still dont completely get :lol
Quotei find INVOKE functionname, FP8(1.0), FP8(0.0), FP8(-1.0) can't help the situation when a function PROTO is like this:
function PROTO :dword,:dword,:dword,:dword,:dword,:dword
that's because you are using 4-byte floats :bg
try this, instead...
INVOKE functionname, FP4(1.0), FP4(0.0), FP4(-1.0)
Put this above all of your include file.
literal_double macro lit_double:vararg
local local_double
.data
local_double real8 lit_double
.code
exitm <local_double>
endm
literal_float MACRO lit_float:VARARG
LOCAL local_float
.data
local_float real4 lit_float
.code
EXITM <local_float>
ENDM
CFLT MACRO lit_float:VARARG
EXITM <literal_float(lit_float)>
ENDM
CDBL macro lit_double:vararg
exitm <literal_double(lit_double)>
endm
This is how do you use it
invoke glVertex3f,CFLT(1.0),0,0
.
just use directx. I have switched myself. mostly because AutoCAD did. Whats good enough for them is good enough for me.
is there some extra requirements for using directx instead of opengl?
currently i only have MASM32 package downloaded from Hutch's site. this IDE is simple and lightweight and doesn't mess with my system. i like this kind of environment. :thumbu
in fact, what i need is just an IDE which helps me create a standalone software, i don't need much fancy stuff, i don't like softwares which are 1GB in size. :snooty:
Quote from: supercoollee on May 09, 2010, 03:10:24 AM
is there some extra requirements for using directx instead of opengl?
currently i only have MASM32 package downloaded from Hutch's site. this IDE is simple and lightweight and doesn't mess with my system. i like this kind of environment. :thumbu
in fact, what i need is just an IDE which helps me create a standalone software, i don't need much fancy stuff, i don't like softwares which are 1GB in size. :snooty:
Try using RadAsm.