From: Cyrill Gorcunov Date: Sat, 5 Jun 2010 07:24:59 +0000 (+0400) Subject: nasmdoc: Document macro parameters range X-Git-Tag: nasm-2.11.05~616 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=640edfd78490a40c0544d4eba406bded5d32542a;p=platform%2Fupstream%2Fnasm.git nasmdoc: Document macro parameters range Signed-off-by: Cyrill Gorcunov --- diff --git a/doc/nasmdoc.src b/doc/nasmdoc.src index 8b6fb2d..fb62825 100644 --- a/doc/nasmdoc.src +++ b/doc/nasmdoc.src @@ -1,5 +1,5 @@ \# -------------------------------------------------------------------------- -\# +\# \# Copyright 1996-2010 The NASM Authors - All Rights Reserved \# See the file AUTHORS included with the NASM distribution for \# the specific copyright holders. @@ -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}