NASM Forum > Announcements

Recursive Macros and Beyond!

(1/4) > >>

Keith Kanios:
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: ---git clone git://repo.or.cz/nasm.git preproc-rewrite
cd ./preproc-rewrite
git checkout origin/preproc-rewrite

--- End code ---

Compiling on MacOSX/FreeBSD/Linux/et al.: (assumes you are in the preproc-rewrite directory of the downloaded source)

--- Code: ---autoheader
autoconf
./configure
make

--- End code ---

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

--- Code: ---#!/bin/sh
git clone git://repo.or.cz/nasm.git preproc-rewrite
cd ./preproc-rewrite
git checkout origin/preproc-rewrite
autoheader
autoconf
./configure
make

--- End code ---

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. -Keith

Keith Kanios:
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.

Keith Kanios:
Update: Fixed line number handling.

Rob Neff:
The %fatal/%error/%warning directives in preproc-rewrite no longer includes in the output the source line of the file/macro it originated from, only the line in the main .asm file where it is detected. Is this new behaviour to be expected now or was this missed?

Keith Kanios:
I would imagine it should stay the same.

Is this with the "latest" preproc-rewrite, from early this morning?

Navigation

[0] Message Index

[#] Next page

Go to full version