NASM "macro stacking"

Programming, for all ages and all languages.
Post Reply
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

NASM "macro stacking"

Post 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
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
DeletedAccount
Member
Member
Posts: 566
Joined: Tue Jun 20, 2006 9:17 am

Re: NASM "macro stacking"

Post 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 . :D .

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
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: NASM "macro stacking"

Post by Troy Martin »

Ahh crap. This will be hard... Need to find a workaround for this one...
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
Post Reply