mirror of
https://github.com/netwide-assembler/nasm
synced 2026-08-26 16:23:04 -04:00
listing: add __?LIST_OPTIONS?__ and __?LIST_OPTIONS_DEFAULT?__ macros
Add macros to query the current state of the listing options, add appropriate documentation. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
parent
06f9a1855e
commit
9969b34454
4 changed files with 97 additions and 9 deletions
|
|
@ -8257,6 +8257,37 @@ err:
|
|||
return make_tok_num(NULL, val);
|
||||
}
|
||||
|
||||
/*
|
||||
* Given the currently default or command-line default listing options
|
||||
*/
|
||||
static Token *
|
||||
get_list_options(uint64_t optmask)
|
||||
{
|
||||
static const char optchars[63] =
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
char optbuf[65], *p;
|
||||
unsigned int i;
|
||||
|
||||
p = optbuf;
|
||||
for (i = 0; i < 62; i++) {
|
||||
if (optmask & 4)
|
||||
*p++ = optchars[i];
|
||||
optmask >>= 1;
|
||||
}
|
||||
*p = '\0';
|
||||
|
||||
return make_tok_qstr_len(NULL, optbuf, p-optbuf);
|
||||
}
|
||||
|
||||
static Token *
|
||||
stdmac_list_options(const SMacro *s, Token **params, int nparam)
|
||||
{
|
||||
(void)s;
|
||||
(void)params;
|
||||
(void)nparam;
|
||||
return get_list_options(active_list_options);
|
||||
}
|
||||
|
||||
/*
|
||||
* Wrapper around define_smacro() which also checks to see if it is
|
||||
* a preprocessor directive, so that pp_op_may_be_function[] needs to
|
||||
|
|
@ -8295,6 +8326,7 @@ static void pp_add_magic_simple(void)
|
|||
{ "__?BITS?__", true, 0, 0, stdmac_bits },
|
||||
{ "__?PTR?__", true, 0, 0, stdmac_ptr },
|
||||
{ "__?DEFAULT?__", true, 0, 0, stdmac_default },
|
||||
{ "__?LIST_OPTIONS?__", true, 0, 0, stdmac_list_options },
|
||||
{ "%abs", false, 1, SPARM_EVAL, stdmac_abs },
|
||||
{ "%chr", false, 1, SPARM_EVAL|SPARM_OPTIONAL|SPARM_VARADIC, stdmac_chr },
|
||||
{ "%count", false, 1, SPARM_VARADIC, stdmac_count },
|
||||
|
|
@ -8552,6 +8584,12 @@ static void pp_add_limits_stdmac(void)
|
|||
define_smacro("__?NASM_LIMITS?__", true, t, NULL);
|
||||
}
|
||||
|
||||
static void pp_add_list_options_default_stdmac(void)
|
||||
{
|
||||
define_smacro("__?LIST_OPTIONS_DEFAULT?__", true,
|
||||
get_list_options(cmdline_list_options), NULL);
|
||||
}
|
||||
|
||||
static void pp_reset_stdmac(enum preproc_mode mode)
|
||||
{
|
||||
int apass;
|
||||
|
|
@ -8569,6 +8607,7 @@ static void pp_reset_stdmac(enum preproc_mode mode)
|
|||
|
||||
pp_add_limits_stdmac();
|
||||
|
||||
pp_add_list_options_default_stdmac();
|
||||
do_predef = true;
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -133,10 +133,17 @@ It is the production version of NASM since 2025.
|
|||
\b Fix a crash when \c{-M} directives were used in response files.
|
||||
|
||||
\b New listing option \c{-Lc} to include the contents of \c{INCBIN}
|
||||
files.
|
||||
files, see \k{opt-L}.
|
||||
|
||||
\b New listing option \c{-Lt} to include the output from every
|
||||
iteration of \c{TIMES} and \c{ALIGN} directives.
|
||||
iteration of \c{TIMES} and \c{ALIGN} directives, see \k{opt-L}.
|
||||
|
||||
\b The \c{%pragma list options} directive now support resetting
|
||||
options to their command-line default, see \k{opt-L}.
|
||||
|
||||
\b New predefined macros \c{__?LIST_OPTIONS?__} and
|
||||
\c{__?LIST_OPTIONS_DEFAULT?__} to query the active and command-line
|
||||
default listing options. See \k{opt-L}.
|
||||
|
||||
|
||||
\S{cl-3.01} Version 3.01
|
||||
|
|
|
|||
|
|
@ -138,24 +138,52 @@ bug reporting), and not likely to be otherwise useful:
|
|||
|
||||
\b \c{-L!} enable \e{all} listing options including debugging ones
|
||||
|
||||
For forward compatility reasons, an undefined flag will be
|
||||
ignored. Thus, a new flag introduced in a newer version of NASM can be
|
||||
specified without breaking older versions. Listing flags will always
|
||||
be a single alphanumeric character and are case sensitive.
|
||||
|
||||
These options can be enabled or disabled at runtime using the
|
||||
\c{%pragma list options} directive:
|
||||
|
||||
\c %pragma list options [+|-]flags...
|
||||
\c %pragma list options [+|-|*]{!|flags}...
|
||||
|
||||
\c{+}, \c{-} and \c{*} adds, removes, or restores to the command-line
|
||||
default the flags that follow.
|
||||
|
||||
For example, to turn on the \c{d} and \c{m} flags but disable the
|
||||
\c{s} flag:
|
||||
|
||||
\c %pragma list options +dm -s
|
||||
|
||||
The \c{+} and \c{!} shorthands available in on the command line are
|
||||
The \c{+} and \c{++} shorthands available in on the command line are
|
||||
not available when using \c{%pragma list options}; each listing option
|
||||
needs to be specified explicitly.
|
||||
needs to be specified explicitly, or \c{!} can be used to specify all
|
||||
options.
|
||||
|
||||
For forward compatility reasons, an undefined flag will be
|
||||
ignored. Thus, a new flag introduced in a newer version of NASM can be
|
||||
specified without breaking older versions. Listing flags will always
|
||||
be a single alphanumeric character and are case sensitive.
|
||||
Spaces, quotation marks, and commas in the argument are explicitly
|
||||
ignored; thus, specifying the options as one or more quoted strings is
|
||||
valid.
|
||||
|
||||
The built-in macros \i\c{__?LIST_OPTIONS?__} and
|
||||
\i\c{__?LIST_OPTIONS_DEFAULT?__} contain the currently active and the
|
||||
command-line default listing options, respectively, as quoted strings.
|
||||
|
||||
To save and restore the listing options, one can use:
|
||||
|
||||
\c %macro ...
|
||||
\c %define %%saved_list_options __?LIST_OPTIONS?__
|
||||
\c ; ... do stuff with special listing options ...
|
||||
\c %pragma list options -! +%%saved_list_options
|
||||
\c %endmacro
|
||||
|
||||
The statement:
|
||||
|
||||
\c %pragma list options -! +__?LIST_OPTIONS_DEFAULT?__
|
||||
|
||||
... is exactly equivalent to ...
|
||||
|
||||
\c %pragma list options *!
|
||||
|
||||
\S{opt-M} The \i\c{-M} Option: Generate \i{Makefile Dependencies}
|
||||
|
||||
|
|
|
|||
|
|
@ -227,6 +227,20 @@ For example, if the \c{altreg} package is included (see
|
|||
|
||||
See also the \c{%ifusable} and \c{%ifusing} directives, \k{ifusing}.
|
||||
|
||||
|
||||
\H{list_options_macro} \i\c{__?LIST_OPTIONS?__}: Current Listing Options
|
||||
|
||||
Contains a quoted string with the listing options currently in
|
||||
effect. See \k{opt-L}.
|
||||
|
||||
|
||||
\H{list_options_default_macro} \i\c{__?LIST_OPTIONS_DEFAULT?__}:
|
||||
Default Listing Options
|
||||
|
||||
Contains a quoted string with the listing options originally specified
|
||||
by the user on the command line. See \k{opt-L}.
|
||||
|
||||
|
||||
\H{pass_macro} \i\c{__?PASS?__}: Assembly Pass
|
||||
|
||||
The macro \c{__?PASS?__} is defined to be \c{1} on preparatory passes,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue