From 34501e12622f129ea112c9ca36251bae51eb32f5 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Tue, 3 Mar 2026 08:40:49 -0800 Subject: [PATCH] nasm.c: add the --bits option for compatibility with 3.0x To make it easier to run A:B testing against NASM 3.0x, which is the whole point of this branch, add the --bits option from NASM 3.0x. Signed-off-by: H. Peter Anvin --- asm/nasm.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/asm/nasm.c b/asm/nasm.c index e97a0af96..ba68c914b 100644 --- a/asm/nasm.c +++ b/asm/nasm.c @@ -947,7 +947,8 @@ enum text_options { OPT_KEEP_ALL, OPT_NO_LINE, OPT_DEBUG, - OPT_REPRODUCIBLE + OPT_REPRODUCIBLE, + OPT_BITS }; enum need_arg { ARG_NO, @@ -980,6 +981,7 @@ static const struct textargs textopts[] = { {"no-line", OPT_NO_LINE, ARG_NO, 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} }; @@ -1350,6 +1352,18 @@ static bool process_arg(char *p, char *q, int pass) case OPT_REPRODUCIBLE: reproducible = true; break; + case OPT_BITS: + if (pass == 2) { + int bits = strtoul(param, NULL, 10); + if (bits != 16 && bits != 32 && bits != 64) { + nasm_nonfatalf(ERR_USAGE, "invalid argument to --bits"); + } else { + char cmdbuf[16]; + snprintf(cmdbuf,sizeof(cmdbuf),"[bits %d]", bits); + pp_pre_command(NULL, cmdbuf); + } + } + break; case OPT_HELP: /* Allow --help topic without *requiring* topic */ if (!param)