If I have the following code, where the parameter I want is defined below where I need to use it-
; these three don't work
invoke GetDlgItem,hParent,IdVal ; doesn't work
invoke GetDlgItem,hParent,[IdVal] ; doesn't work
invoke GetDlgItem,hParent,dword ptr IdVal ; doesn't work
; however this one does
mov eax,IdVal
invoke GetDlgItem,hParent,eax ; works
.
.
.
.data?
IdVal dd ?
.code
mov IdVal,1017
Clearly masm knows what and where IdVal is or the "mov eax, IdVal" wouldn't work.
What is the form of putting the address of the variable in as an invoke parameter without out using a register or moving the definition above the code?
similarly, if an address were to be passed to routine XXXX
invoke XXXX,hParent,addr IdVal ; doesn't work
invoke XXXX,hParent,offset IdVal ; doesn't work
mov eax,offset IdVal
invoke XXXX,hParent,eax ; works
The first form is correct, I don't know why it's not working for you...
invoke GetDlgItem,hParent,IdVal
Same thing for passing offsets. Just remember that OFFSET won't work with local variables.
I'm glad it's supposed to work!
Here's the error I get:
Assembling: F:\WinAsm\Progs\NewTest\DgTest.asm
F:\WinAsm\Progs\NewTest\DgTest.asm(281) : error A2006: undefined symbol : IdVal
F:\WinAsm\Progs\NewTest\DgTest.asm(281) : error A2114: INVOKE argument type mismatch : argument : 2
You need to define the IdVal symbol before using it... try placing your data before your code.
Although forward references to variables are generally supported, they are not for invoke.
I was reallllllly hoping it was something I was doing wrong. How about the the replacements for invoke that are floating around. Do any of them allow forward references like (except invoke) everything else in masm does?
Jim,
The only thing you are doing "wrong" is placing your data AFTER the code so that it has not yet been referenc3d by the assembler. Old TASM and others used to work like that but MASM has always required the data to be available before it is referenced.
Just place your data BEFORE the code that references it.
That's the thing that bugs me. No other instruction requires the data before it is referenced, Invoke is the only one.
Hi Jim, you can always stick the declaration inline:
.data
IdVal DD 0
; align 4?
.code
invoke GetDlgItem,hParent,IdVal
I'm surprised MASM didn't complain that the var was "undefined."
It could always be worse... be thankful you're not programming JAL - http://groups.yahoo.com/group/jallist/ - entire routines cannot be forward-referenced! ::) :lol