From d235408c65fc8176fdd94dd9f7d49074828bfa86 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Tue, 27 Aug 2019 16:38:48 -0700 Subject: [PATCH] preproc: standard macros now C-safe, %aliases off, fix %? recursion Enough users expect the namespace starting with underscore to be safe for symbols. Change our private namespace from __foo__ to __?foo?__. Use %defalias to provide backwards compatiblity (by using %defalias instead of %define, we handle the case properly where the user changes the value.) Add a preprocessor directive: %aliases off ... to disable all smacro aliases and thereby making the namespace clean. Finally, fix infinite recursion when seeing %? or %?? due to paste_tokens(). If we don't paste anything, the expansion is done. Signed-off-by: H. Peter Anvin --- asm/float.c | 10 +- asm/nasm.c | 22 ++--- asm/pptok.dat | 1 + asm/preproc.c | 99 ++++++++++++++++--- asm/tokens.dat | 62 ++++++------ asm/tokhash.pl | 6 +- doc/nasmdoc.src | 180 +++++++++++++++++----------------- include/nasm.h | 8 +- macros/fp.mac | 24 ++--- macros/ifunc.mac | 14 +-- macros/macros.pl | 4 +- macros/masm.mac | 8 +- macros/smartalign.mac | 222 +++++++++++++++++++++--------------------- macros/standard.mac | 138 +++++++++++++++++++++----- output/outaout.mac | 4 +- output/outas86.mac | 4 +- output/outbin.mac | 4 +- output/outcoff.mac | 4 +- output/outdbg.mac | 4 +- output/outelf.mac | 4 +- output/outmacho.mac | 8 +- output/outobj.mac | 4 +- output/outrdf.mac | 4 +- output/outrdf2.mac | 4 +- version.pl | 28 +++--- 25 files changed, 519 insertions(+), 351 deletions(-) diff --git a/asm/float.c b/asm/float.c index 3ae59f0e7..77d576c67 100644 --- a/asm/float.c +++ b/asm/float.c @@ -737,18 +737,18 @@ static int to_float(const char *str, int s, uint8_t *result, if (str[0] == '_') { /* Special tokens */ - switch (str[2]) { - case 'n': /* __nan__ */ + switch (str[3]) { + case 'n': /* __?nan?__ */ case 'N': - case 'q': /* __qnan__ */ + case 'q': /* __?qnan?__ */ case 'Q': type = FL_QNAN; break; - case 's': /* __snan__ */ + case 's': /* __?snan?__ */ case 'S': type = FL_SNAN; break; - case 'i': /* __infinity__ */ + case 'i': /* __?infinity?__ */ case 'I': type = FL_INFINITY; break; diff --git a/asm/nasm.c b/asm/nasm.c index 4cf6f2ab0..fd700df2a 100644 --- a/asm/nasm.c +++ b/asm/nasm.c @@ -299,29 +299,29 @@ static void define_macros(void) char temp[128]; if (oct->have_local) { - strftime(temp, sizeof temp, "__DATE__=\"%Y-%m-%d\"", &oct->local); + strftime(temp, sizeof temp, "__?DATE?__=\"%Y-%m-%d\"", &oct->local); preproc->pre_define(temp); - strftime(temp, sizeof temp, "__DATE_NUM__=%Y%m%d", &oct->local); + strftime(temp, sizeof temp, "__?DATE_NUM?__=%Y%m%d", &oct->local); preproc->pre_define(temp); - strftime(temp, sizeof temp, "__TIME__=\"%H:%M:%S\"", &oct->local); + strftime(temp, sizeof temp, "__?TIME?__=\"%H:%M:%S\"", &oct->local); preproc->pre_define(temp); - strftime(temp, sizeof temp, "__TIME_NUM__=%H%M%S", &oct->local); + strftime(temp, sizeof temp, "__?TIME_NUM?__=%H%M%S", &oct->local); preproc->pre_define(temp); } if (oct->have_gm) { - strftime(temp, sizeof temp, "__UTC_DATE__=\"%Y-%m-%d\"", &oct->gm); + strftime(temp, sizeof temp, "__?UTC_DATE?__=\"%Y-%m-%d\"", &oct->gm); preproc->pre_define(temp); - strftime(temp, sizeof temp, "__UTC_DATE_NUM__=%Y%m%d", &oct->gm); + strftime(temp, sizeof temp, "__?UTC_DATE_NUM?__=%Y%m%d", &oct->gm); preproc->pre_define(temp); - strftime(temp, sizeof temp, "__UTC_TIME__=\"%H:%M:%S\"", &oct->gm); + strftime(temp, sizeof temp, "__?UTC_TIME?__=\"%H:%M:%S\"", &oct->gm); preproc->pre_define(temp); - strftime(temp, sizeof temp, "__UTC_TIME_NUM__=%H%M%S", &oct->gm); + strftime(temp, sizeof temp, "__?UTC_TIME_NUM?__=%H%M%S", &oct->gm); preproc->pre_define(temp); } if (oct->have_posix) { - snprintf(temp, sizeof temp, "__POSIX_TIME__=%"PRId64, oct->posix); + snprintf(temp, sizeof temp, "__?POSIX_TIME?__=%"PRId64, oct->posix); preproc->pre_define(temp); } @@ -330,7 +330,7 @@ static void define_macros(void) * we have to put shortname of the alias itself here * otherwise ABI backward compatibility gets broken. */ - snprintf(temp, sizeof(temp), "__OUTPUT_FORMAT__=%s", + snprintf(temp, sizeof(temp), "__?OUTPUT_FORMAT?__=%s", ofmt_alias ? ofmt_alias->shortname : ofmt->shortname); preproc->pre_define(temp); @@ -344,7 +344,7 @@ static void define_macros(void) * Debug format, if any */ if (dfmt != &null_debug_form) { - snprintf(temp, sizeof(temp), "__DEBUG_FORMAT__=%s", dfmt->shortname); + snprintf(temp, sizeof(temp), "__?DEBUG_FORMAT?__=%s", dfmt->shortname); preproc->pre_define(temp); } } diff --git a/asm/pptok.dat b/asm/pptok.dat index 45610958b..bb908a318 100644 --- a/asm/pptok.dat +++ b/asm/pptok.dat @@ -70,6 +70,7 @@ %un!macro # Other directives +%aliases %arg %clear %depend diff --git a/asm/preproc.c b/asm/preproc.c index c8d86656c..694527dc5 100644 --- a/asm/preproc.c +++ b/asm/preproc.c @@ -444,6 +444,7 @@ static int LocalOffset = 0; static Context *cstk; static Include *istk; static const struct strlist *ipath_list; +static bool do_aliases; static struct strlist *deplist; @@ -1602,6 +1603,55 @@ static int ppscan(void *private_data, struct tokenval *tokval) return tokval->t_type = tline->text[0]; } +/* + * 1. An expression (true if nonzero 0) + * 2. The keywords true, on, yes for true + * 3. The keywords false, off, no for false + * 4. An empty line, for true + * + * On error, return defval (usually the previous value) + */ +static bool pp_get_boolean_option(Token *tline, bool defval) +{ + static const char * const noyes[] = { + "no", "yes", + "false", "true", + "off", "on" + }; + struct ppscan pps; + struct tokenval tokval; + expr *evalresult; + + skip_white_(tline); + if (!tline || !tline->type) + return true; + + if (tline->type == TOK_ID) { + size_t i; + for (i = 0; i < ARRAY_SIZE(noyes); i++) + if (!nasm_stricmp(tline->text, noyes[i])) + return i & 1; + } + + pps.tptr = NULL; + pps.tptr = tline; + pps.ntokens = -1; + tokval.t_type = TOKEN_INVALID; + evalresult = evaluate(ppscan, &pps, &tokval, NULL, true, NULL); + + if (!evalresult) + return true; + + if (tokval.t_type) + nasm_warn(WARN_OTHER, "trailing garbage after expression ignored"); + if (!is_really_simple(evalresult)) { + nasm_nonfatal("boolean flag expression must be a constant"); + return defval; + } + + return reloc_value(evalresult) != 0; +} + /* * Compare a string to the name of an existing macro; this is a * simple wrapper which calls either strcmp or nasm_stricmp @@ -1801,7 +1851,7 @@ FILE *pp_input_fopen(const char *filename, enum file_flags mode) */ static bool smacro_defined(Context * ctx, const char *name, int nparam, SMacro ** defn, - bool nocase) + bool nocase, bool find_alias) { struct hash_table *smtbl; SMacro *m; @@ -1817,12 +1867,22 @@ smacro_defined(Context * ctx, const char *name, int nparam, SMacro ** defn, } else { smtbl = &smacros; } + +restart: m = (SMacro *) hash_findix(smtbl, name); while (m) { if (!mstrcmp(m->name, name, m->casesense && nocase) && (nparam <= 0 || m->nparam == 0 || nparam == m->nparam || (m->greedy && nparam >= m->nparam-1))) { + if (m->alias && !find_alias) { + if (do_aliases) { + name = m->name; + goto restart; + } else { + continue; + } + } if (defn) { *defn = (nparam == m->nparam || nparam == -1) ? m : NULL; } @@ -1963,7 +2023,7 @@ static enum cond_state if_condition(Token * tline, enum preproc_token ct) dname); goto fail; } - if (smacro_defined(NULL, tline->text, 0, NULL, true)) + if (smacro_defined(NULL, tline->text, 0, NULL, true, false)) j = true; tline = tline->next; } @@ -2460,7 +2520,7 @@ static SMacro *define_smacro(const char *mname, bool casesense, while (1) { ctx = get_ctx(mname, &mname); - if (!smacro_defined(ctx, mname, nparam, &smac, casesense)) { + if (!smacro_defined(ctx, mname, nparam, &smac, casesense, true)) { /* Create a new macro */ smtbl = ctx ? &ctx->localmac : &smacros; smhead = (SMacro **) hash_findi_add(smtbl, mname); @@ -2476,7 +2536,7 @@ static SMacro *define_smacro(const char *mname, bool casesense, * some others didn't. What is the right thing to do here? */ goto fail; - } else if (!smac->alias || defining_alias) { + } else if (!smac->alias || !do_aliases || defining_alias) { /* * We're redefining, so we have to take over an * existing SMacro structure. This means freeing @@ -2545,6 +2605,8 @@ static void undef_smacro(const char *mname, bool undefalias) while ((s = *sp) != NULL) { if (!mstrcmp(s->name, mname, s->casesense)) { if (s->alias && !undefalias) { + if (!do_aliases) + continue; if (s->in_progress) { nasm_nonfatal("macro alias loop"); } else { @@ -3916,6 +3978,12 @@ static int do_directive(Token *tline, Token **output) define_smacro(mname, casesense, macro_start, NULL); break; + case PP_ALIASES: + tline = tline->next; + tline = expand_smacro(tline); + do_aliases = pp_get_boolean_option(tline, do_aliases); + break; + case PP_LINE: /* * Syntax is `%line nnn[+mmm] [filename]' @@ -4371,7 +4439,7 @@ static Token *expand_mmac_params(Token * tline) cc = find_cc(tt); if (cc == -1) { nasm_nonfatal("macro parameter `%s' is not a condition code", - text); + t->text); text = NULL; break; } @@ -4534,6 +4602,8 @@ static SMacro *expand_one_smacro(Token ***tpp) * checking for parameters if necessary. */ list_for_each(m, head) { + if (unlikely(m->alias && !do_aliases)) + continue; if (!mstrcmp(m->name, mname, m->casesense)) break; } @@ -4986,8 +5056,10 @@ static Token *expand_smacro_noreset(Token * tline) * Also we look for %+ tokens and concatenate the tokens * before and after them (without white spaces in between). */ - paste_tokens(&thead, tmatch, ARRAY_SIZE(tmatch), true); - + if (!paste_tokens(&thead, tmatch, ARRAY_SIZE(tmatch), true)) { + tline = thead; + break; + } expanded = false; } @@ -5578,10 +5650,10 @@ struct magic_macros { }; static const struct magic_macros magic_macros[] = { - { "__FILE__", 0, stdmac_file }, - { "__LINE__", 0, stdmac_line }, - { "__BITS__", 0, stdmac_bits }, - { "__PTR__", 0, stdmac_ptr }, + { "__?FILE?__", 0, stdmac_file }, + { "__?LINE?__", 0, stdmac_line }, + { "__?BITS?__", 0, stdmac_bits }, + { "__?PTR?__", 0, stdmac_ptr }, { NULL, 0, NULL } }; @@ -5613,6 +5685,7 @@ pp_reset(const char *file, enum preproc_mode mode, struct strlist *dep_list) unique = 0; deplist = dep_list; pp_mode = mode; + do_aliases = true; if (!use_loaded) use_loaded = nasm_malloc(use_package_count * sizeof(bool)); @@ -5656,7 +5729,7 @@ pp_reset(const char *file, enum preproc_mode mode, struct strlist *dep_list) do_predef = true; /* - * Define the __PASS__ macro. This is defined here unlike all the + * Define the __?PASS?__ macro. This is defined here unlike all the * other builtins, because it is special -- it varies between * passes -- but there is really no particular reason to make it * magic. @@ -5680,7 +5753,7 @@ pp_reset(const char *file, enum preproc_mode mode, struct strlist *dep_list) panic(); } - define_smacro("__PASS__", true, make_tok_num(apass), NULL); + define_smacro("__?PASS?__", true, make_tok_num(apass), NULL); } static void pp_init(void) diff --git a/asm/tokens.dat b/asm/tokens.dat index d75640cf5..ad26420d2 100644 --- a/asm/tokens.dat +++ b/asm/tokens.dat @@ -92,42 +92,42 @@ to ptr % TOKEN_FLOAT, 0, 0, 0 -__infinity__ -__nan__ -__qnan__ -__snan__ - -% TOKEN_FLOATIZE, 0, 0, FLOAT_{__float*__} -__float8__ -__float16__ -__float32__ -__float64__ -__float80m__ -__float80e__ -__float128l__ -__float128h__ - -% TOKEN_STRFUNC, 0, 0, STRFUNC_{__*__} -__utf16__ -__utf16le__ -__utf16be__ -__utf32__ -__utf32le__ -__utf32be__ - -% TOKEN_IFUNC, 0, 0, IFUNC_{__*__} -__ilog2e__ -__ilog2w__ -__ilog2f__ -__ilog2c__ +__?infinity?__ +__?nan?__ +__?qnan?__ +__?snan?__ + +% TOKEN_FLOATIZE, 0, 0, FLOAT_{__?float*?__} +__?float8?__ +__?float16?__ +__?float32?__ +__?float64?__ +__?float80m?__ +__?float80e?__ +__?float128l?__ +__?float128h?__ + +% TOKEN_STRFUNC, 0, 0, STRFUNC_{__?*?__} +__?utf16?__ +__?utf16le?__ +__?utf16be?__ +__?utf32?__ +__?utf32le?__ +__?utf32be?__ + +% TOKEN_IFUNC, 0, 0, IFUNC_{__?*?__} +__?ilog2e?__ +__?ilog2w?__ +__?ilog2f?__ +__?ilog2c?__ % TOKEN_*, 0, 0, 0 seg wrt -% TOKEN_{__*__}, 0, 0, 0 -__masm_ptr__ -__masm_flat__ +% TOKEN_{__?*?__}, 0, 0, 0 +__?masm_ptr?__ +__?masm_flat?__ % TOKEN_DECORATOR, 0, TFLAG_BRC | TFLAG_BRDCAST , BRC_1TO{1to*} 1to2 diff --git a/asm/tokhash.pl b/asm/tokhash.pl index 4636e12e9..f831265bb 100755 --- a/asm/tokhash.pl +++ b/asm/tokhash.pl @@ -57,7 +57,7 @@ # open(ID, '<', $insns_dat) or die "$0: cannot open $insns_dat: $!\n"; while (defined($line = )) { - if ($line =~ /^([A-Z0-9_]+)(|cc)\s/) { + if ($line =~ /^([\?\@A-Z0-9_]+)(|cc)\s/) { $insn = $1.$2; ($token = $1) =~ tr/A-Z/a-z/; @@ -88,7 +88,7 @@ # open(RD, '<', $regs_dat) or die "$0: cannot open $regs_dat: $!\n"; while (defined($line = )) { - if ($line =~ /^([a-z0-9_-]+)\s*\S+\s*\S+\s*[0-9]+\s*(\S*)/) { + if ($line =~ /^([\?\@a-z0-9_-]+)\s*\S+\s*\S+\s*[0-9]+\s*(\S*)/) { $reg = $1; $reg_flag = $2; @@ -144,6 +144,7 @@ my $head = $1, $tail = $3; my $px = $2; + $px =~ s/\?/\\?/g; $px =~ s/\*/(.*)/g; if ($token =~ /$px/i) { $data = $head."\U$1".$tail; @@ -153,6 +154,7 @@ } $data =~ s/\*/\U$token/g; + $data =~ s/\?//g; push(@tokendata, "\"$token\", ".length($token).", $data"); } diff --git a/doc/nasmdoc.src b/doc/nasmdoc.src index cb6fdc6a4..f7df6cc94 100644 --- a/doc/nasmdoc.src +++ b/doc/nasmdoc.src @@ -1558,17 +1558,17 @@ operands to \c{DW}, and so forth. \S{unicode} \I{UTF-16}\I{UTF-32}\i{Unicode} Strings -The special operators \i\c{__utf16__}, \i\c{__utf16le__}, -\i\c{__utf16be__}, \i\c{__utf32__}, \i\c{__utf32le__} and -\i\c{__utf32be__} allows definition of Unicode strings. They take a +The special operators \i\c{__?utf16?__}, \i\c{__?utf16le?__}, +\i\c{__?utf16be?__}, \i\c{__?utf32?__}, \i\c{__?utf32le?__} and +\i\c{__?utf32be?__} allows definition of Unicode strings. They take a string in UTF-8 format and converts it to UTF-16 or UTF-32, respectively. Unless the \c{be} forms are specified, the output is littleendian. For example: -\c %define u(x) __utf16__(x) -\c %define w(x) __utf32__(x) +\c %define u(x) __?utf16?__(x) +\c %define w(x) __?utf32?__(x) \c \c dw u('C:\WINDOWS'), 0 ; Pathname in UTF-16 \c dd w(`A + B = \u206a`), 0 ; String in UTF-32 @@ -1581,10 +1581,10 @@ context. \i{Floating-point} constants are acceptable only as arguments to \i\c{DB}, \i\c{DW}, \i\c{DD}, \i\c{DQ}, \i\c{DT}, and \i\c{DO}, or as -arguments to the special operators \i\c{__float8__}, -\i\c{__float16__}, \i\c{__float32__}, \i\c{__float64__}, -\i\c{__float80m__}, \i\c{__float80e__}, \i\c{__float128l__}, and -\i\c{__float128h__}. +arguments to the special operators \i\c{__?float8?__}, +\i\c{__?float16?__}, \i\c{__?float32?__}, \i\c{__?float64?__}, +\i\c{__?float80m?__}, \i\c{__?float80e?__}, \i\c{__?float128l?__}, and +\i\c{__?float128h?__}. Floating-point constants are expressed in the traditional form: digits, then a period, then optionally more digits, then optionally an @@ -1626,15 +1626,15 @@ called a "\i{minifloat}." The special operators are used to produce floating-point numbers in other contexts. They produce the binary representation of a specific floating-point number as an integer, and can use anywhere integer -constants are used in an expression. \c{__float80m__} and -\c{__float80e__} produce the 64-bit mantissa and 16-bit exponent of an -80-bit floating-point number, and \c{__float128l__} and -\c{__float128h__} produce the lower and upper 64-bit halves of a 128-bit +constants are used in an expression. \c{__?float80m?__} and +\c{__?float80e?__} produce the 64-bit mantissa and 16-bit exponent of an +80-bit floating-point number, and \c{__?float128l?__} and +\c{__?float128h?__} produce the lower and upper 64-bit halves of a 128-bit floating-point number, respectively. For example: -\c mov rax,__float64__(3.141592653589793238462) +\c mov rax,__?float64?__(3.141592653589793238462) ... would assign the binary representation of pi as a 64-bit floating point number into \c{RAX}. This is exactly equivalent to: @@ -1651,13 +1651,13 @@ do floating arithmetic it would have to include its own complete set of floating-point routines, which would significantly increase the size of the assembler for very little benefit. -The special tokens \i\c{__Infinity__}, \i\c{__QNaN__} (or -\i\c{__NaN__}) and \i\c{__SNaN__} can be used to generate +The special tokens \i\c{__?Infinity?__}, \i\c{__?QNaN?__} (or +\i\c{__?NaN?__}) and \i\c{__?SNaN?__} can be used to generate \I{infinity}infinities, quiet \i{NaN}s, and signalling NaNs, respectively. These are normally used as macros: -\c %define Inf __Infinity__ -\c %define NaN __QNaN__ +\c %define Inf __?Infinity?__ +\c %define NaN __?QNaN?__ \c \c dq +1.5, -Inf, NaN ; Double-precision constants @@ -2104,9 +2104,9 @@ where macro expansion would otherwise not occur, including in the names other macros. For example, if you have a set of macros named \c{Foo16}, \c{Foo32} and \c{Foo64}, you could write: -\c mov ax,Foo%[__BITS__] ; The Foo value +\c mov ax,Foo%[__?BITS?__] ; The Foo value -to use the builtin macro \c{__BITS__} (see \k{bitsm}) to automatically +to use the builtin macro \c{__?BITS?__} (see \k{bitsm}) to automatically select between them. Similarly, the two statements: \c %xdefine Bar Quux ; Expands due to %xdefine @@ -3756,24 +3756,24 @@ described here. \S{stdmacver} \i{NASM Version} Macros -The single-line macros \i\c{__NASM_MAJOR__}, \i\c{__NASM_MINOR__}, -\i\c{__NASM_SUBMINOR__} and \i\c{___NASM_PATCHLEVEL__} expand to the +The single-line macros \i\c{__?NASM_MAJOR?__}, \i\c{__?NASM_MINOR?__}, +\i\c{__?NASM_SUBMINOR?__} and \i\c{__?_NASM_PATCHLEVEL?__} expand to the major, minor, subminor and patch level parts of the \i{version number of NASM} being used. So, under NASM 0.98.32p1 for -example, \c{__NASM_MAJOR__} would be defined to be 0, \c{__NASM_MINOR__} -would be defined as 98, \c{__NASM_SUBMINOR__} would be defined to 32, -and \c{___NASM_PATCHLEVEL__} would be defined as 1. +example, \c{__?NASM_MAJOR?__} would be defined to be 0, \c{__?NASM_MINOR?__} +would be defined as 98, \c{__?NASM_SUBMINOR?__} would be defined to 32, +and \c{__?_NASM_PATCHLEVEL?__} would be defined as 1. -Additionally, the macro \i\c{__NASM_SNAPSHOT__} is defined for +Additionally, the macro \i\c{__?NASM_SNAPSHOT?__} is defined for automatically generated snapshot releases \e{only}. -\S{stdmacverid} \i\c{__NASM_VERSION_ID__}: \i{NASM Version ID} +\S{stdmacverid} \i\c{__?NASM_VERSION_ID?__}: \i{NASM Version ID} -The single-line macro \c{__NASM_VERSION_ID__} expands to a dword integer +The single-line macro \c{__?NASM_VERSION_ID?__} expands to a dword integer representing the full version number of the version of nasm being used. -The value is the equivalent to \c{__NASM_MAJOR__}, \c{__NASM_MINOR__}, -\c{__NASM_SUBMINOR__} and \c{___NASM_PATCHLEVEL__} concatenated to +The value is the equivalent to \c{__?NASM_MAJOR?__}, \c{__?NASM_MINOR?__}, +\c{__?NASM_SUBMINOR?__} and \c{__?_NASM_PATCHLEVEL?__} concatenated to produce a single doubleword. Hence, for 0.98.32p1, the returned number would be equivalent to: @@ -3788,29 +3788,29 @@ line is used just to give an indication of the order that the separate values will be present in memory. -\S{stdmacverstr} \i\c{__NASM_VER__}: \i{NASM Version string} +\S{stdmacverstr} \i\c{__?NASM_VER?__}: \i{NASM Version string} -The single-line macro \c{__NASM_VER__} expands to a string which defines +The single-line macro \c{__?NASM_VER?__} expands to a string which defines the version number of nasm being used. So, under NASM 0.98.32 for example, -\c db __NASM_VER__ +\c db __?NASM_VER?__ would expand to \c db "0.98.32" -\S{fileline} \i\c{__FILE__} and \i\c{__LINE__}: File Name and Line Number +\S{fileline} \i\c{__?FILE?__} and \i\c{__?LINE?__}: File Name and Line Number Like the C preprocessor, NASM allows the user to find out the file name and line number containing the current instruction. The macro -\c{__FILE__} expands to a string constant giving the name of the +\c{__?FILE?__} expands to a string constant giving the name of the current input file (which may change through the course of assembly -if \c{%include} directives are used), and \c{__LINE__} expands to a +if \c{%include} directives are used), and \c{__?LINE?__} expands to a numeric constant giving the current line number in the input file. These macros could be used, for example, to communicate debugging -information to a macro, since invoking \c{__LINE__} inside a macro +information to a macro, since invoking \c{__?LINE?__} inside a macro definition (either single-line or multi-line) will return the line number of the macro \e{call}, rather than \e{definition}. So to determine where in a piece of code a crash is occurring, for @@ -3821,7 +3821,7 @@ here'. You could then write a macro \c %macro notdeadyet 0 \c \c push eax -\c mov eax,__LINE__ +\c mov eax,__?LINE?__ \c call stillhere \c pop eax \c @@ -3831,34 +3831,34 @@ and then pepper your code with calls to \c{notdeadyet} until you find the crash point. -\S{bitsm} \i\c{__BITS__}: Current BITS Mode +\S{bitsm} \i\c{__?BITS?__}: Current BITS Mode -The \c{__BITS__} standard macro is updated every time that the BITS mode is +The \c{__?BITS?__} standard macro is updated every time that the BITS mode is set using the \c{BITS XX} or \c{[BITS XX]} directive, where XX is a valid mode -number of 16, 32 or 64. \c{__BITS__} receives the specified mode number and +number of 16, 32 or 64. \c{__?BITS?__} receives the specified mode number and makes it globally available. This can be very useful for those who utilize mode-dependent macros. -\S{ofmtm} \i\c{__OUTPUT_FORMAT__}: Current Output Format +\S{ofmtm} \i\c{__?OUTPUT_FORMAT?__}: Current Output Format -The \c{__OUTPUT_FORMAT__} standard macro holds the current output +The \c{__?OUTPUT_FORMAT?__} standard macro holds the current output format name, as given by the \c{-f} option or NASM's default. Type \c{nasm -hf} for a list. -\c %ifidn __OUTPUT_FORMAT__, win32 +\c %ifidn __?OUTPUT_FORMAT?__, win32 \c %define NEWLINE 13, 10 -\c %elifidn __OUTPUT_FORMAT__, elf32 +\c %elifidn __?OUTPUT_FORMAT?__, elf32 \c %define NEWLINE 10 \c %endif -\S{dfmtm} \i\c{__DEBUG_FORMAT__}: Current Debug Format +\S{dfmtm} \i\c{__?DEBUG_FORMAT?__}: Current Debug Format If debugging information generation is enabled, The -\c{__DEBUG_FORMAT__} standard macro holds the current debug format +\c{__?DEBUG_FORMAT?__} standard macro holds the current debug format name as specified by the \c{-F} or \c{-g} option or the output format default. Type \c{nasm -f} \e{output} \c{y} for a list. -\c{__DEBUG_FORMAT__} is not defined if debugging is not enabled, or if +\c{__?DEBUG_FORMAT?__} is not defined if debugging is not enabled, or if the debug format specified is \c{null}. \S{datetime} Assembly Date and Time Macros @@ -3866,26 +3866,26 @@ the debug format specified is \c{null}. NASM provides a variety of macros that represent the timestamp of the assembly session. -\b The \i\c{__DATE__} and \i\c{__TIME__} macros give the assembly date and +\b The \i\c{__?DATE?__} and \i\c{__?TIME?__} macros give the assembly date and time as strings, in ISO 8601 format (\c{"YYYY-MM-DD"} and \c{"HH:MM:SS"}, respectively.) -\b The \i\c{__DATE_NUM__} and \i\c{__TIME_NUM__} macros give the assembly +\b The \i\c{__?DATE_NUM?__} and \i\c{__?TIME_NUM?__} macros give the assembly date and time in numeric form; in the format \c{YYYYMMDD} and \c{HHMMSS} respectively. -\b The \i\c{__UTC_DATE__} and \i\c{__UTC_TIME__} macros give the assembly +\b The \i\c{__?UTC_DATE?__} and \i\c{__?UTC_TIME?__} macros give the assembly date and time in universal time (UTC) as strings, in ISO 8601 format (\c{"YYYY-MM-DD"} and \c{"HH:MM:SS"}, respectively.) If the host platform doesn't provide UTC time, these macros are undefined. -\b The \i\c{__UTC_DATE_NUM__} and \i\c{__UTC_TIME_NUM__} macros give the +\b The \i\c{__?UTC_DATE_NUM?__} and \i\c{__?UTC_TIME_NUM?__} macros give the assembly date and time universal time (UTC) in numeric form; in the format \c{YYYYMMDD} and \c{HHMMSS} respectively. If the host platform doesn't provide UTC time, these macros are undefined. -\b The \c{__POSIX_TIME__} macro is defined as a number containing the +\b The \c{__?POSIX_TIME?__} macro is defined as a number containing the number of seconds since the POSIX epoch, 1 January 1970 00:00:00 UTC; excluding any leap seconds. This is computed using UTC time if available on the host platform, otherwise it is computed using the @@ -3898,15 +3898,15 @@ started at 42 seconds after midnight on January 1, 2010 in Moscow assuming, of course, a properly configured environment with a correct clock: -\c __DATE__ "2010-01-01" -\c __TIME__ "00:00:42" -\c __DATE_NUM__ 20100101 -\c __TIME_NUM__ 000042 -\c __UTC_DATE__ "2009-12-31" -\c __UTC_TIME__ "21:00:42" -\c __UTC_DATE_NUM__ 20091231 -\c __UTC_TIME_NUM__ 210042 -\c __POSIX_TIME__ 1262293242 +\c __?DATE?__ "2010-01-01" +\c __?TIME?__ "00:00:42" +\c __?DATE_NUM?__ 20100101 +\c __?TIME_NUM?__ 000042 +\c __?UTC_DATE?__ "2009-12-31" +\c __?UTC_TIME?__ "21:00:42" +\c __?UTC_DATE_NUM?__ 20091231 +\c __?UTC_TIME_NUM?__ 210042 +\c __?POSIX_TIME?__ 1262293242 \S{use_def} \I\c{__USE_*__}\c{__USE_}\e{package}\c{__}: Package @@ -3918,12 +3918,12 @@ When a standard macro package (see \k{macropkg}) is included with the testing if a particular package is invoked or not. For example, if the \c{altreg} package is included (see -\k{pkg_altreg}), then the macro \c{__USE_ALTREG__} is defined. +\k{pkg_altreg}), then the macro \c{__?USE_ALTREG?__} is defined. -\S{pass_macro} \i\c{__PASS__}: Assembly Pass +\S{pass_macro} \i\c{__?PASS?__}: Assembly Pass -The macro \c{__PASS__} is defined to be \c{1} on preparatory passes, +The macro \c{__?PASS?__} is defined to be \c{1} on preparatory passes, and \c{2} on the final pass. In preprocess-only mode, it is set to \c{3}, and when running only to generate dependencies (due to the \c{-M} or \c{-MG} option, see \k{opt-M}) it is set to \c{0}. @@ -4215,7 +4215,7 @@ instructions first introduced in Pentium Pro. This is incompatible with all CPUs of family 5 or lower, as well as some VIA CPUs and several virtualization solutions. The default jump threshold is 16. -The macro \i\c{__ALIGNMODE__} is defined to contain the current +The macro \i\c{__?ALIGNMODE?__} is defined to contain the current alignment mode. A number of other macros beginning with \c{__ALIGN_} are used internally by this macro package. @@ -4224,19 +4224,19 @@ are used internally by this macro package. This packages contains the following floating-point convenience macros: -\c %define Inf __Infinity__ -\c %define NaN __QNaN__ -\c %define QNaN __QNaN__ -\c %define SNaN __SNaN__ +\c %define Inf __?Infinity?__ +\c %define NaN __?QNaN?__ +\c %define QNaN __?QNaN?__ +\c %define SNaN __?SNaN?__ \c -\c %define float8(x) __float8__(x) -\c %define float16(x) __float16__(x) -\c %define float32(x) __float32__(x) -\c %define float64(x) __float64__(x) -\c %define float80m(x) __float80m__(x) -\c %define float80e(x) __float80e__(x) -\c %define float128l(x) __float128l__(x) -\c %define float128h(x) __float128h__(x) +\c %define float8(x) __?float8?__(x) +\c %define float16(x) __?float16?__(x) +\c %define float32(x) __?float32?__(x) +\c %define float64(x) __?float64?__(x) +\c %define float80m(x) __?float80m?__(x) +\c %define float80e(x) __?float80e?__(x) +\c %define float128l(x) __?float128l?__(x) +\c %define float128h(x) __?float128h?__(x) \H{pkg_ifunc} \i\c{ifunc}: \i{Integer functions} @@ -4420,13 +4420,13 @@ special, and indeed will strip off the leading period of any section name that has one. -\S{sectmac} The \i\c{__SECT__} Macro +\S{sectmac} The \i\c{__?SECT?__} Macro The \c{SECTION} directive is unusual in that its user-level form functions differently from its primitive form. The primitive form, \c{[SECTION xyz]}, simply switches the current target section to the one given. The user-level form, \c{SECTION xyz}, however, first -defines the single-line macro \c{__SECT__} to be the primitive +defines the single-line macro \c{__?SECT?__} to be the primitive \c{[SECTION]} directive which it is about to issue, and then issues it. So the user-level directive @@ -4434,7 +4434,7 @@ it. So the user-level directive expands to the two lines -\c %define __SECT__ [SECTION .text] +\c %define __?SECT?__ [SECTION .text] \c [SECTION .text] Users may find it useful to make use of this in their own macros. @@ -4448,7 +4448,7 @@ usefully rewritten in the following more sophisticated form: \c %%str: db %2 \c %%endstr: \c -\c __SECT__ +\c __?SECT?__ \c \c mov dx,%%str \c mov cx,%%endstr-%%str @@ -4461,8 +4461,8 @@ usefully rewritten in the following more sophisticated form: This form of the macro, once passed a string to output, first switches temporarily to the data section of the file, using the primitive form of the \c{SECTION} directive so as not to modify -\c{__SECT__}. It then declares its string in the data section, and -then invokes \c{__SECT__} to switch back to \e{whichever} section +\c{__?SECT?__}. It then declares its string in the data section, and +then invokes \c{__?SECT?__} to switch back to \e{whichever} section the user was previously working in. It thus avoids the need, in the previous version of the macro, to include a \c{JMP} instruction to jump over the data, and also does not fail if, in a complicated @@ -4491,10 +4491,10 @@ segment address 0x40: the above code defines \c{kbuf_chr} to be 0x1A, \c{kbuf_free} to be 0x1C, and \c{kbuf} to be 0x1E. The user-level form of \c{ABSOLUTE}, like that of \c{SECTION}, -redefines the \i\c{__SECT__} macro when it is invoked. +redefines the \i\c{__?SECT?__} macro when it is invoked. \i\c{STRUC} and \i\c{ENDSTRUC} are defined as macros which use -\c{ABSOLUTE} (and also \c{__SECT__}). +\c{ABSOLUTE} (and also \c{__?SECT?__}). \c{ABSOLUTE} doesn't have to take an absolute constant as an argument: it can take an expression (actually, a \i{critical @@ -4753,11 +4753,11 @@ this behaviour: \b\c{FLOAT DEFAULT} Restore default settings -The standard macros \i\c{__FLOAT_DAZ__}, \i\c{__FLOAT_ROUND__}, and -\i\c{__FLOAT__} contain the current state, as long as the programmer +The standard macros \i\c{__?FLOAT_DAZ?__}, \i\c{__?FLOAT_ROUND?__}, and +\i\c{__?FLOAT?__} contain the current state, as long as the programmer has avoided the use of the brackeded primitive form, (\c{[FLOAT]}). -\c{__FLOAT__} contains the full set of floating-point settings; this +\c{__?FLOAT?__} contains the full set of floating-point settings; this value can be saved away and invoked later to restore the setting. @@ -5403,7 +5403,7 @@ table." Its typical use would be: \c section .text \c extern _MessageBoxA@16 -\c %if __NASM_VERSION_ID__ >= 0x02030000 +\c %if __?NASM_VERSION_ID?__ >= 0x02030000 \c safeseh handler ; register handler as "safe handler" \c %endif \c handler: diff --git a/include/nasm.h b/include/nasm.h index cfeb13ce9..9bd42a759 100644 --- a/include/nasm.h +++ b/include/nasm.h @@ -186,12 +186,12 @@ enum token_type { /* token types, other than chars */ TOKEN_DBL_XOR, /* ^^ */ TOKEN_SEG, /* SEG */ TOKEN_WRT, /* WRT */ - TOKEN_FLOATIZE, /* __floatX__ */ + TOKEN_FLOATIZE, /* __?floatX?__ */ TOKEN_STRFUNC, /* __utf16*__, __utf32*__ */ TOKEN_IFUNC, /* __ilog2*__ */ TOKEN_DECORATOR, /* decorators such as {...} */ - TOKEN_MASM_PTR, /* __masm_ptr__ for the masm package */ - TOKEN_MASM_FLAT, /* __masm_flat__ for the masm package */ + TOKEN_MASM_PTR, /* __?masm_ptr?__ for the masm package */ + TOKEN_MASM_FLAT, /* __?masm_flat?__ for the masm package */ TOKEN_OPMASK /* translated token for opmask registers */ }; @@ -808,7 +808,7 @@ struct ofmt { /* * This, if non-NULL, is a NULL-terminated list of `char *'s * pointing to extra standard macros supplied by the object - * format (e.g. a sensible initial default value of __SECT__, + * format (e.g. a sensible initial default value of __?SECT?__, * and user-level equivalents for any format-specific * directives). */ diff --git a/macros/fp.mac b/macros/fp.mac index 1334784bd..eb297014e 100644 --- a/macros/fp.mac +++ b/macros/fp.mac @@ -39,16 +39,16 @@ USE: fp -%define Inf __Infinity__ -%define NaN __QNaN__ -%define QNaN __QNaN__ -%define SNaN __SNaN__ +%define Inf __?Infinity?__ +%define NaN __?QNaN?__ +%define QNaN __?QNaN?__ +%define SNaN __?SNaN?__ -%define float8(x) __float8__(x) -%define float16(x) __float16__(x) -%define float32(x) __float32__(x) -%define float64(x) __float64__(x) -%define float80m(x) __float80m__(x) -%define float80e(x) __float80e__(x) -%define float128l(x) __float128l__(x) -%define float128h(x) __float128h__(x) +%define float8(x) __?float8?__(x) +%define float16(x) __?float16?__(x) +%define float32(x) __?float32?__(x) +%define float64(x) __?float64?__(x) +%define float80m(x) __?float80m?__(x) +%define float80e(x) __?float80e?__(x) +%define float128l(x) __?float128l?__(x) +%define float128h(x) __?float128h?__(x) diff --git a/macros/ifunc.mac b/macros/ifunc.mac index 0fafe8d60..4db46d34e 100644 --- a/macros/ifunc.mac +++ b/macros/ifunc.mac @@ -39,10 +39,10 @@ USE: ifunc -%idefine ilog2(x) (__ilog2e__(x)) -%idefine ilog2e(x) (__ilog2e__(x)) -%idefine ilog2w(x) (__ilog2w__(x)) -%idefine ilog2fw(x) (__ilog2w__(x)) -%idefine ilog2f(x) (__ilog2f__(x)) -%idefine ilog2cw(x) (__ilog2w__(x) * 0 + __ilog2c__(x)) -%idefine ilog2c(x) (__ilog2c__(x)) +%idefine ilog2(x) (__?ilog2e?__(x)) +%idefine ilog2e(x) (__?ilog2e?__(x)) +%idefine ilog2w(x) (__?ilog2w?__(x)) +%idefine ilog2fw(x) (__?ilog2w?__(x)) +%idefine ilog2f(x) (__?ilog2f?__(x)) +%idefine ilog2cw(x) (__?ilog2w?__(x) * 0 + __?ilog2c?__(x)) +%idefine ilog2c(x) (__?ilog2c?__(x)) diff --git a/macros/macros.pl b/macros/macros.pl index 260382c22..9fc425d4f 100755 --- a/macros/macros.pl +++ b/macros/macros.pl @@ -205,7 +205,9 @@ (@) $lastname = $fname; push(@pkg_list, $pkg); $pkg_number{$pkg} = $npkg++; - $z = pack("C", $pnum{'%define'})."__USE_\U$pkg\E__"; + $z = pack("C", $pnum{'%define'})."__?USE_\U$pkg\E?__"; + printf OUT " /* %4d */ %sEOL,\n", $index, charcify($z); + $z = pack("C", $pnum{'%defalias'})."__USE_\U$pkg\E__ __?USE\U$pkg\E?__"; printf OUT " /* %4d */ %sEOL,\n", $index, charcify($z); $index += length($z)+1; } else { diff --git a/macros/masm.mac b/macros/masm.mac index 6587e0154..da7e6eead 100644 --- a/macros/masm.mac +++ b/macros/masm.mac @@ -45,8 +45,8 @@ USE: masm %unimacro segment 1+ %imacro segment 0-1+.nolist - %define __SECT__ [segment %00 %1] - __SECT__ + %define __?SECT?__ [segment %00 %1] + __?SECT?__ %endmacro %imacro ends 0+.nolist @@ -69,8 +69,8 @@ USE: masm %undef ret %endmacro -%idefine ptr __masm_ptr__ -%idefine flat __masm_flat__ ; is %idefine really correct here? +%idefine ptr __?masm_ptr?__ +%idefine flat __?masm_flat?__ ; is %idefine really correct here? %idefine offset %imacro end 0+.nolist diff --git a/macros/smartalign.mac b/macros/smartalign.mac index 0f81ae87b..abd496e6f 100644 --- a/macros/smartalign.mac +++ b/macros/smartalign.mac @@ -38,147 +38,149 @@ USE: smartalign %imacro alignmode 1-2.nolist %ifidni %1,nop - %define __ALIGN_JMP_THRESHOLD__ 16 + %define __?ALIGN_JMP_THRESHOLD?__ 16 - %define __ALIGN_16BIT_1B__ 0x90 - %define __ALIGN_16BIT_GROUP__ 1 + %define __?ALIGN_16BIT_1B?__ 0x90 + %define __?ALIGN_16BIT_GROUP?__ 1 - %define __ALIGN_32BIT_1B__ 0x90 - %define __ALIGN_32BIT_GROUP__ 1 + %define __?ALIGN_32BIT_1B?__ 0x90 + %define __?ALIGN_32BIT_GROUP?__ 1 - %define __ALIGN_64BIT_1B__ 0x90 - %define __ALIGN_64BIT_GROUP__ 1 + %define __?ALIGN_64BIT_1B?__ 0x90 + %define __?ALIGN_64BIT_GROUP?__ 1 %elifidni %1,generic - %define __ALIGN_JMP_THRESHOLD__ 8 - - %define __ALIGN_16BIT_1B__ 0x90 - %define __ALIGN_16BIT_2B__ 0x89,0xf6 - %define __ALIGN_16BIT_3B__ 0x8d,0x74,0x00 - %define __ALIGN_16BIT_4B__ 0x8d,0xb4,0x00,0x00 - %define __ALIGN_16BIT_5B__ 0x8d,0xb4,0x00,0x00,0x90 - %define __ALIGN_16BIT_6B__ 0x8d,0xb4,0x00,0x00,0x89,0xff - %define __ALIGN_16BIT_7B__ 0x8d,0xb4,0x00,0x00,0x8d,0x7d,0x00 - %define __ALIGN_16BIT_8B__ 0x8d,0xb4,0x00,0x00,0x8d,0xbd,0x00,0x00 - %define __ALIGN_16BIT_GROUP__ 8 - - %define __ALIGN_32BIT_1B__ 0x90 - %define __ALIGN_32BIT_2B__ 0x89,0xf6 - %define __ALIGN_32BIT_3B__ 0x8d,0x76,0x00 - %define __ALIGN_32BIT_4B__ 0x8d,0x74,0x26,0x00 - %define __ALIGN_32BIT_5B__ 0x90,0x8d,0x74,0x26,0x00 - %define __ALIGN_32BIT_6B__ 0x8d,0xb6,0x00,0x00,0x00,0x00 - %define __ALIGN_32BIT_7B__ 0x8d,0xb4,0x26,0x00,0x00,0x00,0x00 - %define __ALIGN_32BIT_GROUP__ 7 - - %define __ALIGN_64BIT_1B__ 0x90 - %define __ALIGN_64BIT_2B__ 0x66,0x90 - %define __ALIGN_64BIT_3B__ 0x66,0x66,0x90 - %define __ALIGN_64BIT_4B__ 0x66,0x66,0x66,0x90 - %define __ALIGN_64BIT_GROUP__ 4 + %define __?ALIGN_JMP_THRESHOLD?__ 8 + + %define __?ALIGN_16BIT_1B?__ 0x90 + %define __?ALIGN_16BIT_2B?__ 0x89,0xf6 + %define __?ALIGN_16BIT_3B?__ 0x8d,0x74,0x00 + %define __?ALIGN_16BIT_4B?__ 0x8d,0xb4,0x00,0x00 + %define __?ALIGN_16BIT_5B?__ 0x8d,0xb4,0x00,0x00,0x90 + %define __?ALIGN_16BIT_6B?__ 0x8d,0xb4,0x00,0x00,0x89,0xff + %define __?ALIGN_16BIT_7B?__ 0x8d,0xb4,0x00,0x00,0x8d,0x7d,0x00 + %define __?ALIGN_16BIT_8B?__ 0x8d,0xb4,0x00,0x00,0x8d,0xbd,0x00,0x00 + %define __?ALIGN_16BIT_GROUP?__ 8 + + %define __?ALIGN_32BIT_1B?__ 0x90 + %define __?ALIGN_32BIT_2B?__ 0x89,0xf6 + %define __?ALIGN_32BIT_3B?__ 0x8d,0x76,0x00 + %define __?ALIGN_32BIT_4B?__ 0x8d,0x74,0x26,0x00 + %define __?ALIGN_32BIT_5B?__ 0x90,0x8d,0x74,0x26,0x00 + %define __?ALIGN_32BIT_6B?__ 0x8d,0xb6,0x00,0x00,0x00,0x00 + %define __?ALIGN_32BIT_7B?__ 0x8d,0xb4,0x26,0x00,0x00,0x00,0x00 + %define __?ALIGN_32BIT_GROUP?__ 7 + + %define __?ALIGN_64BIT_1B?__ 0x90 + %define __?ALIGN_64BIT_2B?__ 0x66,0x90 + %define __?ALIGN_64BIT_3B?__ 0x66,0x66,0x90 + %define __?ALIGN_64BIT_4B?__ 0x66,0x66,0x66,0x90 + %define __?ALIGN_64BIT_GROUP?__ 4 %elifidni %1,k8 - %define __ALIGN_JMP_THRESHOLD__ 16 - - %define __ALIGN_16BIT_1B__ 0x90 - %define __ALIGN_16BIT_2B__ 0x66,0x90 - %define __ALIGN_16BIT_3B__ 0x66,0x66,0x90 - %define __ALIGN_16BIT_4B__ 0x66,0x66,0x66,0x90 - %define __ALIGN_16BIT_GROUP__ 4 - - %define __ALIGN_32BIT_1B__ 0x90 - %define __ALIGN_32BIT_2B__ 0x66,0x90 - %define __ALIGN_32BIT_3B__ 0x66,0x66,0x90 - %define __ALIGN_32BIT_4B__ 0x66,0x66,0x66,0x90 - %define __ALIGN_32BIT_GROUP__ 4 - - %define __ALIGN_64BIT_1B__ 0x90 - %define __ALIGN_64BIT_2B__ 0x66,0x90 - %define __ALIGN_64BIT_3B__ 0x66,0x66,0x90 - %define __ALIGN_64BIT_4B__ 0x66,0x66,0x66,0x90 - %define __ALIGN_64BIT_GROUP__ 4 + %define __?ALIGN_JMP_THRESHOLD?__ 16 + + %define __?ALIGN_16BIT_1B?__ 0x90 + %define __?ALIGN_16BIT_2B?__ 0x66,0x90 + %define __?ALIGN_16BIT_3B?__ 0x66,0x66,0x90 + %define __?ALIGN_16BIT_4B?__ 0x66,0x66,0x66,0x90 + %define __?ALIGN_16BIT_GROUP?__ 4 + + %define __?ALIGN_32BIT_1B?__ 0x90 + %define __?ALIGN_32BIT_2B?__ 0x66,0x90 + %define __?ALIGN_32BIT_3B?__ 0x66,0x66,0x90 + %define __?ALIGN_32BIT_4B?__ 0x66,0x66,0x66,0x90 + %define __?ALIGN_32BIT_GROUP?__ 4 + + %define __?ALIGN_64BIT_1B?__ 0x90 + %define __?ALIGN_64BIT_2B?__ 0x66,0x90 + %define __?ALIGN_64BIT_3B?__ 0x66,0x66,0x90 + %define __?ALIGN_64BIT_4B?__ 0x66,0x66,0x66,0x90 + %define __?ALIGN_64BIT_GROUP?__ 4 %elifidni %1,k7 - %define __ALIGN_JMP_THRESHOLD__ 16 - - %define __ALIGN_16BIT_1B__ 0x90 - %define __ALIGN_16BIT_2B__ 0x66,0x90 - %define __ALIGN_16BIT_3B__ 0x66,0x66,0x90 - %define __ALIGN_16BIT_4B__ 0x66,0x66,0x66,0x90 - %define __ALIGN_64BIT_GROUP__ 4 - - %define __ALIGN_32BIT_1B__ 0x90 - %define __ALIGN_32BIT_2B__ 0x8b,0xc0 - %define __ALIGN_32BIT_3B__ 0x8d,0x04,0x20 - %define __ALIGN_32BIT_4B__ 0x8d,0x44,0x20,0x00 - %define __ALIGN_32BIT_5B__ 0x8d,0x44,0x20,0x00,0x90 - %define __ALIGN_32BIT_6B__ 0x8d,0x80,0x00,0x00,0x00,0x00 - %define __ALIGN_32BIT_7B__ 0x8d,0x04,0x05,0x00,0x00,0x00,0x00 - %define __ALIGN_32BIT_GROUP__ 7 - - %define __ALIGN_64BIT_1B__ 0x90 - %define __ALIGN_64BIT_2B__ 0x66,0x90 - %define __ALIGN_64BIT_3B__ 0x66,0x66,0x90 - %define __ALIGN_64BIT_4B__ 0x66,0x66,0x66,0x90 - %define __ALIGN_64BIT_GROUP__ 4 + %define __?ALIGN_JMP_THRESHOLD?__ 16 + + %define __?ALIGN_16BIT_1B?__ 0x90 + %define __?ALIGN_16BIT_2B?__ 0x66,0x90 + %define __?ALIGN_16BIT_3B?__ 0x66,0x66,0x90 + %define __?ALIGN_16BIT_4B?__ 0x66,0x66,0x66,0x90 + %define __?ALIGN_64BIT_GROUP?__ 4 + + %define __?ALIGN_32BIT_1B?__ 0x90 + %define __?ALIGN_32BIT_2B?__ 0x8b,0xc0 + %define __?ALIGN_32BIT_3B?__ 0x8d,0x04,0x20 + %define __?ALIGN_32BIT_4B?__ 0x8d,0x44,0x20,0x00 + %define __?ALIGN_32BIT_5B?__ 0x8d,0x44,0x20,0x00,0x90 + %define __?ALIGN_32BIT_6B?__ 0x8d,0x80,0x00,0x00,0x00,0x00 + %define __?ALIGN_32BIT_7B?__ 0x8d,0x04,0x05,0x00,0x00,0x00,0x00 + %define __?ALIGN_32BIT_GROUP?__ 7 + + %define __?ALIGN_64BIT_1B?__ 0x90 + %define __?ALIGN_64BIT_2B?__ 0x66,0x90 + %define __?ALIGN_64BIT_3B?__ 0x66,0x66,0x90 + %define __?ALIGN_64BIT_4B?__ 0x66,0x66,0x66,0x90 + %define __?ALIGN_64BIT_GROUP?__ 4 %elifidni %1,p6 - %define __ALIGN_JMP_THRESHOLD__ 16 - - %define __ALIGN_16BIT_1B__ 0x90 - %define __ALIGN_16BIT_2B__ 0x66,0x90 - %define __ALIGN_16BIT_3B__ 0x0f,0x1f,0x00 - %define __ALIGN_16BIT_4B__ 0x0f,0x1f,0x40,0x00 - %define __ALIGN_16BIT_GROUP__ 4 - - %define __ALIGN_32BIT_1B__ 0x90 - %define __ALIGN_32BIT_2B__ 0x66,0x90 - %define __ALIGN_32BIT_3B__ 0x0f,0x1f,0x00 - %define __ALIGN_32BIT_4B__ 0x0f,0x1f,0x40,0x00 - %define __ALIGN_32BIT_5B__ 0x0f,0x1f,0x44,0x00,0x00 - %define __ALIGN_32BIT_6B__ 0x66,0x0f,0x1f,0x44,0x00,0x00 - %define __ALIGN_32BIT_7B__ 0x0f,0x1f,0x80,0x00,0x00,0x00,0x00 - %define __ALIGN_32BIT_8B__ 0x0f,0x1f,0x84,0x00,0x00,0x00,0x00,0x00 - %define __ALIGN_32BIT_GROUP__ 8 - - %define __ALIGN_64BIT_1B__ 0x90 - %define __ALIGN_64BIT_2B__ 0x66,0x90 - %define __ALIGN_64BIT_3B__ 0x0f,0x1f,0x00 - %define __ALIGN_64BIT_4B__ 0x0f,0x1f,0x40,0x00 - %define __ALIGN_64BIT_5B__ 0x0f,0x1f,0x44,0x00,0x00 - %define __ALIGN_64BIT_6B__ 0x66,0x0f,0x1f,0x44,0x00,0x00 - %define __ALIGN_64BIT_7B__ 0x0f,0x1f,0x80,0x00,0x00,0x00,0x00 - %define __ALIGN_64BIT_8B__ 0x0f,0x1f,0x84,0x00,0x00,0x00,0x00,0x00 - %define __ALIGN_64BIT_GROUP__ 8 + %define __?ALIGN_JMP_THRESHOLD?__ 16 + + %define __?ALIGN_16BIT_1B?__ 0x90 + %define __?ALIGN_16BIT_2B?__ 0x66,0x90 + %define __?ALIGN_16BIT_3B?__ 0x0f,0x1f,0x00 + %define __?ALIGN_16BIT_4B?__ 0x0f,0x1f,0x40,0x00 + %define __?ALIGN_16BIT_GROUP?__ 4 + + %define __?ALIGN_32BIT_1B?__ 0x90 + %define __?ALIGN_32BIT_2B?__ 0x66,0x90 + %define __?ALIGN_32BIT_3B?__ 0x0f,0x1f,0x00 + %define __?ALIGN_32BIT_4B?__ 0x0f,0x1f,0x40,0x00 + %define __?ALIGN_32BIT_5B?__ 0x0f,0x1f,0x44,0x00,0x00 + %define __?ALIGN_32BIT_6B?__ 0x66,0x0f,0x1f,0x44,0x00,0x00 + %define __?ALIGN_32BIT_7B?__ 0x0f,0x1f,0x80,0x00,0x00,0x00,0x00 + %define __?ALIGN_32BIT_8B?__ 0x0f,0x1f,0x84,0x00,0x00,0x00,0x00,0x00 + %define __?ALIGN_32BIT_GROUP?__ 8 + + %define __?ALIGN_64BIT_1B?__ 0x90 + %define __?ALIGN_64BIT_2B?__ 0x66,0x90 + %define __?ALIGN_64BIT_3B?__ 0x0f,0x1f,0x00 + %define __?ALIGN_64BIT_4B?__ 0x0f,0x1f,0x40,0x00 + %define __?ALIGN_64BIT_5B?__ 0x0f,0x1f,0x44,0x00,0x00 + %define __?ALIGN_64BIT_6B?__ 0x66,0x0f,0x1f,0x44,0x00,0x00 + %define __?ALIGN_64BIT_7B?__ 0x0f,0x1f,0x80,0x00,0x00,0x00,0x00 + %define __?ALIGN_64BIT_8B?__ 0x0f,0x1f,0x84,0x00,0x00,0x00,0x00,0x00 + %define __?ALIGN_64BIT_GROUP?__ 8 %else %error unknown alignment mode: %1 %endif %ifnempty %2 %ifidni %2,nojmp - %xdefine __ALIGN_JMP_THRESHOLD__ -1 + %xdefine __?ALIGN_JMP_THRESHOLD?__ -1 %else - %xdefine __ALIGN_JMP_THRESHOLD__ %2 + %xdefine __?ALIGN_JMP_THRESHOLD?__ %2 %endif %endif - %xdefine __ALIGNMODE__ %1,__ALIGN_JMP_THRESHOLD__ + %xdefine __?ALIGNMODE?__ %1,__?ALIGN_JMP_THRESHOLD?__ %endmacro +%defalias __ALIGNMODE__ __?ALIGNMODE?__ + %unimacro align 1-2+.nolist %imacro align 1-2+.nolist sectalign %1 ; align a segment as well %ifnempty %2 times (((%1) - (($-$$) % (%1))) % (%1)) %2 - %elif __PASS__ == 0 || __PASS__ == 3 + %elif __?PASS?__ == 0 || __?PASS?__ == 3 times (((%1) - (($-$$) % (%1))) % (%1)) nop %else %push %assign %$pad (((%1) - (($-$$) % (%1))) % (%1)) - %if __ALIGN_JMP_THRESHOLD__ != -1 && %$pad > __ALIGN_JMP_THRESHOLD__ + %if __?ALIGN_JMP_THRESHOLD?__ != -1 && %$pad > __?ALIGN_JMP_THRESHOLD?__ jmp %$end ; We can't re-use %$pad here as $ will have changed! times (((%1) - (($-$$) % (%1))) % (%1)) nop %else - times (%$pad / __ALIGN_%[__BITS__]BIT_GROUP__) \ - db __ALIGN_%[__BITS__]BIT_%[__ALIGN_%[__BITS__]BIT_GROUP__]B__ - %assign %$pad %$pad % __ALIGN_%[__BITS__]BIT_GROUP__ + times (%$pad / __?ALIGN_%[__?BITS?__]BIT_GROUP?__) \ + db __?ALIGN_%[__?BITS?__]BIT_%[__?ALIGN_%[__?BITS?__]BIT_GROUP?__]B?__ + %assign %$pad %$pad % __?ALIGN_%[__?BITS?__]BIT_GROUP?__ %if %$pad > 0 - db __ALIGN_%[__BITS__]BIT_%[%$pad]B__ + db __?ALIGN_%[__?BITS?__]BIT_%[%$pad]B?__ %endif %endif %$end: diff --git a/macros/standard.mac b/macros/standard.mac index 3a930f402..f6ca65d22 100644 --- a/macros/standard.mac +++ b/macros/standard.mac @@ -49,32 +49,34 @@ STD: nasm ; here, not all of them are: the user-level form of a format-specific ; directive should be defined in the module for that directive. -%define __SECT__ ; it ought to be defined, even if as nothing +%define __?SECT?__ ; it ought to be defined, even if as nothing +%defalias __SECT__ __?SECT?__ %imacro section 1+.nolist - %define __SECT__ [section %1] - __SECT__ + %define __?SECT?__ [section %1] + __?SECT?__ %endmacro %imacro segment 1+.nolist - %define __SECT__ [segment %1] - __SECT__ + %define __?SECT?__ [segment %1] + __?SECT?__ %endmacro -%define __SECTALIGN_ALIGN_UPDATES_SECTION__ 1 +%define __?SECTALIGN_ALIGN_UPDATES_SECTION?__ 1 %imacro sectalign 1+.nolist %ifidni %1,off - %define __SECTALIGN_ALIGN_UPDATES_SECTION__ 0 + %define __?SECTALIGN_ALIGN_UPDATES_SECTION?__ 0 %elifidni %1,on - %define __SECTALIGN_ALIGN_UPDATES_SECTION__ 1 + %define __?SECTALIGN_ALIGN_UPDATES_SECTION?__ 1 %else [sectalign %1] %endif %endmacro +%defalias __SECTALIGN_ALIGN_UPDATES_SECTION__ __?SECTALIGN_ALIGN_UPDATES_SECTION?__ %imacro absolute 1+.nolist - %define __SECT__ [absolute %1] - __SECT__ + %define __?SECT?__ [absolute %1] + __?SECT?__ %endmacro %imacro struc 1-2.nolist 0 @@ -87,7 +89,7 @@ STD: nasm %imacro endstruc 0.nolist %{$strucname}_size equ ($-%$strucname) %pop - __SECT__ + __?SECT?__ %endmacro %imacro istruc 1.nolist @@ -107,14 +109,14 @@ STD: nasm %endmacro %imacro align 1-2+.nolist nop - %if __SECTALIGN_ALIGN_UPDATES_SECTION__ + %if __?SECTALIGN_ALIGN_UPDATES_SECTION?__ sectalign %1 %endif times (((%1) - (($-$$) % (%1))) % (%1)) %2 %endmacro %imacro alignb 1-2+.nolist - %if __SECTALIGN_ALIGN_UPDATES_SECTION__ + %if __?SECTALIGN_ALIGN_UPDATES_SECTION?__ sectalign %1 %endif %ifempty %2 @@ -175,30 +177,34 @@ STD: nasm [cpu %1] %endmacro -%define __FLOAT_DAZ__ nodaz -%define __FLOAT_ROUND__ near -; __FLOAT__ contains the whole floating-point configuration so it can +%define __?FLOAT_DAZ?__ nodaz +%define __?FLOAT_ROUND?__ near +; __?FLOAT?__ contains the whole floating-point configuration so it can ; be saved and restored -%define __FLOAT__ __FLOAT_DAZ__,__FLOAT_ROUND__ +%define __?FLOAT?__ __?FLOAT_DAZ?__,__?FLOAT_ROUND?__ + +%defalias __FLOAT_DAZ__ __?FLOAT_DAZ?__ +%defalias __FLOAT_ROUND__ __?FLOAT_ROUND?__ +%defalias __FLOAT__ __?FLOAT?__ %imacro float 1-*.nolist %rep %0 [float %1] %ifidni %1,daz - %define __FLOAT_DAZ__ daz + %define __?FLOAT_DAZ?__ daz %elifidni %1,nodaz - %define __FLOAT_DAZ__ nodaz + %define __?FLOAT_DAZ?__ nodaz %elifidni %1,near - %define __FLOAT_ROUND__ near + %define __?FLOAT_ROUND?__ near %elifidni %1,up - %define __FLOAT_ROUND__ up + %define __?FLOAT_ROUND?__ up %elifidni %1,down - %define __FLOAT_ROUND__ down + %define __?FLOAT_ROUND?__ down %elifidni %1,zero - %define __FLOAT_ROUND__ zero + %define __?FLOAT_ROUND?__ zero %elifidni %1,default - %define __FLOAT_DAZ__ nodaz - %define __FLOAT_ROUND__ near + %define __?FLOAT_DAZ?__ nodaz + %define __?FLOAT_ROUND?__ near %endif %rotate 1 %endrep @@ -228,3 +234,85 @@ STD: nasm %? %$dep,%2 %pop %endmacro + +; Compatibility macro aliases +%defalias __NASM_MAJOR__ __?NASM_MAJOR?__ +%defalias __NASM_MINOR__ __?NASM_MINOR?__ +%defalias __NASM_SUBMINOR__ __?NASM_SUBMINOR?__ +%defalias __NASM_PATCHLEVEL__ __?NASM_PATCHLEVEL?__ +%defalias __NASM_SNAPSHOT__ __?NASM_SNAPSHOT?__ +%defalias __NASM_VERSION_ID__ __?NASM_VERSION_ID?__ +%defalias __NASM_VER__ __?NASM_VER?__ + +%defalias __OUTPUT_FORMAT__ __?OUTPUT_FORMAT?__ +%defalias __DEBUG_FORMAT__ __?DEBUG_FORMAT?__ + +%defalias __DATE__ __?DATE?__ +%defalias __DATE_NUM__ __?DATE_NUM?__ +%defalias __TIME__ __?TIME?__ +%defalias __TIME_NUM__ __?TIME_NUM?__ +%defalias __UTC_DATE__ __?UTC_DATE?__ +%defalias __UTC_DATE_NUM__ __?UTC_DATE_NUM?__ +%defalias __UTC_TIME__ __?UTC_TIME?__ +%defalias __UTC_TIME_NUM__ __?UTC_TIME_NUM?__ +%defalias __POSIX_TIME__ __?POSIX_TIME?__ + +%defalias __FILE__ __?FILE?__ +%defalias __LINE__ __?LINE?__ +%defalias __BITS__ __?BITS?__ +%defalias __PTR__ __?PTR?__ +%defalias __PASS__ __?PASS?__ + +; Backwards compatiblity aliases for tokens. The extra level of indirection here +; means %aliases on|off will do the right thing for these as well. +%idefine __?infinity?__ %? +%idefine __?nan?__ %? +%idefine __?qnan?__ %? +%idefine __?snan?__ %? + +%idefine __?float8?__ %? +%idefine __?float16?__ %? +%idefine __?float32?__ %? +%idefine __?float64?__ %? +%idefine __?float80m?__ %? +%idefine __?float80e?__ %? +%idefine __?float128l?__ %? +%idefine __?float128h?__ %? + +%idefine __?utf16?__ %? +%idefine __?utf16le?__ %? +%idefine __?utf16be?__ %? +%idefine __?utf32?__ %? +%idefine __?utf32le?__ %? +%idefine __?utf32be?__ %? + +%idefine __?ilog2e?__ %? +%idefine __?ilog2w?__ %? +%idefine __?ilog2f?__ %? +%idefine __?ilog2c?__ %? + +%idefalias __infinity__ __?infinity?__ +%idefalias __nan__ __?nan?__ +%idefalias __qnan__ __?qnan?__ +%idefalias __snan__ __?snan?__ + +%idefalias __float8__ __?float8?__ +%idefalias __float16__ __?float16?__ +%idefalias __float32__ __?float32?__ +%idefalias __float64__ __?float64?__ +%idefalias __float80m__ __?float80m?__ +%idefalias __float80e__ __?float80e?__ +%idefalias __float128l__ __?float128l?__ +%idefalias __float128h__ __?float128h?__ + +%idefalias __utf16__ __?utf16?__ +%idefalias __utf16le__ __?utf16le?__ +%idefalias __utf16be__ __?utf16be?__ +%idefalias __utf32__ __?utf32?__ +%idefalias __utf32le__ __?utf32le?__ +%idefalias __utf32be__ __?utf32be?__ + +%idefalias __ilog2e__ __?ilog2e?__ +%idefalias __ilog2w__ __?ilog2w?__ +%idefalias __ilog2f__ __?ilog2f?__ +%idefalias __ilog2c__ __?ilog2c?__ diff --git a/output/outaout.mac b/output/outaout.mac index cd23852dc..5b7b3668b 100644 --- a/output/outaout.mac +++ b/output/outaout.mac @@ -32,6 +32,6 @@ ;; -------------------------------------------------------------------------- OUT: aout aoutb -%define __SECT__ [section .text] -%macro __NASM_CDecl__ 1 +%define __?SECT?__ [section .text] +%macro __?NASM_CDecl?__ 1 %endmacro diff --git a/output/outas86.mac b/output/outas86.mac index f0bd2e419..f7c9a489c 100644 --- a/output/outas86.mac +++ b/output/outas86.mac @@ -32,6 +32,6 @@ ;; -------------------------------------------------------------------------- OUT: as86 -%define __SECT__ [section .text] -%macro __NASM_CDecl__ 1 +%define __?SECT?__ [section .text] +%macro __?NASM_CDecl?__ 1 %endmacro diff --git a/output/outbin.mac b/output/outbin.mac index be7fefae0..99c15b6af 100644 --- a/output/outbin.mac +++ b/output/outbin.mac @@ -32,9 +32,9 @@ ;; -------------------------------------------------------------------------- OUT: bin -%define __SECT__ [section .text] +%define __?SECT?__ [section .text] %imacro org 1+.nolist [org %1] %endmacro -%macro __NASM_CDecl__ 1 +%macro __?NASM_CDecl?__ 1 %endmacro diff --git a/output/outcoff.mac b/output/outcoff.mac index 2b8b12ff3..8d338efa9 100644 --- a/output/outcoff.mac +++ b/output/outcoff.mac @@ -32,8 +32,8 @@ ;; -------------------------------------------------------------------------- OUT: coff win32 win64 -%define __SECT__ [section .text] -%macro __NASM_CDecl__ 1 +%define __?SECT?__ [section .text] +%macro __?NASM_CDecl?__ 1 %endmacro %imacro export 1+.nolist [export %1] diff --git a/output/outdbg.mac b/output/outdbg.mac index 4f68d63cd..af7d274cd 100644 --- a/output/outdbg.mac +++ b/output/outdbg.mac @@ -36,7 +36,7 @@ ; for the .obj format. ; OUT: dbg -%define __SECT__ [section .text] +%define __?SECT?__ [section .text] %imacro group 1+.nolist [group %1] %endmacro @@ -49,5 +49,5 @@ OUT: dbg %imacro import 1+.nolist %pragma dbg import %1 %endmacro -%macro __NASM_CDecl__ 1 +%macro __?NASM_CDecl?__ 1 %endmacro diff --git a/output/outelf.mac b/output/outelf.mac index 6994d0774..94babe300 100644 --- a/output/outelf.mac +++ b/output/outelf.mac @@ -32,8 +32,8 @@ ;; -------------------------------------------------------------------------- OUT: elf elf32 elf64 -%define __SECT__ [section .text] -%macro __NASM_CDecl__ 1 +%define __?SECT?__ [section .text] +%macro __?NASM_CDecl?__ 1 %define $_%1 $%1 %endmacro %imacro osabi 1+.nolist diff --git a/output/outmacho.mac b/output/outmacho.mac index 52ce3d27b..001bb3a0a 100644 --- a/output/outmacho.mac +++ b/output/outmacho.mac @@ -32,18 +32,18 @@ ;; -------------------------------------------------------------------------- OUT: macho macho32 macho64 -%define __SECT__ [section .text] -%macro __NASM_CDecl__ 1 +%define __?SECT?__ [section .text] +%macro __?NASM_CDecl?__ 1 %endmacro ; This directive sets the MH_SUBSECTIONS_VIA_SYMBOLS header flag %imacro subsections_via_symbols 0.nolist - %pragma __OUTPUT_FORMAT__ %? + %pragma __?OUTPUT_FORMAT?__ %? %endmacro %imacro no_dead_strip 1-*.nolist %rep %0 - %pragma __OUTPUT_FORMAT__ %? %1 + %pragma __?OUTPUT_FORMAT?__ %? %1 %rotate 1 %endrep %endmacro diff --git a/output/outobj.mac b/output/outobj.mac index a5da833e8..09158f23e 100644 --- a/output/outobj.mac +++ b/output/outobj.mac @@ -32,7 +32,7 @@ ;; -------------------------------------------------------------------------- OUT: obj -%define __SECT__ [section .text] +%define __?SECT?__ [section .text] %imacro group 1+.nolist [group %1] %endmacro @@ -45,5 +45,5 @@ OUT: obj %imacro import 1+.nolist [import %1] %endmacro -%macro __NASM_CDecl__ 1 +%macro __?NASM_CDecl?__ 1 %endmacro diff --git a/output/outrdf.mac b/output/outrdf.mac index 64a7ac148..b318329a7 100644 --- a/output/outrdf.mac +++ b/output/outrdf.mac @@ -32,9 +32,9 @@ ;; -------------------------------------------------------------------------- OUT: rdf -%define __SECT__ [section .text] +%define __?SECT?__ [section .text] %imacro library 1+.nolist [library %1] %endmacro -%macro __NASM_CDecl__ 1 +%macro __?NASM_CDecl?__ 1 %endmacro diff --git a/output/outrdf2.mac b/output/outrdf2.mac index 4875c50c5..5e9166e65 100644 --- a/output/outrdf2.mac +++ b/output/outrdf2.mac @@ -32,12 +32,12 @@ ;; -------------------------------------------------------------------------- OUT: rdf2 -%define __SECT__ [section .text] +%define __?SECT?__ [section .text] %imacro library 1+.nolist [library %1] %endmacro %imacro module 1+.nolist [module %1] %endmacro -%macro __NASM_CDecl__ 1 +%macro __?NASM_CDecl?__ 1 %endmacro diff --git a/version.pl b/version.pl index f6a9c7f79..634ad311c 100755 --- a/version.pl +++ b/version.pl @@ -56,13 +56,13 @@ # NASM_VER -- whole version number as a string # # version.mac: -# __NASM_MAJOR__ -# __NASM_MINOR__ -# __NASM_SUBMINOR__ -# __NASM_PATCHLEVEL__ -# __NASM_SNAPSHOT__ -# __NASM_VERSION_ID__ -# __NASM_VER__ +# __?NASM_MAJOR?__ +# __?NASM_MINOR?__ +# __?NASM_SUBMINOR?__ +# __?NASM_PATCHLEVEL?__ +# __?NASM_SNAPSHOT?__ +# __?NASM_VERSION_ID?__ +# __?NASM_VER?__ # ($what) = @ARGV; @@ -148,15 +148,15 @@ print "#endif /* NASM_VERSION_H */\n"; } elsif ( $what eq 'mac' ) { print "STD: version\n"; - printf "%%define __NASM_MAJOR__ %d\n", $nmaj; - printf "%%define __NASM_MINOR__ %d\n", $nmin; - printf "%%define __NASM_SUBMINOR__ %d\n", $nsmin; - printf "%%define __NASM_PATCHLEVEL__ %d\n", $nplvl; + printf "%%define __?NASM_MAJOR?__ %d\n", $nmaj; + printf "%%define __?NASM_MINOR?__ %d\n", $nmin; + printf "%%define __?NASM_SUBMINOR?__ %d\n", $nsmin; + printf "%%define __?NASM_PATCHLEVEL?__ %d\n", $nplvl; if (defined($snapshot)) { - printf "%%define __NASM_SNAPSHOT__ %d\n", $snapshot; + printf "%%define __?NASM_SNAPSHOT?__ %d\n", $snapshot; } - printf "%%define __NASM_VERSION_ID__ 0%08Xh\n", $nasm_id; - printf "%%define __NASM_VER__ \"%s\"\n", $line; + printf "%%define __?NASM_VERSION_ID?__ 0%08Xh\n", $nasm_id; + printf "%%define __?NASM_VER?__ \"%s\"\n", $line; } elsif ( $what eq 'sed' ) { printf "s/\@\@NASM_MAJOR\@\@/%d/g\n", $nmaj; printf "s/\@\@NASM_MINOR\@\@/%d/g\n", $nmin;