nasmdoc: Document macro parameters range

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
Cyrill Gorcunov 2010-06-05 11:24:59 +04:00
parent 2f40375077
commit 640edfd784

View file

@ -2558,6 +2558,48 @@ definition.
See \k{sectmac} for a better way to write the above macro.
\S{mlmacrange} \i{Macro Parameters Range}
NASM also allows you to expand parameters via special construction \c{%\{x:y\}}
where \c{x} is the first parameter index and \c{y} is the last. Any index can
be either negative or positive. Though the indices must never be zero.
For example
\c %macro mpar 1-*
\c db %{3:5}
\c %endmacro
\c
\c mpar 1,2,3,4,5,6
expands to \c{3,4,5} range.
Even more, the parameters can be reversed so that
\c %macro mpar 1-*
\c db %{5:3}
\c %endmacro
\c
\c mpar 1,2,3,4,5,6
expands to \c{5,4,3} range.
But even this is not the last. The parameters can be addressed via negative
indices so NASM will count them reversed. The ones who know Python may see
the analogue here.
\c %macro mpar 1-*
\c db %{-1:-3}
\c %endmacro
\c
\c mpar 1,2,3,4,5,6
expands to \c{6,5,4} range.
Note that NASM uses \i{comma} to separate parameters being expanded.
By the way, here is a trick - you might use the index \c{%{-1:-1}} gives
you the \i{last} argument passed to a macro.
\S{mlmacdef} \i{Default Macro Parameters}