News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Using function MACRO as proc MACRO

Started by Ficko, June 22, 2010, 01:57:25 PM

Previous topic - Next topic

dedndave

truthfully, the label shouldn't have to be on a seperate line
the fact that the macro is expanded first kinda sux rox if you ask me   :P
if i were a big-time macro user, i would bitch about it - lol

Ficko

Quote
if i were a big-time macro user, i would bitch about it..

What you think I am doing now ?  :lol :lol

But I have to stick to your proposal because there is no other way to circumvent it. :(
And if I look the things in a certain way there is every command a potential error trap if you don't know what you are doing. :wink

I tried everything even managed to get MASM into a dead loop. :green2


.686p
.model flat, stdcall
option casemap :none

MyMacro MACRO
@CatStr(<COMMENT !*>)
EXITM <>
@CatStr(<!*>)
ENDM

.code
start:MyMacro()
end start


My only hope left is to manage to get a way to report an error at least if the line has a label but that presuppose there is a way to get the line content somehow.
"@Line" gives the actual line and I am wondering may exist a public pointer to the actual line? ::)

jj2007

OK, to summarise the problem here a testbed.

include \masm32\include\masm32rt.inc

zemac MACRO arg
ifb <arg>
tmp$ CATSTR <"I am a lonely macro with no arg called from line >, %@Line, <">
MsgBox 0, chr$(tmp$), "zemac:", MB_OK
EXITM <>
else
MsgBox 0, &arg&, "zemac:", MB_OK
EXITM <EAX>
endif
ENDM

.code
start: jmp L1 ; jmp L1 will work fine, jmp L2 will ignore the macro code
nop
L1:
L2: mov eax, zemac("Hello World, if you see me it's working!") ; this code will be generated before label L2
.if eax!=IDOK
MsgBox 0, "There was no box...!", "Hi", MB_OK
.endif
zemac() ; same macro "standalone"
exit

end start