flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > How two macros linking ? |
Author |
|
revolution 13 Jun 2023, 12:58
You have the same problem of mixing the assembler and preprocessor. You can't conditionally define a macro within an if block. The macro is always defined.
So to fix it you need to use the preprocessor to conditionally define macros. Code: match =0, b { macro lmb \{ ;... \} }match =1, b { macro lmb \{ ;... \} } |
|||
13 Jun 2023, 12:58 |
|
Roman 15 Jun 2023, 08:51
Code: macro lm2 a,b=0 { match =0, b \{ macro lmb \\{ Inc a purge lmb ;in this place not working \\} \} } ;in code lm2 eax lm2 ecx lmb ;I get Inc ecx lmb ;I get Inc ecx, but must be Inc eax ;this OK lm2 eax lm2 ecx lmb ;I get Inc ecx purge lmb lmb ;I get Inc eax |
|||
15 Jun 2023, 08:51 |
|
revolution 15 Jun 2023, 08:58
A macro cannot purge itself.
Purge does work inside a macro, but it will purge a previous definition, not itself. |
|||
15 Jun 2023, 08:58 |
|
ProMiNick 15 Jun 2023, 13:56
Roman, I tryed to reproduce thour problem and I couldn`t - not found a problem at all:
Code: use32 incdec0 equ inc incdec1 equ dec macro lm_ a,b=0 { define lmb incdec#b a } macro lmb { match a,lmb \{ a \} restore lmb } lm_ ecx lm_ eax,1 lmb lmb next one lmb will throw error Code: use32 incdec0 equ inc incdec1 equ dec macro lm_ a,b=0 { define lmb Roman' incdec#b a } macro lmb { match =Roman' a,lmb \{ ; check for Roman' in definition a restore lmb \} } lm_ ecx lm_ eax,1 lmb lmb lmb ; no error here it just does nothing or this way Code: use32 incdec0 equ inc incdec1 equ dec macro lm_ a,b=0 { define lmb incdec#b a } macro lmb { irpv any,lmb \{ ; check if defined at least once common match a,lmb \\{ a \\} restore lmb \} } lm_ ecx lm_ eax,1 lmb lmb lmb |
|||
15 Jun 2023, 13:56 |
|
Roman 15 Jun 2023, 16:24
ProMiNick you do trick and restore one equ value, but not hole macro.
My example simple, but sometimes macro have 20 asm commands or more. For this reason I asked about purge. |
|||
15 Jun 2023, 16:24 |
|
ProMiNick 15 Jun 2023, 16:51
linking of symbols(macronames or whatever) is always via define or equ.
just imagine thou create set of macros with temporary names (or even local names of some macro, so that names would be unnaccesible outside of that outer macro) and link that names to some symbol with help of equ or define. Than thou could unwind all values of link symbol that are macros by nature. |
|||
15 Jun 2023, 16:51 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.