summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin (Intel) <hpa@zytor.com>2020-06-30 17:14:36 -0700
committerH. Peter Anvin (Intel) <hpa@zytor.com>2020-06-30 17:14:36 -0700
commita3db726f02be8ac285f51106070a04aca7ab0142 (patch)
treebe35b568bba4a7b41008e391e6ab13bc3bd3ecf5
parent367350319b8c5d2a79f400915d7a51be9cb98209 (diff)
parent8877a3ddb08e5cb7cd60704380ccccb5bb5c36b2 (diff)
downloadnasm-a3db726f02be8ac285f51106070a04aca7ab0142.tar.gz
Merge remote-tracking branch 'github/nasm-2.15.xx'
Resolved Conflicts: version Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
-rw-r--r--.gitattributes1
-rw-r--r--asm/listing.c9
-rw-r--r--asm/parser.c14
-rwxr-xr-xasm/pptok.pl6
-rw-r--r--asm/preproc.c95
-rw-r--r--asm/stdscan.c2
-rwxr-xr-xasm/tokhash.pl6
-rwxr-xr-xasm/warnings.pl13
-rw-r--r--config/unconfig.h30
-rw-r--r--configure.ac38
-rw-r--r--doc/changes.src11
-rwxr-xr-xdoc/genps.pl4
-rw-r--r--doc/head.ps8
-rw-r--r--doc/nasmdoc.css1
-rw-r--r--doc/nasmdoc.src260
-rw-r--r--doc/psfonts.ph47
-rw-r--r--include/compiler.h25
-rw-r--r--include/strlist.h8
-rwxr-xr-xmacros/macros.pl6
-rwxr-xr-xnasmlib/perfhash.pl6
-rw-r--r--nasmlib/strlist.c5
-rw-r--r--test/dup.asm15
-rw-r--r--[l---------]test/emptyarg.asm148
23 files changed, 514 insertions, 244 deletions
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 00000000..d94c5fb3
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+/version -merge
diff --git a/asm/listing.c b/asm/listing.c
index 9b101ff4..6d6f3606 100644
--- a/asm/listing.c
+++ b/asm/listing.c
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------- *
*
- * Copyright 1996-2019 The NASM Authors - All Rights Reserved
+ * Copyright 1996-2020 The NASM Authors - All Rights Reserved
* See the file AUTHORS included with the NASM distribution for
* the specific copyright holders.
*
@@ -276,8 +276,13 @@ static void list_output(const struct out_data *data)
break;
case OUT_RESERVE:
{
- if (size)
+ if (size > 8) {
list_size(offset, "res", size);
+ } else {
+ memset(q, '?', size << 1);
+ q[size << 1] = '\0';
+ list_out(offset, q);
+ }
break;
}
default:
diff --git a/asm/parser.c b/asm/parser.c
index de24103e..7c24cc00 100644
--- a/asm/parser.c
+++ b/asm/parser.c
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------- *
*
- * Copyright 1996-2019 The NASM Authors - All Rights Reserved
+ * Copyright 1996-2020 The NASM Authors - All Rights Reserved
* See the file AUTHORS included with the NASM distribution for
* the specific copyright holders.
*
@@ -234,7 +234,8 @@ static bool parse_braces(decoflags_t *decoflags)
}
}
-static inline const expr *next_expr(const expr *e, const expr **next_list)
+static inline unused
+const expr *next_expr(const expr *e, const expr **next_list)
{
e++;
if (!e->type) {
@@ -830,7 +831,14 @@ restart_parse:
/* DB et al */
result->operands = oper_num;
if (oper_num == 0)
- nasm_warn(WARN_OTHER, "no operand for data declaration");
+ /*!
+ *!db-empty [on] no operand for data declaration
+ *! warns about a \c{DB}, \c{DW}, etc declaration
+ *! with no operands, producing no output.
+ *! This is permitted, but often indicative of an error.
+ *! See \k{db}.
+ */
+ nasm_warn(WARN_DB_EMPTY, "no operand for data declaration");
}
return result;
}
diff --git a/asm/pptok.pl b/asm/pptok.pl
index a4853f2e..5498cb46 100755
--- a/asm/pptok.pl
+++ b/asm/pptok.pl
@@ -223,19 +223,19 @@ if ($what eq 'c') {
# Put a large value in unused slots. This makes it extremely unlikely
# that any combination that involves unused slot will pass the range test.
# This speeds up rejection of unrecognized tokens, i.e. identifiers.
- print OUT "#define UNUSED (65535/3)\n";
+ print OUT "#define UNUSED_HASH_ENTRY (65535/3)\n";
print OUT " static const int16_t hash1[$n] = {\n";
for ($i = 0; $i < $n; $i++) {
my $h = ${$g}[$i*2+0];
- print OUT " ", defined($h) ? $h : 'UNUSED', ",\n";
+ print OUT " ", defined($h) ? $h : 'UNUSED_HASH_ENTRY', ",\n";
}
print OUT " };\n";
print OUT " static const int16_t hash2[$n] = {\n";
for ($i = 0; $i < $n; $i++) {
my $h = ${$g}[$i*2+1];
- print OUT " ", defined($h) ? $h : 'UNUSED', ",\n";
+ print OUT " ", defined($h) ? $h : 'UNUSED_HASH_ENTRY', ",\n";
}
print OUT " };\n";
diff --git a/asm/preproc.c b/asm/preproc.c
index 0a6e2451..eee4d8a9 100644
--- a/asm/preproc.c
+++ b/asm/preproc.c
@@ -345,7 +345,8 @@ static inline bool tok_text_match(const struct Token *a, const struct Token *b)
return a->len == b->len && !memcmp(tok_text(a), tok_text(b), a->len);
}
-static inline bool tok_match(const struct Token *a, const struct Token *b)
+static inline unused bool
+tok_match(const struct Token *a, const struct Token *b)
{
return a->type == b->type && tok_text_match(a, b);
}
@@ -763,7 +764,8 @@ static const char *unquote_token_cstr(Token *t)
* TOK_STRING tokens.
*/
static Token *quote_any_token(Token *t);
-static inline Token *quote_token(Token *t)
+static inline unused
+Token *quote_token(Token *t)
{
if (likely(!tok_is(t, TOK_INTERNAL_STRING)))
return t;
@@ -4886,17 +4888,15 @@ static int mmac_rotate(const MMacro *mac, unsigned int n)
/*
* expands to a list of tokens from %{x:y}
*/
-static Token *expand_mmac_params_range(MMacro *mac, Token *tline, Token ***last)
+void expand_mmac_params_range(MMacro *mac, Token *tline, Token ***tail)
{
- Token *t = tline, **tt, *tm, *head;
- char *pos;
- int fst, lst, j, i;
-
- pos = strchr(tok_text(tline), ':');
- nasm_assert(pos);
+ Token *t;
+ const char *arg = tok_text(tline) + 1;
+ int fst, lst, incr, n;
+ int parsed;
- lst = atoi(pos + 1);
- fst = atoi(tok_text(tline) + 1);
+ parsed = sscanf(arg, "%d:%d", &fst, &lst);
+ nasm_assert(parsed == 2);
/*
* only macros params are accounted so
@@ -4914,56 +4914,28 @@ static Token *expand_mmac_params_range(MMacro *mac, Token *tline, Token ***last)
fst = fst < 0 ? fst + (int)mac->nparam + 1: fst;
lst = lst < 0 ? lst + (int)mac->nparam + 1: lst;
- /* count from zero */
- fst--, lst--;
-
/*
- * It will be at least one token. Note we
- * need to scan params until separator, otherwise
- * only first token will be passed.
+ * It will be at least one parameter, as we can loop
+ * in either direction.
*/
- j = (fst + mac->rotate) % mac->nparam;
- tm = mac->params[j+1];
- if (!tm)
- goto err;
- head = dup_Token(NULL, tm);
- tt = &head->next, tm = tm->next;
- while (tok_isnt(tm, ',')) {
- t = dup_Token(NULL, tm);
- *tt = t, tt = &t->next, tm = tm->next;
- }
+ incr = (fst < lst) ? 1 : -1;
- if (fst < lst) {
- for (i = fst + 1; i <= lst; i++) {
- t = make_tok_char(NULL, ',');
- *tt = t, tt = &t->next;
- j = (i + mac->rotate) % mac->nparam;
- tm = mac->params[j+1];
- while (tok_isnt(tm, ',')) {
- t = dup_Token(NULL, tm);
- *tt = t, tt = &t->next, tm = tm->next;
- }
- }
- } else {
- for (i = fst - 1; i >= lst; i--) {
- t = make_tok_char(NULL, ',');
- *tt = t, tt = &t->next;
- j = (i + mac->rotate) % mac->nparam;
- tm = mac->params[j+1];
- while (!tok_isnt(tm, ',')) {
- t = dup_Token(NULL, tm);
- *tt = t, tt = &t->next, tm = tm->next;
- }
- }
+ while (true) {
+ n = mmac_rotate(mac, fst);
+ dup_tlistn(mac->params[n], mac->paramlen[n], tail);
+ if (fst == lst)
+ break;
+ t = make_tok_char(NULL, ',');
+ **tail = t;
+ *tail = &t->next;
+ fst += incr;
}
- *last = tt;
- return head;
+ return;
err:
- nasm_nonfatal("`%%{%s}': macro parameters out of range",
- tok_text(tline) + 1);
- return NULL;
+ nasm_nonfatal("`%%{%s}': macro parameters out of range", arg);
+ return;
}
/*
@@ -5014,16 +4986,9 @@ static Token *expand_mmac_params(Token * tline)
}
if (strchr(text, ':')) {
- /*
- * seems we have a parameters range here
- */
- Token *head, **last;
- head = expand_mmac_params_range(mac, t, &last);
- if (head) {
- *tail = head;
- *last = tline;
- text = NULL;
- }
+ /* It is a range */
+ expand_mmac_params_range(mac, t, &tail);
+ text = NULL;
break;
}
@@ -5999,7 +5964,7 @@ static MMacro *is_mmacro(Token * tline, int *nparamp, Token ***paramsp)
*! The legacy behavior is quite strange and highly context-dependent,
*! and can be disabled with:
*!-
- *! \c %pragma preproc sane_empty_expansion true
+ *! \c %pragma preproc sane_empty_expansion true
*!-
*! It is highly recommended to use this option in new code.
*/
diff --git a/asm/stdscan.c b/asm/stdscan.c
index c1c38f42..cbc0fc77 100644
--- a/asm/stdscan.c
+++ b/asm/stdscan.c
@@ -164,7 +164,7 @@ int stdscan(void *private_data, struct tokenval *tv)
*!ptr [on] non-NASM keyword used in other assemblers
*! warns about keywords used in other assemblers that might
*! indicate a mistake in the source code. Currently only the MASM
- *! \c{PTR} keyword is recognized.
+ *! \c{PTR} keyword is recognized. See also \k{pkg_masm}.
*/
nasm_warn(WARN_PTR, "`%s' is not a NASM keyword",
tv->t_charptr);
diff --git a/asm/tokhash.pl b/asm/tokhash.pl
index 9dbe77a2..9303157b 100755
--- a/asm/tokhash.pl
+++ b/asm/tokhash.pl
@@ -234,19 +234,19 @@ if ($output eq 'h') {
# Put a large value in unused slots. This makes it extremely unlikely
# that any combination that involves unused slot will pass the range test.
# This speeds up rejection of unrecognized tokens, i.e. identifiers.
- print "#define UNUSED (65535/3)\n";
+ print "#define UNUSED_HASH_ENTRY (65535/3)\n";
print " static const int16_t hash1[$n] = {\n";
for ($i = 0; $i < $n; $i++) {
my $h = ${$g}[$i*2+0];
- print " ", defined($h) ? $h : 'UNUSED', ",\n";
+ print " ", defined($h) ? $h : 'UNUSED_HASH_ENTRY', ",\n";
}
print " };\n";
print " static const int16_t hash2[$n] = {\n";
for ($i = 0; $i < $n; $i++) {
my $h = ${$g}[$i*2+1];
- print " ", defined($h) ? $h : 'UNUSED', ",\n";
+ print " ", defined($h) ? $h : 'UNUSED_HASH_ENTRY', ",\n";
}
print " };\n";
diff --git a/asm/warnings.pl b/asm/warnings.pl
index a609e132..8a79568a 100755
--- a/asm/warnings.pl
+++ b/asm/warnings.pl
@@ -253,7 +253,18 @@ if ($what eq 'c') {
} else {
my $docdef = $whatdef{$warn->{def}};
- @doc = @{$warn->{doc}};
+ my $newpara = 0;
+ foreach my $l (@{$warn->{doc}}) {
+ if ($l =~ /^\s*$/) {
+ $newpara = 1;
+ } else {
+ if ($newpara && $l !~ /^\\c\s+/) {
+ $l = '\> ' . $l;
+ }
+ $newpara = 0;
+ }
+ push(@doc, $l);
+ }
if (defined($docdef)) {
push(@doc, "\n", "\\> $docdef by default.\n");
}
diff --git a/config/unconfig.h b/config/unconfig.h
index d01c2b3e..c7d900fc 100644
--- a/config/unconfig.h
+++ b/config/unconfig.h
@@ -60,6 +60,12 @@
/* Define to 1 if compiled with the `-Wc90-c99-compat' compiler flag */
/* #undef CFLAGS_WC90_C99_COMPAT */
+/* Define to 1 if compiled with the `-Wc99-compat' compiler flag */
+/* #undef CFLAGS_WC99_COMPAT */
+
+/* Define to 1 if compiled with the `-Wc99-extensions' compiler flag */
+/* #undef CFLAGS_WC99_EXTENSIONS */
+
/* Define to 1 if compiled with the `-Werror' compiler flag */
/* #undef CFLAGS_WERROR */
@@ -225,6 +231,10 @@
functions */
/* #undef HAVE_FUNC_ATTRIBUTE_SENTINEL */
+/* Define to 1 if your compiler supports __attribute__((unused)) on functions
+ */
+/* #undef HAVE_FUNC_ATTRIBUTE_UNUSED */
+
/* Define to 1 if your compiler supports __attribute__((alloc_size)) on
function pointers */
/* #undef HAVE_FUNC_PTR_ATTRIBUTE1_ALLOC_SIZE */
@@ -265,6 +275,10 @@
pointers */
/* #undef HAVE_FUNC_PTR_ATTRIBUTE_SENTINEL */
+/* Define to 1 if your compiler supports __attribute__((unused)) on function
+ pointers */
+/* #undef HAVE_FUNC_PTR_ATTRIBUTE_UNUSED */
+
/* Define to 1 if you have the `getgid' function. */
/* #undef HAVE_GETGID */
@@ -714,6 +728,22 @@
# endif
#endif
+#ifndef unused_func
+# ifdef HAVE_FUNC_ATTRIBUTE_UNUSED
+# define unused_func __attribute__((unused))
+# else
+# define unused_func
+# endif
+#endif
+
+#ifndef unused_func_ptr
+# ifdef HAVE_FUNC_PTR_ATTRIBUTE_UNUSED
+# define unused_func_ptr __attribute__((unused))
+# else
+# define unused_func_ptr
+# endif
+#endif
+
#ifndef never_null
# ifdef HAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL
# define never_null __attribute__((returns_nonnull))
diff --git a/configure.ac b/configure.ac
index 85393d03..d9d45837 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,12 +23,6 @@ AC_USE_SYSTEM_EXTENSIONS
AC_SYS_LARGEFILE
AC_PROG_CC
AC_PROG_CC_STDC
-AC_PROG_LN_S
-AC_PROG_MAKE_SET
-AC_PROG_INSTALL
-AC_PROG_MKDIR_P
-
-pa_no_optimize=false
dnl If the user did not specify a CFLAGS default, change default
dnl to -O0 for debugging
@@ -36,6 +30,19 @@ PA_ARG_DISABLED([optimization],
[compile without optimization (-O0) to help debugging],
[pa_no_optimize=true])
+dnl LLVM doesn't error out on invalid -W options unless this option is
+dnl specified first. Enable this so this script can actually discover
+dnl which -W options are possible for this compiler.
+PA_ADD_CFLAGS([-Werror=unknown-warning-option])
+
+dnl Other programs
+AC_PROG_LN_S
+AC_PROG_MAKE_SET
+AC_PROG_INSTALL
+AC_PROG_MKDIR_P
+
+pa_no_optimize=false
+
dnl Compile and link with dwarf debug
PA_ARG_ENABLED([gdb],
[disable optimization and compile with extra debug information for GDB debugger],
@@ -282,6 +289,7 @@ PA_FUNC_ATTRIBUTE(format, [printf,1,2], int, [const char *, ...], ["%d",1])
PA_FUNC_ATTRIBUTE(const)
PA_FUNC_ATTRIBUTE(pure)
PA_FUNC_ATTRIBUTE(cold,,,,,unlikely_func)
+PA_FUNC_ATTRIBUTE(unused)
PA_FUNC_ATTRIBUTE_ERROR
dnl
@@ -320,22 +328,25 @@ PA_ARG_ENABLED([sanitizer],
dnl
dnl Don't make symbols visible, there is no point and it just
-dnl makes the code slower.
+dnl makes the code slower. This mainly affects ELF.
dnl
PA_ADD_CFLAGS([-fvisibility=hidden])
-dnl If we have gcc, add appropriate code cleanliness options
+dnl
+dnl If we have gcc, add appropriate code cleanliness options. Do this
+dnl here at the end, because configure relies on being able to use
+dnl some very, very old C constructs.
+dnl
PA_ADD_CFLAGS([-Wall])
PA_ARG_DISABLED([pedantic],
[disable some extra paranoid compiler warnings],
[],
[PA_ADD_CFLAGS([-W])
PA_ADD_CFLAGS([-pedantic])
- PA_ADD_CFLAGS([-Wc90-c99-compat])])
-dnl LLVM doesn't error out on invalid -W options unless this option is
-dnl specified first. Enable this so this script can actually discover
-dnl which -W options are possible for this compiler.
-PA_ADD_CFLAGS([-Werror=unknown-warning-option])
+ PA_ADD_CFLAGS([-Wc90-c99-compat])
+ PA_ADD_CFLAGS([-Wc99-compat])
+ PA_ADD_CFLAGS([-Wc99-extensions])
+])
dnl Suppress format warning on Windows targets due to their <inttypes.h>
PA_ADD_CFLAGS([-Wpedantic-ms-format],[-Wno-pedantic-ms-format])
PA_ADD_CFLAGS([-Wlong-long],[-Wno-long-long])
@@ -347,6 +358,7 @@ dnl on compilers with gcc-like command line syntax we pass the -fwrapv
dnl option for exactly that reason.
PA_ADD_CFLAGS([-Wshift-negative-value],[-Wno-shift-negative-value])
+dnl Want to turn this on at some point...
dnl PA_ADD_CFLAGS([-Wwrite-strings])
PA_ARG_ENABLED([werror],
[compile with -Werror to error out on any warning],
diff --git a/doc/changes.src b/doc/changes.src
index 29f190d4..f33e3ce4 100644
--- a/doc/changes.src
+++ b/doc/changes.src
@@ -7,6 +7,17 @@
The NASM 2 series supports x86-64, and is the production version of NASM
since 2007.
+\S{cl-2.15.02} Version 2.15.02
+
+\b Fix miscompilation when building with \c{clang}.
+
+\b Add \c{db-empty} warning class, see \k{opt-w}.
+
+\b Some documentation improvements and cleanups.
+
+\b Fix the handling of macro parameter ranges (\c{%\{:\}}), including
+with brace-enclosed original arguments.
+
\S{cl-2.15.01} Version 2.15.01
\b Fix building the documentation from the release archive. For 2.15,
diff --git a/doc/genps.pl b/doc/genps.pl
index 7cbe23c0..b5a1a8a2 100755
--- a/doc/genps.pl
+++ b/doc/genps.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
## --------------------------------------------------------------------------
##
-## Copyright 1996-2017 The NASM Authors - All Rights Reserved
+## Copyright 1996-2020 The NASM Authors - All Rights Reserved
## See the file AUTHORS included with the NASM distribution for
## the specific copyright holders.
##
@@ -775,7 +775,7 @@ sub ps_break_lines($$) {
my $p;
# Code paragraph; each chunk is a line
foreach $p ( @data ) {
- push(@ls, [[$ptype,0,undef,\%BodyFont,0,0],[$p]]);
+ push(@ls, [[$ptype,0,undef,\%CodeFont,0,0],[$p]]);
}
$ls[0]->[0]->[1] |= 1; # First in para
$ls[-1]->[0]->[1] |= 2; # Last in para
diff --git a/doc/head.ps b/doc/head.ps
index 7fbb3a90..6109915d 100644
--- a/doc/head.ps
+++ b/doc/head.ps
@@ -246,10 +246,10 @@
/norm2 { lmarg exch moveto bfont showstream } def
/norm3 { lmarg exch moveto bfont showstream } def
-/code0 { lmarg exch moveto bfont showstream } def
-/code1 { lmarg exch moveto bfont showstream } def
-/code2 { lmarg exch moveto bfont showstream } def
-/code3 { lmarg exch moveto bfont showstream } def
+/code0 { lmarg exch moveto xfont showstream } def
+/code1 { lmarg exch moveto xfont showstream } def
+/code2 { lmarg exch moveto xfont showstream } def
+/code3 { lmarg exch moveto xfont showstream } def
/bull0 { bullmarg exch moveto bfont bwidth showstreamjust } def
/bull1 { dup lmarg exch moveto bullet bfont showstream
diff --git a/doc/nasmdoc.css b/doc/nasmdoc.css
index 6ad9e913..7926d2b4 100644
--- a/doc/nasmdoc.css
+++ b/doc/nasmdoc.css
@@ -18,6 +18,7 @@ span.subtitle {
}
code, pre {
font-family: "source code pro", "liberation mono", "monospace";
+ font-size: 80%;
}
pre, blockquote {
margin-left: 4em;
diff --git a/doc/nasmdoc.src b/doc/nasmdoc.src
index 86b2c826..eb49d1a8 100644
--- a/doc/nasmdoc.src
+++ b/doc/nasmdoc.src
@@ -126,7 +126,13 @@
\IR{+ modifier} \c{+} modifier
\IR{- opsubtraction} \c{-} operator, binary
\IR{- opunary} \c{-} operator, unary
-\IR{! opunary} \c{!} operator, unary
+\IR{! opunary} \c{!} operator
+\IA{A16}{a16}
+\IA{A32}{a32}
+\IA{A64}{a64}
+\IA{O16}{o16}
+\IA{O32}{o32}
+\IA{O64}{o64}
\IR{alignment, in bin sections} alignment, in \c{bin} sections
\IR{alignment, in elf sections} alignment, in ELF sections
\IR{alignment, in win32 sections} alignment, in \c{win32} sections
@@ -152,10 +158,9 @@ variables
\IA{case-sensitive}{case sensitive}
\IA{case-insensitive}{case sensitive}
\IA{character constants}{character constant}
-\IR{codeview} CodeView debugging format
+\IR{codeview debugging format} CodeView debugging format
\IR{common object file format} Common Object File Format
-\IR{common variables, alignment in elf} common variables, alignment
-in ELF
+\IR{common variables, alignment in elf} common variables, alignment in ELF
\IR{common, elf extensions to} \c{COMMON}, ELF extensions to
\IR{common, obj extensions to} \c{COMMON}, \c{obj} extensions to
\IR{declaring structure} declaring structures
@@ -165,15 +170,12 @@ in ELF
\IR{dll symbols, exporting} DLL symbols, exporting
\IR{dll symbols, importing} DLL symbols, importing
\IR{dos} DOS
-\IR{dos archive} DOS archive
-\IR{dos source archive} DOS source archive
-\IR{dup} \c{DUP}
\IA{effective address}{effective addresses}
\IA{effective-address}{effective addresses}
\IR{elf} ELF
\IR{elf, 16-bit code} ELF, 16-bit code
\IR{elf, debug formats} ELF, debug formats
-\IR{elf shared libraries} ELF, shared libraries
+\IR{elf shared library} ELF, shared libraries
\IR{elf32} \c{elf32}
\IR{elf64} \c{elf64}
\IR{elfx32} \c{elfx32}
@@ -186,8 +188,7 @@ in ELF
\IR{freebsd} FreeBSD
\IR{freelink} FreeLink
\IR{functions, c calling convention} functions, C calling convention
-\IR{functions, pascal calling convention} functions, Pascal calling
-convention
+\IR{functions, pascal calling convention} functions, \c{PASCAL} calling convention
\IR{global, aoutb extensions to} \c{GLOBAL}, \c{aoutb} extensions to
\IR{global, elf extensions to} \c{GLOBAL}, ELF extensions to
\IR{global, rdf extensions to} \c{GLOBAL}, \c{rdf} extensions to
@@ -199,9 +200,6 @@ convention
\IR{linux, elf} Linux, ELF
\IR{linux, a.out} Linux, \c{a.out}
\IR{linux, as86} Linux, \c{as86}
-\IR{logical and} logical AND
-\IR{logical or} logical OR
-\IR{logical xor} logical XOR
\IR{mach object file format} Mach, object file format
\IA{mach-o}{macho}
\IR{mach-o} Mach-O, object file format
@@ -215,24 +213,30 @@ convention
\IA{misc directory}{misc subdirectory}
\IR{misc subdirectory} \c{misc} subdirectory
\IR{microsoft omf} Microsoft OMF
-\IR{mmx registers} MMX registers
-\IA{modr/m}{modr/m byte}
-\IR{modr/m byte} ModR/M byte
\IR{ms-dos} MS-DOS
\IR{ms-dos device drivers} MS-DOS device drivers
\IR{multipush} \c{multipush} macro
\IR{nan} NaN
\IR{nasm version} NASM version
+\IR{nasm version history} NASM version, history
+\IR{nasm version macros} NASM version, macros
+\IR{nasm version id} NASM version, ID macro
+\IR{nasm version string} NASM version, string macro
+\IR{arithmetic negation} negation, arithmetic
+\IR{bitwise negation} negation, bitwise
+\IR{boolean negation} negation, boolean
+\IR{boolean and} boolean, AND
+\IR{boolean or} boolean, OR
+\IR{boolean xor} boolean, XOR
\IR{netbsd} NetBSD
\IR{nsis} NSIS
\IR{nullsoft scriptable installer} Nullsoft Scriptable Installer
+\IA{.OBJ}{.obj}
\IR{omf} OMF
\IR{openbsd} OpenBSD
\IR{operating system} operating system
\IR{os/2} OS/2
-\IR{pascal calling convention}Pascal calling convention
-\IR{passes} passes, assembly
-\IR{perl} Perl
+\IR{pascal calling convention} Pascal calling convention
\IR{pic} PIC
\IR{pharlap} PharLap
\IR{plt} PLT
@@ -253,14 +257,16 @@ Object File Format
\IR{section alignment, in win32} section alignment, in \c{win32}
\IR{section, elf extensions to} \c{SECTION}, ELF extensions to
\IR{section, macho extensions to} \c{SECTION}, \c{macho} extensions to
-\IR{section, win32 extensions to} \c{SECTION}, \c{win32} extensions to
+\IR{section, windows extensions to} \c{SECTION}, Windows extensions to
\IR{segment alignment, in bin} segment alignment, in \c{bin}
\IR{segment alignment, in obj} segment alignment, in \c{obj}
-\IR{segment, obj extensions to} \c{SEGMENT}, ELF extensions to
+\IR{segment, obj extensions to} \c{SEGMENT}, \c{obj} extensions to
\IR{segment names, borland pascal} segment names, Borland Pascal
\IR{shift command} \c{shift} command
-\IA{sib}{sib byte}
-\IR{sib byte} SIB byte
+\IA{string constant}{string constants}
+\IR{string constants} string, constants
+\IR{string length} string, length
+\IR{string manipulation in macros} string, manipulation in macros
\IR{align, smart} \c{ALIGN}, smart
\IA{sectalign}{sectalign}
\IR{solaris x86} Solaris x86
@@ -271,7 +277,9 @@ Object File Format
\IR{thread local storage in elf} thread local storage, in ELF
\IR{thread local storage in mach-o} thread local storage, in \c{macho}
\IR{tlink} \c{TLINK}
+\IR{unconditionally importing symbols} importing symbols, unconditionally
\IR{underscore, in c symbols} underscore, in C symbols
+\IA{uninitialized storage}{storage, uninitialized}
\IR{unicode} Unicode
\IR{unix} Unix
\IR{utf-8} UTF-8
@@ -279,20 +287,16 @@ Object File Format
\IR{utf-32} UTF-32
\IA{sco unix}{unix, sco}
\IR{unix, sco} Unix, SCO
-\IA{unix source archive}{unix, source archive}
-\IR{unix, source archive} Unix, source archive
\IA{unix system v}{unix, system v}
\IR{unix, system v} Unix, System V
\IR{unixware} UnixWare
\IR{val} VAL
-\IR{version number of nasm} version number of NASM
+\IA{version number of nasm}{nasm, version}
\IR{visual c++} Visual C++
-\IR{www page} WWW page
\IR{win32} Win32
-\IR{win32} Win64
+\IR{win64} Win64
\IR{windows} Windows
-\IR{windows 95} Windows 95
-\IR{windows nt} Windows NT
+\IR{windows debugging formats} Windows, debugging formats
\# \IC{program entry point}{entry point, program}
\# \IC{program entry point}{start point, program}
\# \IC{MS-DOS device drivers}{device drivers, MS-DOS}
@@ -433,7 +437,7 @@ an intervening space. For example:
\c nasm -f bin driver.asm -odriver.sys
Note that this is a small o, and is different from a capital O , which
-is used to specify the number of optimisation passes required. See \k{opt-O}.
+is used to specify the number of optimization passes required. See \k{opt-O}.
\S{opt-f} The \i\c{-f} Option: Specifying the \i{Output File Format}
@@ -1195,21 +1199,21 @@ defines a symbol called \c{eax}, you can refer to \c{$eax} in NASM
code to distinguish the symbol from the register. Maximum length of
an identifier is 4095 characters.
-The instruction field may contain any machine instruction: Pentium
-and P6 instructions, FPU instructions, MMX instructions and even
+The instruction field may contain any machine instruction: Pentium and
+P6 instructions, FPU instructions, MMX instructions and even
undocumented instructions are all supported. The instruction may be
prefixed by \c{LOCK}, \c{REP}, \c{REPE}/\c{REPZ}, \c{REPNE}/\c{REPNZ},
-\c{XACQUIRE}/\c{XRELEASE} or \c{BND}/\c{NOBND}, in the usual way. Explicit
-\I{address-size prefixes}address-size and \i{operand-size prefixes} \i\c{A16},
-\i\c{A32}, \i\c{A64}, \i\c{O16} and \i\c{O32}, \i\c{O64} are provided - one example of their use
-is given in \k{mixsize}. You can also use the name of a \I{segment
-override}segment register as an instruction prefix: coding
-\c{es mov [bx],ax} is equivalent to coding \c{mov [es:bx],ax}. We
-recommend the latter syntax, since it is consistent with other
-syntactic features of the language, but for instructions such as
-\c{LODSB}, which has no operands and yet can require a segment
-override, there is no clean syntactic way to proceed apart from
-\c{es lodsb}.
+\c{XACQUIRE}/\c{XRELEASE} or \c{BND}/\c{NOBND}, in the usual
+way. Explicit \I{address-size prefixes}address-size and
+\i{operand-size prefixes} \i\c{A16}, \i\c{A32}, \i\c{A64}, \i\c{O16}
+and \i\c{O32}, \i\c{O64} are provided - one example of their use is
+given in \k{mixsize}. You can also use the name of a \I{segment
+override}segment register as an instruction prefix: coding \c{es mov
+[bx],ax} is equivalent to coding \c{mov [es:bx],ax}. We recommend the
+latter syntax, since it is consistent with other syntactic features of
+the language, but for instructions such as \c{LODSB}, which has no
+operands and yet can require a segment override, there is no clean
+syntactic way to proceed apart from \c{es lodsb}.
An instruction is not required to use a prefix: prefixes such as
\c{CS}, \c{A32}, \c{LOCK} or \c{REPE} can appear on a line by
@@ -1250,10 +1254,11 @@ Pseudo-instructions are things which, though not real x86 machine
instructions, are used in the instruction field anyway because that's
the most convenient place to put them. The current pseudo-instructions
are \i\c{DB}, \i\c{DW}, \i\c{DD}, \i\c{DQ}, \i\c{DT}, \i\c{DO},
-\i\c{DY} and \i\c\{DZ}; their \i{uninitialized} counterparts
-\i\c{RESB}, \i\c{RESW}, \i\c{RESD}, \i\c{RESQ}, \i\c{REST},
-\i\c{RESO}, \i\c{RESY} and \i\c\{RESZ}; the \i\c{INCBIN} command, the
-\i\c{EQU} command, and the \i\c{TIMES} prefix.
+\i\c{DY} and \i\c\{DZ}; their \I{storage,
+uninitialized}\i{uninitialized} counterparts \i\c{RESB}, \i\c{RESW},
+\i\c{RESD}, \i\c{RESQ}, \i\c{REST}, \i\c{RESO}, \i\c{RESY} and
+\i\c\{RESZ}; the \i\c{INCBIN} command, the \i\c{EQU} command, and the
+\i\c{TIMES} prefix.
\S{db} \c{DB} and Friends: Declaring Initialized Data
@@ -1280,12 +1285,12 @@ the output file. They can be invoked in a wide range of ways:
\c{DT}, \c{DO}, \c{DY} and \c{DZ} do not accept \i{numeric constants}
as operands.
-\I{masmdb} Starting in NASM 2.15, a the following MASM-like features
+\I{masmdb} Starting in NASM 2.15, a the following \i{MASM}-like features
have been implemented:
-\b A \I{?db}\c{?} argument to declare uninitialized data:
+\b A \I{?db}\c{?} argument to declare \i{uninitialized storage}:
-\c db ? ; uninitialized data
+\c db ? ; uninitialized
\b A superset of the \i\c{DUP} syntax. The NASM version of this has
the following syntax specification; capital letters indicate literal
@@ -1308,7 +1313,7 @@ valid:
\c db 33
\c db (44) ; Integer expression
-\c ; db (44,55) ; Invalid - error
+\c ; db (44,55) ; Invalid - error
\c db %(44,55)
\c db %('XX','YY')
\c db ('AA') ; Integer expression - outputs single byte
@@ -1355,11 +1360,10 @@ the above example could also be written:
\S{incbin} \i\c{INCBIN}: Including External \i{Binary Files}
-\c{INCBIN} is borrowed from the old Amiga assembler \i{DevPac}: it
-includes a binary file verbatim into the output file. This can be
-handy for (for example) including \i{graphics} and \i{sound} data
-directly into a game executable file. It can be called in one of
-these three ways:
+\c{INCBIN} includes binary file data verbatim into the output
+file. This can be handy for (for example) including \i{graphics} and
+\i{sound} data directly into a game executable file. It can be called
+in one of these three ways:
\c incbin "file.dat" ; include the whole file
\c incbin "file.dat",1024 ; skip the first 1024 bytes
@@ -1574,7 +1578,7 @@ Some examples (all producing exactly the same code):
\c mov ax,0b1100_1000 ; same binary constant yet again
\c mov ax,0y1100_1000 ; same binary constant yet again
-\S{strings} \I{Strings}\i{Character Strings}
+\S{strings} \I{string}\I{string constants}\i{Character Strings}
A character string consists of up to eight characters enclosed in
either single quotes (\c{'...'}), double quotes (\c{"..."}) or
@@ -1884,15 +1888,15 @@ The \c{|} operator gives a bitwise OR, exactly as performed by the
\S{expshift} \i{Bit Shift} Operators
\i\c{<<} gives a bit-shift to the left, just as it does in C. So
-\c{5<<3} evaluates to 5 times 8, or 40. \i\c{>>} gives an \e{unsigned}
-(logical) bit-shift to the right; the bits shifted in from the left
-are set to zero.
+\c{5<<3} evaluates to 5 times 8, or 40. \i\c{>>} gives an \I{unsigned,
+bit shift}\e{unsigned} (logical) bit-shift to the right; the bits
+shifted in from the left are set to zero.
\i\c{<<<} gives a bit-shift to the left, exactly equivalent to the
\c{<<} operator; it is included for completeness. \i\c{>>>} gives an
-\e{signed} (arithmetic) bit-shift to the right; the bits shifted in
-from the left are filled with copies of the most significant (sign)
-bit.
+\I{signed, bit shift}\e{signed} (arithmetic) bit-shift to the right;
+the bits shifted in from the left are filled with copies of the most
+significant (sign) bit.
\S{expplmi} \I{+ opaddition}\c{+} and \I{- opsubtraction}\c{-}:
@@ -1906,11 +1910,13 @@ subtraction.
\i\c{*} is the multiplication operator.
-\i\c{/} and \i\c{//} are both division operators: \c{/} is \i{unsigned
-division} and \c{//} is \i{signed division}.
+\i\c{/} and \i\c{//} are both division operators: \c{/} is
+\I{division, unsigned}\I{unsigned, division}unsigned division and \c{//} is
+\I{division, signed}\I{signed, division}signed division.
-Similarly, \i\c{%} and \i\c{%%} provide \I{unsigned modulo}\I{modulo
-operators} unsigned and \i{signed modulo} operators respectively.
+Similarly, \i\c{%} and \i\c{%%} provide \I{modulo,
+unsigned}\I{unsigned, modulo}unsigned and \I{modulo, signed}\I{signed,
+modulo}signed modulo operators respectively.
Since the \c{%} character is used extensively by the macro
\i{preprocessor}, you should ensure that both the signed and unsigned
@@ -1923,22 +1929,27 @@ the signed division operator, such that:
\c b * (a // b) + (a %% b) = a (b != 0)
-\S{expmul} \i{Unary Operators}
+\S{expmul} \I{operators, unary}\i{Unary Operators}
The highest-priority operators in NASM's expression grammar are those
-which only apply to one argument. These are \I{+ opunary}\c{+}, \I{-
-opunary}\c{-}, \i\c{~}, \I{! opunary}\c{!}, \i\c{SEG}, and the
-\i{integer functions} operators.
+which only apply to one argument. These are:
+
+\b \I{- opunary}\c{-} \I{arithmetic negation}negates (\i{2's complement}) its
+operand.
+
+\b \I{+ opunary}\c{+} does nothing; it's provided for symmetry with \c{-}.
+
+\b \I{~ opunary}\c{~} computes the \I{negation, bitwise}\i{bitwise
+negation} (\i{1's complement}) of its operand.
-\c{-} negates its operand, \c{+} does nothing (it's provided for
-symmetry with \c{-}), \c{~} computes the \i{one's complement} of its
-operand, \c{!} is the \i{logical negation} operator.
+\b \I{! opunary}\c{!} is the \I{negation, boolean}\i{boolean negation}
+operator. It evaluates to 1 if the argument is 0, otherwise 0.
-\c{SEG} provides the \i{segment address}
-of its operand (explained in more detail in \k{segwrt}).
+\b \c{SEG} provides the \i{segment address} of its operand (explained in
+more detail in \k{segwrt}).
-A set of additional operators with leading and trailing double
-underscores are used to implement the integer functions of the
+\b A set of additional operators with leading and trailing double
+underscores are used to implement the \c{integer functions} of the
\c{ifunc} macro package, see \k{pkg_ifunc}.
@@ -2239,7 +2250,7 @@ if the argument is never used. For example:
A single pair of parentheses is a subcase of a single, unused argument:
\c %define myreg() eax
-\c mov edx,myreg()
+\c mov edx,myreg()
This is similar to the behavior of the C preprocessor.
@@ -4109,10 +4120,9 @@ be assembled with no pre-defined macros, you can use the \i\c{%clear}
directive to empty the preprocessor of everything but context-local
preprocessor variables and single-line macros, see \k{clear}.
-Most \i{user-level assembler directives} (see \k{directive}) are
-implemented as macros which invoke primitive directives; these are
-described in \k{directive}. The rest of the standard macro set is
-described here.
+Most \i{user-level directives} (see \k{directive}) are implemented as
+macros which invoke primitive directives; these are described in
+\k{directive}. The rest of the standard macro set is described here.
For compability with NASM versions before NASM 2.15, most standard
macros of the form \c{__?foo?__} have aliases of form \c{__foo__} (see
@@ -4120,15 +4130,15 @@ macros of the form \c{__?foo?__} have aliases of form \c{__foo__} (see
defalias}.
-\H{stdmacver} \i{NASM Version} Macros
+\H{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
+\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.
+and \c{__?NASM_PATCHLEVEL?__} would be defined as 1.
Additionally, the macro \i\c{__?NASM_SNAPSHOT?__} is defined for
automatically generated snapshot releases \e{only}.
@@ -4139,7 +4149,7 @@ automatically generated snapshot releases \e{only}.
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
+\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:
@@ -4154,7 +4164,7 @@ 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 version number of nasm being used. So, under NASM 0.98.32 for example,
@@ -4650,13 +4660,17 @@ functionality, as intended to be used primarily with machine-generated code.
It does not include any "programmer-friendly" shortcuts, nor does it in any way
support ASSUME, symbol typing, or MASM-style structures.
-Currently, the MASM compatibility package emulates only the PTR keyword and
-recognize syntax displacement[index] for memory operations.
-
+Currently, the MASM compatibility package emulates only the PTR
+keyword and recognize syntax displacement[index] for memory
+operations.
To enable the package, use the directive:
\c{%use masm}
+In addition, NASM now natively supports the MASM \c{?} and
+\c{DUP} syntax for the \c{DB} etc data declaration directives,
+regardless of if this package is included or not. See \k{db}.
+
\C{directive} \i{Assembler Directives}
@@ -4949,13 +4963,12 @@ declared as \c{EXTERN} and then defined, it will be treated as
\c{EXTERN}, it will be treated as \c{COMMON}.
-\H{required} \i\c{REQUIRED}: \i{Importing Symbols} from Other Modules
+\H{required} \i\c{REQUIRED}: \i{Unconditionally Importing Symbols} from Other Modules
-The \c{REQUIRED} keyword is similar to \c{EXTERN} one. The difference is that
-the \c{EXTERN} keyword as of version 2.15 does not generate unknown symbols, as
-this behavior is highly undesirable when using common header files,
-because it might cause the linker to pull in a bunch of unnecessary modules,
-depending on how smart the linker is.
+The \c{REQUIRED} keyword is similar to \c{EXTERN} one. The difference
+is that the \c{EXTERN} keyword as of version 2.15 does not generate
+unknown symbols as that prevents using common header files, as it
+might cause the linker to pull in a bunch of unnecessary modules.
If the old behavior is required, use \c{REQUIRED} keyword instead.
@@ -5244,7 +5257,7 @@ does. See \k{proborg} for further comments.
\S{binseg} \c{bin} Extensions to the \c{SECTION}
-Directive\I{SECTION, bin extensions to}
+Directive\I{\c{SECTION}, \c{bin} extensions to}
The \c{bin} output format extends the \c{SECTION} (or \c{SEGMENT})
directive to allow you to specify the alignment requirements of
@@ -5557,7 +5570,7 @@ be specified, even if it is the same as the internal name. The
available attributes are:
\b \c{resident} indicates that the exported name is to be kept
-resident by the system loader. This is an optimisation for
+resident by the system loader. This is an optimization for
frequently used symbols imported by name.
\b \c{nodata} indicates that the exported symbol is a function which
@@ -5701,7 +5714,7 @@ files that Win32 linkers can generate correct output from.
\S{win32sect} \c{win32} Extensions to the \c{SECTION}
-Directive\I{SECTION, win32 extensions to}
+Directive\I{SECTION, Windows extensions to}
Like the \c{obj} format, \c{win32} allows you to specify additional
information on the \c{SECTION} directive line, to control the type
@@ -5847,8 +5860,8 @@ later can still be linked by earlier versions or non-Microsoft linkers.
\S{codeview} Debugging formats for Windows
\I{Windows debugging formats}
-The \c{win32} and \c{win64} formats support the Microsoft CodeView
-debugging format. Currently CodeView version 8 format is supported
+The \c{win32} and \c{win64} formats support the Microsoft \i{CodeView
+debugging format}. Currently CodeView version 8 format is supported
(\i\c{cv8}), but newer versions of the CodeView debugger should be
able to handle this format as well.
@@ -6420,14 +6433,14 @@ of the symbol with code such as:
\S{elfglob} \c{elf} Extensions to the \c{GLOBAL} Directive\I{GLOBAL,
elf extensions to}\I{GLOBAL, aoutb extensions to}
-\c{ELF} object files can contain more information about a global symbol
-than just its address: they can contain the \I{symbol sizes,
-specifying}\I{size, of symbols}size of the symbol and its \I{symbol
-types, specifying}\I{type, of symbols}type as well. These are not
-merely debugger conveniences, but are actually necessary when the
-program being written is a \i{shared library}. NASM therefore
-supports some extensions to the \c{GLOBAL} directive, allowing you
-to specify these features.
+\c{ELF} object files can contain more information about a global
+symbol than just its address: they can contain the \I{symbols,
+specifying sizes}\I{size, of symbols}size of the symbol and its
+\I{symbols, specifying types}\I{type, of symbols}type as well. These
+are not merely debugger conveniences, but are actually necessary when
+the program being written is a \I{elf shared library}shared
+library. NASM therefore supports some extensions to the \c{GLOBAL}
+directive, allowing you to specify these features.
You can specify whether a global variable is a function or a data
object by suffixing the name with a colon and the word
@@ -6731,7 +6744,7 @@ also, have to be built as \c{.EXE} files, since Windows does not
support the \c{.COM} format.
In general, you generate \c{.EXE} files by using the \c{obj} output
-format to produce one or more \i\c{.OBJ} files, and then linking
+format to produce one or more \i\c{.obj} files, and then linking
them together using a linker. However, NASM also supports the direct
generation of simple DOS \c{.EXE} files using the \c{bin} output
format (by using \c{DB} and \c{DW} to construct the \c{.EXE} file
@@ -8060,7 +8073,7 @@ and create \c{library.so.1} as a symbolic link to it.
This chapter tries to cover some of the issues, largely related to
unusual forms of addressing and jump instructions, encountered when
-writing operating system code such as protected-mode initialisation
+writing operating system code such as protected-mode initialization
routines, which require code that operates in mixed segment sizes,
such as code in a 16-bit segment trying to modify data in a 32-bit
one, or jumps between different-size segments.
@@ -8571,7 +8584,7 @@ Hence, to disassemble a \c{.COM} file:
will do the trick.
-\S{ndissync} Code Following Data: Synchronisation
+\S{ndissync} Code Following Data: Synchronization
Suppose you are disassembling a file which contains some data which
isn't machine code, and \e{then} contains some machine code. NDISASM
@@ -8590,8 +8603,8 @@ then the correct first instruction in the code section will not be
seen because the starting point skipped over it. This isn't really
ideal.
-To avoid this, you can specify a `\i{synchronisation}' point, or indeed
-as many synchronisation points as you like (although NDISASM can
+To avoid this, you can specify a `\i{synchronization}' point, or indeed
+as many synchronization points as you like (although NDISASM can
only handle 2147483647 sync points internally). The definition of a sync
point is this: NDISASM guarantees to hit sync points exactly during
disassembly. If it is thinking about generating an instruction which
@@ -8615,7 +8628,7 @@ As stated above, you can specify multiple sync markers if you need
to, just by repeating the \c{-s} option.
-\S{ndisisync} Mixed Code and Data: Automatic (Intelligent) Synchronisation
+\S{ndisisync} Mixed Code and Data: Automatic (Intelligent) Synchronization
\I\c{auto-sync}
Suppose you are disassembling the boot sector of a \c{DOS} floppy (maybe
@@ -8734,8 +8747,9 @@ the \c{git} distributed source control system. The link is available
on the website. This is recommended only to participate in the
development of NASM or to assist with testing the development code.
-To build NASM from the \c{git} repository you will need a Perl and, if
-building on a Unix system, GNU autoconf.
+To build NASM from the \c{git} repository you will need a Perl
+interpreter and, if building on a Unix system, GNU autoconf installed
+on your system.
To build on a Unix system, run:
@@ -8743,6 +8757,14 @@ To build on a Unix system, run:
to create the \c{configure} script and then build as listed above.
+\H{builddoc} Building the documentation
+
+To build the documentation, you will need a Perl interpreter, a
+Postscript to PDF converter such as Ghostscript, and suitable fonts
+installed on your system. The recommended (and default) fonts are
+Adobe's Source Sans and Source Code fonts, which are freely available
+under the SIL Open Font License.
+
\A{contact} Contact Information
\H{website} Website
diff --git a/doc/psfonts.ph b/doc/psfonts.ph
index 093d9dc4..9ebbe09d 100644
--- a/doc/psfonts.ph
+++ b/doc/psfonts.ph
@@ -21,33 +21,54 @@ my @QText = ('SourceSansPro-It', 'ClearSans-Italic', 'LiberationSans-Italic',
'Arial-Italic', 'Helvetica-Italic');
my @QBold = ('SourceSansPro-BoldIt', 'ClearSans-BoldItalic', 'LiberationSans-BoldItalic', 'Arial-Bold', 'Helvetica-BoldItalic');
my @QCode = ('SourceCodePro-Regular', 'LiberationMono', 'Courier');
+my @XCode = ('SourceCodePro-Regular', 'LiberationMono', 'Courier');
# The fonts we want to use for various things
# The order is: <normal> <emphatic> <code>
+my $lf = 1.2; # Leading scale factor
+my $cf = 0.8; # Code size scale factor
+
+my $st = 20;
%TitlFont = (name => 'tfont',
- leading => 24,
- fonts => [[20, \@TText], [20, \@TItal], [20, \@TCode]]);
+ leading => $st*$lf,
+ fonts => [[$st, \@TText], [$st, \@TItal], [$st*$cf, \@TCode]]);
+
+my $sc = 18;
%ChapFont = (name => 'cfont',
- leading => 21.6,
- fonts => [[18, \@HText], [18, \@HItal], [18, \@HCode]]);
+ leading => $sc*$lf,
+ fonts => [[$sc, \@HText], [$sc, \@HItal], [$sc*$cf, \@HCode]]);
+
+my $sh = 14;
%HeadFont = (name => 'hfont',
- leading => 16.8,
- fonts => [[14, \@HText], [14, \@HItal], [14, \@HCode]]);
+ leading => $sh*$lf,
+ fonts => [[$sh, \@HText], [$sh, \@HItal], [$sh*$cf, \@HCode]]);
+
+my $ss = 12;
%SubhFont = (name => 'sfont',
- leading => 14.4,
- fonts => [[12, \@HText], [12, \@HItal], [12, \@HCode]]);
+ leading => $ss*$lf,
+ fonts => [[$ss, \@HText], [$ss, \@HItal], [$ss*$cf, \@HCode]]);
+
+my $sb = 10;
%BodyFont = (name => 'bfont',
- leading => 12,
- fonts => [[10, \@BText], [10, \@BItal], [10, \@BCode]]);
+ leading => $sb*$lf,
+ fonts => [[$sb, \@BText], [$sb, \@BItal], [$sb*$cf, \@BCode]]);
+
+my $sq = 9;
%BquoFont = (name => 'qfont',
- leading => 10.8,
- fonts => [[9, \@QText], [9, \@QBold], [9, \@QCode]]);
+ leading => $sq*$lf,
+ fonts => [[$sq, \@QText], [$sq, \@QBold], [$sq*$cf, \@QCode]]);
+
+my $sx = $sb*$cf;
+%CodeFont = (name => 'xfont',
+ leading => $sx*$lf,
+ fonts => [[$sx, \@XCode], [$sx, \@XCode], [$sx, \@XCode]]);
+
#
# List of all fontsets; used to compute the list of fonts needed
#
@AllFonts = ( \%TitlFont, \%ChapFont, \%HeadFont, \%SubhFont, \%BodyFont,
- \%BquoFont);
+ \%BquoFont, \%CodeFont );
# OK
1;
diff --git a/include/compiler.h b/include/compiler.h
index 43984338..a1905d27 100644
--- a/include/compiler.h
+++ b/include/compiler.h
@@ -1,5 +1,5 @@
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 2007-2018 The NASM Authors - All Rights Reserved
* See the file AUTHORS included with the NASM distribution for
* the specific copyright holders.
@@ -14,7 +14,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
@@ -310,6 +310,27 @@ static inline void *mempcpy(void *dst, const void *src, size_t n)
#define printf_func(fmt, list) format_func3(printf,fmt,list)
#define printf_func_ptr(fmt, list) format_func3_ptr(printf,fmt,list)
+/*
+ * A static [inline] function which either is currently unused but
+ * likely to be used in the future, or used only under some #if
+ * combinations. Mark with this option to suppress compiler
+ * warnings.
+ *
+ * This is better than #if(def) because it still lets the compiler
+ * analyze the function for validity, and it works even for the
+ * conditional use case.
+ *
+ * The macro UNUSED is set to 1 if the unused macro is meaningful,
+ * otherwise 0; this may be useful in some #if statements.
+ */
+#ifdef HAVE_FUNC_ATTRIBUTE_UNUSED
+# define unused __attribute__((unused))
+# define UNUSED 1
+#else
+# define unused
+# define UNUSED 0
+#endif
+
/* Determine probabilistically if something is a compile-time constant */
#ifdef HAVE___BUILTIN_CONSTANT_P
# if defined(__GNUC__) && (__GNUC__ >= 5)
diff --git a/include/strlist.h b/include/strlist.h
index 2c80d0be..f1775abd 100644
--- a/include/strlist.h
+++ b/include/strlist.h
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------- *
*
- * Copyright 1996-2018 The NASM Authors - All Rights Reserved
+ * Copyright 1996-2020 The NASM Authors - All Rights Reserved
* See the file AUTHORS included with the NASM distribution for
* the specific copyright holders.
*
@@ -78,10 +78,10 @@ static inline size_t strlist_size(const struct strlist *list)
}
struct strlist safe_alloc *strlist_alloc(bool uniq);
-const struct strlist_entry * never_null strlist_add(struct strlist *list, const char *str);
-const struct strlist_entry * printf_func(2, 3) never_null
+const struct strlist_entry *strlist_add(struct strlist *list, const char *str);
+const struct strlist_entry * printf_func(2, 3)
strlist_printf(struct strlist *list, const char *fmt, ...);
-const struct strlist_entry * never_null
+const struct strlist_entry *
strlist_vprintf(struct strlist *list, const char *fmt, va_list ap);
const struct strlist_entry *
strlist_find(const struct strlist *list, const char *str);
diff --git a/macros/macros.pl b/macros/macros.pl
index 9fc425d4..517a9e6f 100755
--- a/macros/macros.pl
+++ b/macros/macros.pl
@@ -276,19 +276,19 @@ print OUT " };\n";
# Put a large value in unused slots. This makes it extremely unlikely
# that any combination that involves unused slot will pass the range test.
# This speeds up rejection of unrecognized tokens, i.e. identifiers.
-print OUT "#define UNUSED (65535/3)\n";
+print OUT "#define UNUSED_HASH_ENTRY (65535/3)\n";
print OUT " static const int16_t hash1[$n] = {\n";
for ($i = 0; $i < $n; $i++) {
my $h = ${$g}[$i*2+0];
- print OUT " ", defined($h) ? $h : 'UNUSED', ",\n";
+ print OUT " ", defined($h) ? $h : 'UNUSED_HASH_ENTRY', ",\n";
}
print OUT " };\n";
print OUT " static const int16_t hash2[$n] = {\n";
for ($i = 0; $i < $n; $i++) {
my $h = ${$g}[$i*2+1];
- print OUT " ", defined($h) ? $h : 'UNUSED', ",\n";
+ print OUT " ", defined($h) ? $h : 'UNUSED_HASH_ENTRY', ",\n";
}
print OUT " };\n";
diff --git a/nasmlib/perfhash.pl b/nasmlib/perfhash.pl
index 8df21f69..9236bfec 100755
--- a/nasmlib/perfhash.pl
+++ b/nasmlib/perfhash.pl
@@ -334,18 +334,18 @@ if ($output eq 'h') {
}
print F "\n};\n\n";
- print F "#define UNUSED (65536/3)\n\n";
+ print F "#define UNUSED_HASH_ENTRY (65536/3)\n\n";
printf F "static const int16_t %s_hashvals[%d] = ", $name, $n*2;
$c = '{';
for (my $i = 0; $i < $n; $i++) {
my $h = ${$g}[$i*2+0];
- print F "$c\n ", defined($h) ? $h : 'UNUSED';
+ print F "$c\n ", defined($h) ? $h : 'UNUSED_HASH_ENTRY';
$c = ',';
}
for (my $i = 0; $i < $n; $i++) {
my $h = ${$g}[$i*2+1];
- print F "$c\n ", defined($h) ? $h : 'UNUSED';
+ print F "$c\n ", defined($h) ? $h : 'UNUSED_HASH_ENTRY';
$c = ',';
}
print F "\n};\n\n";
diff --git a/nasmlib/strlist.c b/nasmlib/strlist.c
index db5a09ab..449304b7 100644
--- a/nasmlib/strlist.c
+++ b/nasmlib/strlist.c
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------- *
*
- * Copyright 1996-2018 The NASM Authors - All Rights Reserved
+ * Copyright 1996-2020 The NASM Authors - All Rights Reserved
* See the file AUTHORS included with the NASM distribution for
* the specific copyright holders.
*
@@ -102,7 +102,8 @@ strlist_add(struct strlist *list, const char *str)
const struct strlist_entry *
strlist_vprintf(struct strlist *list, const char *fmt, va_list ap)
{
- struct strlist_entry *e;
+ /* clang miscompiles offsetin() unless e is initialized here */
+ struct strlist_entry *e = NULL;
struct hash_insert hi;
if (!list)
diff --git a/test/dup.asm b/test/dup.asm
index 723da48b..62785628 100644
--- a/test/dup.asm
+++ b/test/dup.asm
@@ -19,3 +19,18 @@
dd 16 dup (0xaaaa, ?, 0xbbbbbb)
dd 64 dup (?)
+
+ resb 1
+ resb 2
+ resb 4
+ resb 8
+
+ resw 1
+ resw 2
+ resw 4
+ resw 8
+
+ resq 1
+ resq 2
+ resq 4
+ resq 8
diff --git a/test/emptyarg.asm b/test/emptyarg.asm
index 0627dfae..af02e378 120000..100644
--- a/test/emptyarg.asm
+++ b/test/emptyarg.asm
@@ -1 +1,147 @@
-../../nasm-2.14.xx/test/emptyarg.asm \ No newline at end of file
+%define EMPTY
+
+%macro bar 1
+ db "bar", __LINE__, %0, %1
+%endmacro
+
+%macro baz 2
+ db "baz", __LINE__, %0, %1, %2
+%endmacro
+
+%macro nothing 0
+ db "nothing", __LINE__, %0
+%endmacro
+
+%macro xyzzy 1-2
+ db "xyzzy", __LINE__, %0, %1, %2, %3
+%endmacro
+
+%macro vararg 0-*
+ db "vararg", __LINE__, %0
+ %assign %%i 1
+ %rep %0
+ db "vararg arg ", %%i, %1
+ %rotate 1
+ %assign %%i %%i + 1
+ %endrep
+%endmacro
+
+%macro defargs 1-5 def2, def3, def4, def5
+ db "defargs", __LINE__, %0, %1, %2, %3, %4, %5
+%endmacro
+
+%macro ivar 1
+ vararg %1
+%endmacro
+
+%macro foo 1-2
+ db "foo", __LINE__, %0, %1, %2
+ bar %2
+ bar {%2}
+ bar %2,
+ bar {%2},
+ baz %1,%2
+ baz {%1},{%2}
+ nothing %1
+ nothing %2
+ xyzzy "meep",%1,%2,
+ xyzzy "meep","meep",%1,%2
+ xyzzy "alpha","bravo",
+ xyzzy "with","empty",EMPTY
+%endmacro
+
+%macro orange 1
+ db %{1:1}
+%endmacro
+
+%macro prange1 2-3
+ db %{1:2}, 0%3
+%endmacro
+
+%macro prange2 1-3 'two', 'three'
+ db %{1:3}
+%endmacro
+
+ db 4,
+ nothing
+ nothing 1
+ nothing ; foo
+ nothing EMPTY
+
+flup: foo 1,2
+ foo 3
+ bar
+ bar EMPTY
+ foo 6,
+ foo 6, ; With space/comment
+ foo 6,EMPTY
+ baz 8,EMPTY
+ foo 6,{}
+ foo ,5
+
+ xyzzy 13,14,15,
+ xyzzy 13,14,15,EMPTY
+ xyzzy 20,21
+ xyzzy 22,23,
+ xyzzy 24,25,EMPTY
+ xyzzy 26,27,,
+ xyzzy 28,29,EMPTY,EMPTY
+
+ vararg
+ vararg EMPTY
+ vararg ,
+ vararg 10
+ vararg 11,
+ vararg 12,EMPTY
+ vararg 13,14,15,
+ vararg 13,14,15,EMPTY
+ vararg 20,21
+ vararg 22,23,
+ vararg 24,25,EMPTY
+ vararg 26,27,,
+ vararg 28,29,EMPTY,EMPTY
+
+ ivar {}
+ ivar {EMPTY}
+ ivar EMPTY
+ ivar ,
+ ivar {,}
+ ivar {60}
+ ivar {61,}
+ ivar {62,EMPTY}
+ ivar {63,64,65,}
+ ivar {63,64,65,EMPTY}
+ ivar {70,71}
+ ivar {72,73,}
+ ivar {74,75,EMPTY}
+ ivar {76,77,,}
+ ivar {78,79,EMPTY,EMPTY}
+
+ defargs EMPTY
+ defargs 91
+ defargs 91,92
+ defargs 91,92,93
+ defargs 91,92,93,94
+ defargs 91,92,93,94,95
+ defargs ,
+ defargs 91,
+ defargs 91,92,
+ defargs 91,92,93,
+ defargs 91,92,93,94,
+ defargs 91,92,93,94,95,
+
+ prange1 101
+ prange1 101, 102
+ prange1 101, 102, 103
+ prange2 121
+ prange2 121, 122
+ prange2 121, 122, 123
+ prange2 {121}
+ prange2 {121,121}
+ prange2 {121},{122}
+ prange2 {121},122,{123}
+ prange2 121,{122,122},123
+
+ orange 130
+ orange 130, 131
+ orange {130, 131}