diff --git a/asm/nasm.c b/asm/nasm.c index 635ad92a..b5da1285 100644 --- a/asm/nasm.c +++ b/asm/nasm.c @@ -912,7 +912,8 @@ enum text_options { OPT_NO_LINE, OPT_DEBUG, OPT_INFO, - OPT_REPRODUCIBLE + OPT_REPRODUCIBLE, + OPT_BITS }; enum need_arg { ARG_NO, @@ -947,6 +948,7 @@ static const struct textargs textopts[] = { {"verbose", OPT_INFO , ARG_MAYBE, 0}, {"debug", OPT_DEBUG, ARG_MAYBE, 0}, {"reproducible", OPT_REPRODUCIBLE, ARG_NO, 0}, + {"bits", OPT_BITS, ARG_YES, 0}, {NULL, OPT_BOGUS, ARG_NO, 0} }; @@ -1301,6 +1303,10 @@ static bool process_arg(char *p, char *q, int pass) if (pass == 2) pp_pre_command("%pragma", param); break; + case OPT_BITS: + if (pass == 2) + pp_pre_command("BITS", param); + break; case OPT_BEFORE: if (pass == 2) pp_pre_command(NULL, param); @@ -2469,6 +2475,7 @@ static void help(FILE *out, const char *what) fputs( " --pragma str pre-executes a specific %pragma\n" " --before str add line (usually a preprocessor statement) before the input\n" + " --bits nn set bits to nn (equivalent to --before \"BITS nn\")\n" " --no-line ignore %line directives in input\n" " --prefix str prepend the given string to the names of all extern,\n" " common and global symbols (also --gprefix)\n" diff --git a/doc/changes.src b/doc/changes.src index 5563de9f..9bc00854 100644 --- a/doc/changes.src +++ b/doc/changes.src @@ -33,6 +33,9 @@ It is the production version of NASM since 2025. \b A new \c{%selbits()} preprocessor function. See \k{f_selbits}. +\b A new \c{--bits} option as convenience shorthand for \c{--before +"BITS ..."}. See \k{opt-bits}. + \S{cl-3.00} Version 3.00 diff --git a/doc/running.src b/doc/running.src index 421a4d1e..366b452e 100644 --- a/doc/running.src +++ b/doc/running.src @@ -556,12 +556,26 @@ is equivalent to the example in \k{opt-pfix}. See \k{pragma}. \S{opt-before} The \i\c{--before} Option -A preprocess statement can be accepted with this option. The example -shown in \k{opt-pragma} is the same as running this: +Insert a statement (usually, but not necessarily) a preprocess +statement before the input file. The example shown in \k{opt-pragma} +is the same as running this: \c nasm -f macho --before "%pragma macho gprefix _" +\S{opt-bits} The \i\c{--bits} Option + +Set the processor mode by inserting a \c{BITS} directive (kee +\k{bits}) before the input file. The following two statements are +exactly equivalent: + +\c nasm -f bin --bits 16 file.asm +\c nasm -f bin --before "BITS 16" file.asm + +The \c{--bits} option was introduced in NASM 3.01; the \c{--before} +form can be used for compatibility with older versions of NASM. + + \S{opt-limit} The \i\c{--limit-X} Option This option allows user to setup various maximum values after which