NASM - Recursive Macros and Beyond!

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 - Recursive Macros and Beyond!

Post by SpooK »

This is a preliminary announcement regarding the rewrite/revamp of the NASM preprocessor.

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 attempts to address heavy/nested macro invocation efficiency issues.

This rewrite is currently a branch [in GIT] called preprocessor-rewrite, and tentatively labeled as version 2.10rc1. Please note that NASM 2.09rc (official/main/master) is still going and NASM 2.09 should be released fairly soon.

This rewrite has been known to accurately build all NASMX demos, along with a variety of other code snippets by various people.

As positive/successful as this rewrite has been thus far, it is still a major change and we would like to catch as many bugs as possible before merging it into the main/master NASM code base.

Please help us test this rewrite further by downloading/compiling the preprocessor-rewrite branch of the NASM source code, and testing it against your NASM code/snippets.

Windows (Win32/MinGW) Binaries: http://www.nasm.us/downloads/preproc-rewrite.zip (these binaries will be updated when new preproc-rewrite updates are made, along with a corresponding reply to this thread.)

Source Download via Browser: goto http://repo.or.cz/w/nasm.git/shortlog/refs/heads/preproc-rewrite and click on the top-most tar.gz or zip "snapshot" link, decompress/unarchive accordingly.

Source Download via GIT:

Code: Select all

git clone git://repo.or.cz/nasm.git preproc-rewrite
cd ./preproc-rewrite
git checkout origin/preproc-rewrite
Compiling on MacOSX/FreeBSD/Linux/et al.: (assumes you are in the preproc-rewrite directory of the downloaded source)

Code: Select all

autoheader
autoconf
./configure
make
Shell Script for GIT Download + Compiling on MacOSX/FreeBSD/Linux/etc al.:

Code: Select all

#!/bin/sh
git clone git://repo.or.cz/nasm.git preproc-rewrite
cd ./preproc-rewrite
git checkout origin/preproc-rewrite
autoheader
autoconf
./configure
make
If you are comfortable enough with making this branch of NASM your primary binary on MacOSX/FreeBSD/Linux/et al., follow the above compile instructions with: sudo make install

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

Thanks. -SpooK
Last edited by SpooK on Mon Aug 09, 2010 10:38 pm, edited 1 time in total.
SpooK
Member
Member
Posts: 260
Joined: Sun Jun 18, 2006 7:21 pm

Re: NASM - Recursive Macros and Beyond!

Post by SpooK »

Update: Fixed a bug regarding the emission of labels that immediately precede macro invocations. The new source/binaries are available, and can be found as instructed in the initial post.

Note: The latest x264 source successfully builds and passes checkasm with this preprocessor rewrite of NASM.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: NASM - Recursive Macros and Beyond!

Post by Combuster »

Saying that to NASM's maintainer... ouch. :shock: :D
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
SpooK
Member
Member
Posts: 260
Joined: Sun Jun 18, 2006 7:21 pm

Re: NASM - Recursive Macros and Beyond!

Post by SpooK »

Combuster wrote:Saying that to NASM's maintainer... ouch. :shock: :D
Yeah, he "offended" all three or four of us :P

berkus' post obviously has some flamebait qualities to it, but I'll give him the benefit of the doubt and answer anyway.

I work with NASM because I enjoy it. I prefer the syntax and decision making that goes on. YASM has a different purpose and different direction, despite the obvious commonalities.

The same answer applies with OS development, or anything else that drives hobbyists to do what they do, obviously.

Also, If I wanted to work on some project that tried to be many things, I would contribute to something more important and broader-reaching like LLVM, not something with limited scope or use like YASM.

Should be interesting to see how the YASM crew decides to implement NASM's new features ;)
Cognition
Member
Member
Posts: 191
Joined: Tue Apr 15, 2008 6:37 pm
Location: Gotham, Batmanistan

Re: NASM - Recursive Macros and Beyond!

Post by Cognition »

Well for it's worth I'm glad to see the preprocessor getting some more features and work continuing on nasm. It works fine for my needs and honestly I find the preprocessor and macro features to be it's best feature. Keep up the good work!
Reserved for OEM use.
SpooK
Member
Member
Posts: 260
Joined: Sun Jun 18, 2006 7:21 pm

Re: NASM - Recursive Macros and Beyond!

Post by SpooK »

Update: Fixed line number handling.
SpooK
Member
Member
Posts: 260
Joined: Sun Jun 18, 2006 7:21 pm

Re: NASM - Recursive Macros and Beyond!

Post by SpooK »

Update: Fixed macro-relative line number handling for %warning/%error/%fatal/etc. This update, combined with the general preprocessor redesign, now allows for %warning/%error/%fatal lines within %rep blocks, that are nested within macros, to correctly emit the exact macro-relative line number.

Update: Context-local labels will no longer implicitly search upper/outer contexts in the case of undefined labels. This feature was added in NASM 0.98.03, and is now being removed due to its unintuitive and error-prone design. There will be a deprecation warning for "usage" of this feature in the NASM 2.09. For NASM 2.10 and beyond, relying on this context-local label fallthrough will simply generate an expression syntax error. If you rely on this soon-to-be deprecated feature, please take this time to adjust your code, accordingly.

Note: The Win32 Binaries link has changed: http://www.nasm.us/downloads/preproc-rewrite.zip
Post Reply