From 0ca00860dfde882f384658409a0d14a3b46fc108 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Sun, 19 Oct 2008 17:00:52 -0700 Subject: [PATCH] doc: document the %[...] construct. Add documentation for the %[...] construct. Signed-off-by: H. Peter Anvin --- doc/nasmdoc.src | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/doc/nasmdoc.src b/doc/nasmdoc.src index 326ab412..79a036f0 100644 --- a/doc/nasmdoc.src +++ b/doc/nasmdoc.src @@ -2026,6 +2026,24 @@ as that is what the embedded macro \c{isTrue} expanded to at the time that \c{isFalse} was defined. +\S{indmacro} \i{Macro Indirection}: \I\c{%[}\c{%[...]} + +The \c{%[...]} construct can be used to expand macros in contexts +where macro expansion would otherwise not occur, including in the +names other macros. For example, if you have a set of macros named +\c{Foo16}, \c{Foo32} and \c{Foo64}, you could write: + +\c mov ax,Foo%[__BITS__] ; The Foo value + +to use the builtin macro \c{__BITS__} (see \k{bitsm}) to automatically +select between them. Similarly, the two statements: + +\c %xdefine Bar Quux ; Expands due to %xdefine +\c %define Bar %[Quux] ; Expands due to %[...] + +have, in fact, the exactly same effect. + + \S{concat%+} Concatenating Single Line Macro Tokens: \i\c{%+} Individual tokens in single line macros can be concatenated, to produce @@ -2097,6 +2115,7 @@ instruction has been used as a label in older code. For example: \c %idefine pause $%? ; Hide the PAUSE instruction + \S{undef} Undefining Single-Line Macros: \i\c{%undef} Single-line macros can be removed with the \c{%undef} directive. For