Page 1 of 1
NASM "macro stacking"
Posted: Thu Jan 01, 2009 4:22 pm
by Troy Martin
Does anyone know if it's possible to do a %macro define inside a macro, but not end the inside macro? Like so:
Code: Select all
%macro crazy 1
%macro crazy2 %1
%endmacro
There, the %endmacro ends the outer macro.
Thanks,
Troy
Re: NASM "macro stacking"
Posted: Fri Jan 02, 2009 1:28 pm
by DeletedAccount
Hi,
It is pretty easy to write a macro processor that supports nested macros , the algorithm is given in Leland L Beck , System Programming . You just need to modify the alogrithm and use recursion insted following the iterative algorithm present in the book .
.
Designing a macro processors based on indentation is a poor design , so %endmacro should and must ideally close the inner macro in this case .Avoid the use of macros as much as possible as they lead to hard to read code .
However you can implement the macroprocessor in such a way that endmacro also takes the macroname as a parameter . I however know not how that can be done in nasm , you may have to rolll your own macroprocessor
Regards
Shrek
Re: NASM "macro stacking"
Posted: Fri Jan 02, 2009 3:08 pm
by Troy Martin
Ahh crap. This will be hard... Need to find a workaround for this one...