NASM - Official Recursive Macro Support!

This forums is for OS project announcements including project openings, new releases, update notices, test requests, and job openings (both paying and volunteer).
Post Reply
SpooK
Member
Member
Posts: 260
Joined: Sun Jun 18, 2006 7:21 pm

NASM - Official Recursive Macro Support!

Post by SpooK »

This is an official announcement regarding the rewrite/revamp of the NASM preprocessor, now available as part of the official/main NASM source code starting with NASM 2.10rc2.

This rewrite addresses issues with implementing recursive macros (%rmacro/%irmacro) as previously attempted, %exitmacro and also makes room for new directives.

New NASM Directives:
  • %rmacro: Recursive Macro, can be called arbitrarily deep (really high limit [2^20] set to catch infinite loops.)
  • %irmacro: Same as above, except case-insensitive like %imacro.
  • %exitmacro: Terminates the current macro invocation, much like %exitrep; can be nested in other preprocessor directives (e.g. %if/%endif) within the macro, with exception of another macro, of course.
  • %while/%endwhile/%exitwhile: A fusion between %rep and %if.
  • %comment/%endcomment: Comment block for long/multi-line comments. A little syntactic sugar, if you will.
  • %final: Causes rest of line after %final to be preprocessed after all other "normal" preprocessing is complete. Multiple %final directives work like the x86 stack, LIFO/FILO.
This rewrite also addresses efficiency issues with heavy/nested macro invocations.

Please help us test this rewrite further by downloading/compiling the NASM 2.10rc2 and testing it against your NASM code/snippets.

NASM 2.10rc2 is available for download (source and binaries) at http://www.nasm.us/pub/nasm/releasebuilds/2.10rc2/

Please note that the official documentation will be updated over the next few weeks as we approach an official/stable NASM 2.10 release.

If there are any questions/comments/concerns, please reply to this thread.

Thanks. -SpooK
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: NASM - Official Recursive Macro Support!

Post by qw »

How much I appreciate NASM, I really dislike its preprocessor syntax. It continues to be expanded with new directives, straightly contradicting the NASM philosophy. Whoever invented "%elifnidni"?

Try to write this in NASM:

Code: Select all

#if defined FOO || BAR == some_value
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: NASM - Official Recursive Macro Support!

Post by Solar »

Easy. Write it just like that and feed your source through the C precompiler first. 8)

(Half serious. I actually do prefer using the C preprocessor for the few ASM source files I have, because I - and most others - are quite familiar with its syntax, and I'm not a friend of heavy macro-ized ASM anyway.)
Every good solution is obvious once you've found it.
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: NASM - Official Recursive Macro Support!

Post by qw »

Solar wrote:Easy. Write it just like that and feed your source through the C precompiler first. 8)
Actually, when I write for GAS I do use the C preprocessor. Haven't tried it with NASM though.

BTW I acknowledge that the NASM preprocessor is very powerful, much more powerful than the C preprocessor. It is just the syntax I don't like.
Post Reply