Hello all.
I have question, why in masm32 dont work "push 1.0" - real or BCD number not allowed. This is not allowed by Intel processor? Its only masm32 bug? :eek
I know: its work
float1 real4 1.0
push float1
How C\C++\Delphi compilator translate this code:
glVertex3f(4.0f, 5.0f, 0.0f);
Greeting :U
Hello,
The number couldn't be push immediately because the compiler need to calculate the value.
To calculate it , he need a declared constant .
Quote
R4MOV MACRO dest,src
local reel
.const
reel REAL4 src
.code
PUSH reel
POP dest
ENDM
See this link.
http://www.masm32.com/board/index.php?topic=6145.msg45730#msg45730
ToutEnMasm
pushfl macro float1
db 68h ; "push immediate dword"
real4 float1
endm
main proc
pushfl 1.0
pop eax
ret
main endp
Gets assembled to
00401000 fn_00401000:
00401000 680000803F push 3F800000h
00401005 58 pop eax
00401006 C3 ret
This way, an "invoke" replacement to support floats can be made.
There's such a replacement of "invoke", but I can't seem to find it :S. I remember it supported strings, too, something like
invoke2 someProc,"hello world",1.0,7
Can anyone give me a link to it, or re-post it?
I using makro from hitchhikr
Quote; Macros
literal_float macro lit_float
local local_float
.data
local_float real4 lit_float
.code
exitm <local_float>
endm
CFLT macro lit_float
exitm <literal_float(lit_float)>
endm
Code in asembler:
Quoteinvoke glColor3f, CFLT(0.0),CFLT(1.0),CFLT(1.0)
invoke glBegin, GL_TRIANGLES
invoke glVertex3f, CFLT(0.0), CFLT(0.0), CFLT(0.0)
invoke glVertex3f, CFLT(1.0), CFLT(0.0),CFLT(0.0)
invoke glVertex3f, CFLT(1.0), CFLT(1.0), CFLT(0.0)
invoke glEnd
Disassemble to:
Quote
push [L004020B3]
push [L004020AF]
push [L004020AB]
call jmp_opengl32.dll!glColor3f
push 00000004h
call jmp_opengl32.dll!glBegin
push [L004020BF]
push [L004020BB]
push [L004020B7]
call jmp_opengl32.dll!glVertex3f
push [L004020CB]
push [L004020C7]
push [L004020C3]
call jmp_opengl32.dll!glVertex3f
push [L004020D7]
push [L004020D3]
push [L004020CF]
call jmp_opengl32.dll!glVertex3f
call jmp_opengl32.dll!glEnd
Quote
L004020B3:
db 00h;
db 00h;
db 80h; '?'
db 3Fh; '?'
L004020B7:
db 00h;
db 00h;
db 00h;
db 00h;
L004020BB:
db 00h;
db 00h;
db 00h;
db 00h;
L004020BF:
db 00h;
db 00h;
db 00h;
db 00h;
L004020C3:
db 00h;
db 00h;
db 80h; '?'
db 3Fh; '?'
Then get real4 value from MEMORY? It's not very fast?
I'm begin programing and I don't know. But a thing its better and faster way?
I'm special get this post to "The Campus" my question is not opengl but why compilator don't let push 1.0
Quote from: LechooY on December 13, 2006, 11:34:31 AM
Then get real4 value from MEMORY? It's not very fast?
Exactly - that's the reason we should find a replacement of "invoke" for this case :bg . Because with the regular invoke, no matter whatever tricks we use, they'll be overwritten.
Quote from: Ultrano on December 13, 2006, 11:38:38 AM
Quote from: LechooY on December 13, 2006, 11:34:31 AM
Then get real4 value from MEMORY? It's not very fast?
Exactly - that's the reason we should find a replacement of "invoke" for this case :bg . Because with the regular invoke, no matter whatever tricks we use, they'll be overwritten.
Then by very good if we find it :) I don't know nothing about "invoke2" when I don't help. Now if I use invoke + CFLT assembler code its slowly than C/C++/Delphi? :(
invoke its very useful but now...
No replacement for invoke, but there is some related information here:
http://www.masm32.com/board/index.php?topic=3893.0
I do have a vague memory of an invoke2, but I can't find it.
And here's what I was searching for:
http://www.masm32.com/board/index.php?topic=1063.0
BUT it can decide to use ecx and edx during "addr localVar", which is a particular problem for me.
Ultrano you The Men!
Quote
invoke glLoadIdentity
fncall glColor3f, 0.0, 1.0, 1.0
invoke glBegin, GL_TRIANGLES
fncall glVertex3f, 0.0, 0.0, 0.0
fncall glVertex3f, 1.0, 0.0, 0.0
fncall glVertex3f, 1.0, 1.0, 0.0
invoke glEnd
invoke SwapBuffers, hDC
:U :clap:
Quote
push 3F800000h
push 3F800000h
push 00000000h
call jmp_opengl32.dll!glColor3f
push 00000004h
call jmp_opengl32.dll!glBegin
push 00000000h
push 00000000h
push 00000000h
call jmp_opengl32.dll!glVertex3f
push 00000000h
push 00000000h
push 3F800000h
call jmp_opengl32.dll!glVertex3f
push 00000000h
push 3F800000h
push 3F800000h
call jmp_opengl32.dll!glVertex3f
call jmp_opengl32.dll!glEnd
Now its perfect :) Thanks Petroizki for this super macro :8)
Quote from: Ultrano on December 13, 2006, 11:58:01 AM
BUT it can decide to use ecx and edx during "addr localVar", which is a particular problem for me.
So load the address yourself and just push a register (or store the address in memory and push that value). I haven't used ADDR in quite a while because of the potential for trashing a register.
A macro to move a REAL4 straight into a register or memory location:
movr4 MACRO dest:REQ, src:REQ
mov dest, 0BADF00Dh
ORG $-4
REAL4 src
ENDM
Cheers,
Zooba :U
Try this, you may get some extra legs out of it.
push esi
push edi
xor esi, esi
mov edi, 3F800000h
push edi
push edi
push esi
call jmp_opengl32.dll!glColor3f
push 00000004h
call jmp_opengl32.dll!glBegin
push esi
push esi
push esi
call jmp_opengl32.dll!glVertex3f
push esi
push esi
push edi
call jmp_opengl32.dll!glVertex3f
push esi
push edi
push edi
call jmp_opengl32.dll!glVertex3f
call jmp_opengl32.dll!glEnd
pop edi
pop esi
Much easier in GoAsm...
invoke glVertex3f, 4.0, 5.0, 0.0
or...
push 0.0
push 5.0
push 4.0
call glVertex3f
encodes as...
00401001 68 00000000 PUSH 0
00401006 68 0000A040 PUSH 40A00000
0040100B 68 00008040 PUSH 40800000
00401010 E8 E1400000 CALL <JMP.&OPENGL32.glVertex3f>
Same result in poasm :)
In flat assembler
invokel glVertex3f, 1.0, 1.0, 0.0
push 00000000h
push 3F800000h
push 3F800000h
call jmp_opengl32.dll!glVertex3f
therefore I was surprise when masm get this log "real or BCD number not allowed". But I still work on masm because I habit to masm and its great.
Thanks everyone :U