What in world do you do with floats in assembly???? You will have to excuse me, but till 2 weeks ago I had spent my life and career programming in C\C++. All I am trying to
do is send a constant float value to a function. I have tried the following...
glClearColor, 1.0,1.0,1.0,1.0
I am trying to make this local to specific function it is called from
LOCAL bkclr:REAL4
mov bkclr,1.0
glClearcolor, bkclr, bkclr, bkclr, bkclr
Anyway neither of these works and I am too new to MASM syntax to come up with anything more original.
floats are 80bit floating point numbers commonly used with the
co/math processor to do precision math. With masm, functions are usally called with
invoke or call. Invoke pushes the parameters in reverse order onto the stack before calling (or jumping to?) the function. With call, you push the arguments onto the stack.
You've done pretty well if you got this far without floats, I started using them one week after I began programming in assembly.
Anyway I know what your problem is. You can't do the following in Masm
mov bkclr,1.0
you have to declare float values at the beginning in the .data section (Or you could use the Hex representation of 1.0)
.data
bkclr real4 1.0
A guy call Serge Coban wrote some macros, specifically for OpenGL in assembly that allow you to use code such as glClearColor, 1.0,1.0,1.0,1.0 in assembly. This is the ideal way to program OpenGL Apps in Masm. You'll find the necessary include files and some great examples at his site
Bizzare Creationshello [=CC=]AMBUSH,
to send a float to a proc with invoke:
.data
float1 real4 1.0
float2 real8 2.0
.code
ReceivingProc proto a1:real4,a2:real8
ReceivingProc proc a1:real4,a2:real8
ret
ReceivingProc endp
CallingProc proc
mov eax,float1
mov edx,dword ptr float2+0
mov cdx,dword ptr float2+4
invoke ReceivingProc,eax,ecx::edx
ret
CallingProc endp
JaphethSpeaking of just putting the value in hex. Does anyone know of a tool that will show you the hex number for a decimal number?
Part of every win32 installation, calc.exe. Put it into scientific mode. To do the conversion inside a program, you can use aad.
Actually before I posted that I tried to use the Win32 calc
program. It didn't work (I tried 0.012 for instance). I read the help and it said quite clearly that any decimal values would be rounded down before converted hex,bin, or octal conversion.
To use a REAL4 float in a mov instruction, you can use this:
movfloat MACRO dest:REQ, value:REQ
mov dest, 88888888h
org $-4
REAL4 value
ENDM
Thomas