Hi there...
I wrote this buggy macro ...
... which should generate those instructions ...
... when it is called like this:
But it won't work at all... DSec is a proc, defined after the MACRO
and also after the location where the macro is called ... I tried to put a
"DSec PROTO" into the header. Didn't help.
Furthermore, dwList is defined as a simple doubleword inside DSec
Nevertheless, MASM gives me a syntax error in the line with the IF expression.
Also, would I need to use VARARG to make it work without any arguments?
Thanks for your valuable help! :)
aweX <-
I wrote this buggy macro ...
GetD MACRO target:=<DSec>, datbase:=<0>
mov eax, [esp+&datbase&]
IF target NE <DSec>
add eax, (&target&-DSec)
ENDIF
ENDM
... which should generate those instructions ...
mov eax, [esp+0] [b](1)[/b]
-- or --
mov eax, [esp+8]
add eax, dwList-DSec [b](2)[/b]
... when it is called like this:
[b](1)[/b] GetD
[b](2)[/b] GetD dwList, 8
But it won't work at all... DSec is a proc, defined after the MACRO
and also after the location where the macro is called ... I tried to put a
"DSec PROTO" into the header. Didn't help.
Furthermore, dwList is defined as a simple doubleword inside DSec
Nevertheless, MASM gives me a syntax error in the line with the IF expression.
Also, would I need to use VARARG to make it work without any arguments?
Thanks for your valuable help! :)
aweX <-
GetD MACRO target:=<DSec>, datbase:=<0>
mov eax, [esp + datbase]
[COLOR=purple]IFDIFI[/COLOR] target,<DSec>
add eax, target - DSec
ENDIF
ENDM
You must do a string comparison, otherwise comparison is numeric.
Personally, I like this solution:
GetD MACRO target:=<>, datbase:=<0>
mov eax, [esp + datbase]
IFNB <target>
add eax, target - DSec
ENDIF
ENDM
If DSec is a procedure, it is not fixed to a certain position in memory and thus MASM can't evaluate 'target - DSec' at assembly time. 'target + DSec' would work.
@bitRAKE: Thank you, it works wonderful now!