flat assembler
Message board for the users of flat assembler.

 Index > Macroinstructions > Flag in macros. Help to solve.
Author
Roman

Joined: 21 Apr 2012
Posts: 1379
Roman 17 Sep 2013, 19:21
My macro:
Quote:

DoProc = 0
macro Loo x{ local Pr0
if DoProc = 0
jmp Pr0
Pr1:
invoke MessageBox,0,eax,0,0
ret
Pr0:
DoProc = 1
end if
mov eax,x
Call Pr1
}

If i not write DoProc = 0 my macro not work. Fasm swears on DoProc in macro.
How fix this. I want use my macro but do not explicitly specify DoProc.
Because I will have a lot of similar macros. And write for each macro flag (like DoProc ) somehow not healthy and not cool.
17 Sep 2013, 19:21
baldr

Joined: 19 Mar 2008
Posts: 1651
baldr 17 Sep 2013, 21:46
Roman,

Do you want to check whether Loo macroinstruction is invoked first time? It can be done several ways:
Code:
```; Using symbolic constant
macro Loo x {
match =_Loo, _Loo \{
; seems that '_Loo' is undefined, let's do it
\local ..Loo, ..Loo0
jmp     ..Loo0
..Loo:  invoke  MessageBox, 0, eax, 0, 0
ret
..Loo0:
_Loo equ ..Loo; now it's defined
\}
mov     eax, x
call    _Loo; here '_Loo' is defined properly in any case
}

; Using numeric constant
macro Loo x {
local ..Loo, ..Loo0
if ~defined _Loo
jmp     ..Loo0
..Loo:  invoke  MessageBox, 0, eax, 0, 0
ret
..Loo0:
_Loo = ..Loo
end if
_Loo = _Loo; make it out of scope above
mov     eax, x
call    _Loo
}    ```
They're quite similar: symbolic one is straightforward, numeric uses defined operator to check if _Loo constant is defined before (because redefinition makes it inaccessible from above).

Do you think you'll get twice as much help if you post this in two forums? Then why not in three (or all at once)? And please use [code]…[/code] tags.
17 Sep 2013, 21:46
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------AssemblyPeripheria General----------------MainTutorials and ExamplesDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsOS ConstructionIDE DevelopmentProjects and IdeasNon-x86 architecturesHigh Level LanguagesProgramming Language DesignCompiler Internals Other----------------FeedbackHeapTest Area

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum