Skip to content

Commit e7dd0e8

Browse files
author
H. Peter Anvin
committed
doc: document the %num() function
Add documentation for the %num() preprocessor function. Signed-off-by: H. Peter Anvin <[email protected]>
1 parent 1d1ba9c commit e7dd0e8

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

doc/nasmdoc.src

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,6 +2255,17 @@ and \i{detokenization} are performed for the arguments of the
22552255
directives.
22562256

22572257

2258+
\S{pcdirect} \i{Directives} processing
2259+
2260+
Remaining preprocessor \i{directives} are processed. It is specific
2261+
to each directive to what extend the above expansions or the ones
2262+
specified in \k{pcfinal} are performed on their arguments.
2263+
2264+
It is specific to each directive to what extent \i{inline expansions}
2265+
and \i{detokenization} are performed for the arguments of the
2266+
directives.
2267+
2268+
22582269
\S{pcsmacro} \i{Inline expansions} and other \I{preprocessor directives}directives
22592270

22602271
In this step, the following expansions are performed on each line:
@@ -2276,10 +2287,6 @@ below), the parameters to that macro are expanded at this time. See
22762287
\b \i{Macro-local labels} are converted into unique strings, see
22772288
\k{maclocal}.
22782289

2279-
\b Remaining preprocessor \i{directives} are processed. It is specific
2280-
to each directive to what extend the above expansions or the ones
2281-
specified in \k{pcfinal} are performed on their arguments.
2282-
22832290

22842291
\S{pcmmacro} \i{Multi-Line Macro Expansion}
22852292

@@ -2923,6 +2930,26 @@ argument to the conditional using \c{\{\}}:
29232930
\c %endif
29242931

29252932

2933+
\S{f_num} \i\c{%num()} Function
2934+
2935+
The \c{%num()} function evaluates its arguments as expressions, and
2936+
then produces a quoted string encoding the first argument as an
2937+
\e{unsigned} integer. The second argument is the encoding base (from 2
2938+
to 64, default 10) and the third argument is the desired number of
2939+
digits (max 253, default -1).
2940+
2941+
Only the first argument is required.
2942+
2943+
If the number of digits is negative, NASM will add additional digits
2944+
if needed, if positive the string is truncated to the number of digits
2945+
specified. 0 is treated as -1, except that the input number 0
2946+
generates an empty string (thus, the first digit will never be zero.)
2947+
2948+
The full 64-symbol set used is, in order:
2949+
2950+
\c 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@_
2951+
2952+
29262953
\S{f_sel} \i\c{%sel()} Function
29272954

29282955
The \c{%sel()} function evaluates its first argument as an

0 commit comments

Comments
 (0)