|
|
5fc368 |
From 01fea662b22875b8f94aa2ab5f836acf7b0378f1 Mon Sep 17 00:00:00 2001
|
|
|
5fc368 |
From: Cyrill Gorcunov <gorcunov@gmail.com>
|
|
|
5fc368 |
Date: Sun, 17 Feb 2013 22:50:19 +0400
|
|
|
5fc368 |
Subject: [PATCH] Generate manpages from asciidoc format
|
|
|
5fc368 |
|
|
|
5fc368 |
---
|
|
|
5fc368 |
Makefile.in | 14 +-
|
|
|
5fc368 |
configure.in | 4 +-
|
|
|
5fc368 |
nasm.1 | 535 -----------------------------------------------------------
|
|
|
5fc368 |
nasm.txt | 303 +++++++++++++++++++++++++++++++++
|
|
|
5fc368 |
ndisasm.1 | 129 --------------
|
|
|
5fc368 |
ndisasm.txt | 94 +++++++++++
|
|
|
5fc368 |
6 files changed, 410 insertions(+), 669 deletions(-)
|
|
|
5fc368 |
delete mode 100644 nasm.1
|
|
|
5fc368 |
create mode 100644 nasm.txt
|
|
|
5fc368 |
delete mode 100644 ndisasm.1
|
|
|
5fc368 |
create mode 100644 ndisasm.txt
|
|
|
5fc368 |
|
|
|
5fc368 |
diff --git a/Makefile.in b/Makefile.in
|
|
|
5fc368 |
index d7b4e22..46b7c00 100644
|
|
|
5fc368 |
--- a/Makefile.in
|
|
|
5fc368 |
+++ b/Makefile.in
|
|
|
5fc368 |
@@ -31,6 +31,8 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
|
|
5fc368 |
INSTALL_DATA = @INSTALL_DATA@
|
|
|
5fc368 |
|
|
|
5fc368 |
NROFF = @NROFF@
|
|
|
5fc368 |
+ASCIIDOC = @ASCIIDOC@
|
|
|
5fc368 |
+XMLTO = @XMLTO@
|
|
|
5fc368 |
|
|
|
5fc368 |
MKDIR = mkdir
|
|
|
5fc368 |
RM = rm
|
|
|
5fc368 |
@@ -47,7 +49,7 @@ ifeq ($(TRACE),1)
|
|
|
5fc368 |
CFLAGS += -DNASM_TRACE
|
|
|
5fc368 |
endif
|
|
|
5fc368 |
|
|
|
5fc368 |
-.SUFFIXES: .c .i .s .$(O) .1 .man
|
|
|
5fc368 |
+.SUFFIXES: .c .i .s .$(O) .1 .txt .xml
|
|
|
5fc368 |
|
|
|
5fc368 |
.PHONY: all doc rdf install clean distclean cleaner spotless install_rdf test
|
|
|
5fc368 |
.PHONY: install_doc everything install_everything strip perlreq dist tags TAGS
|
|
|
5fc368 |
@@ -61,8 +63,12 @@ endif
|
|
|
5fc368 |
.c.i:
|
|
|
5fc368 |
$(CC) -E $(ALL_CFLAGS) -o $@ $<
|
|
|
5fc368 |
|
|
|
5fc368 |
-.1.man:
|
|
|
5fc368 |
- $(NROFF) -man $< > $@
|
|
|
5fc368 |
+.txt.xml:
|
|
|
5fc368 |
+ $(ASCIIDOC) -b docbook -d manpage -o $@ $<
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+.xml.1:
|
|
|
5fc368 |
+ $(XMLTO) man --skip-validation $< 2>/dev/null
|
|
|
5fc368 |
+
|
|
|
5fc368 |
|
|
|
5fc368 |
#-- Begin File Lists --#
|
|
|
5fc368 |
NASM = nasm.$(O) nasmlib.$(O) ver.$(O) \
|
|
|
5fc368 |
@@ -88,7 +94,7 @@ NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) nasmlib.$(O) ver.$(O) \
|
|
|
5fc368 |
insnsd.$(O) insnsb.$(O) insnsn.$(O) regs.$(O) regdis.$(O)
|
|
|
5fc368 |
#-- End File Lists --#
|
|
|
5fc368 |
|
|
|
5fc368 |
-all: nasm$(X) ndisasm$(X) nasm.man ndisasm.man rdf
|
|
|
5fc368 |
+all: nasm$(X) ndisasm$(X) nasm.1 ndisasm.1 rdf
|
|
|
5fc368 |
|
|
|
5fc368 |
nasm$(X): $(NASM) $(XOBJS)
|
|
|
5fc368 |
$(CC) $(LDFLAGS) -o nasm$(X) $(NASM) $(XOBJS) $(LIBS)
|
|
|
5fc368 |
diff --git a/configure.in b/configure.in
|
|
|
5fc368 |
index 8c6a429..da2154d 100644
|
|
|
5fc368 |
--- a/configure.in
|
|
|
5fc368 |
+++ b/configure.in
|
|
|
5fc368 |
@@ -67,7 +67,9 @@ PA_ADD_CFLAGS([-std=c99])
|
|
|
5fc368 |
PA_ADD_CFLAGS([-pedantic])
|
|
|
5fc368 |
|
|
|
5fc368 |
dnl Look for programs...
|
|
|
5fc368 |
-AC_CHECK_PROGS(NROFF, nroff, echo)
|
|
|
5fc368 |
+AC_CHECK_PROGS(NROFF, nroff, false)
|
|
|
5fc368 |
+AC_CHECK_PROGS(ASCIIDOC, asciidoc, false)
|
|
|
5fc368 |
+AC_CHECK_PROGS(XMLTO, xmlto, false)
|
|
|
5fc368 |
AC_CHECK_PROGS(ACRODIST, acrodist, false)
|
|
|
5fc368 |
AC_CHECK_PROGS(PS2PDF, ps2pdf, false)
|
|
|
5fc368 |
AC_CHECK_PROGS(PSTOPDF, pstopdf, false)
|
|
|
5fc368 |
diff --git a/nasm.1 b/nasm.1
|
|
|
5fc368 |
deleted file mode 100644
|
|
|
5fc368 |
index bca0cd5..0000000
|
|
|
5fc368 |
--- a/nasm.1
|
|
|
5fc368 |
+++ /dev/null
|
|
|
5fc368 |
@@ -1,535 +0,0 @@
|
|
|
5fc368 |
-.TH NASM 1 "The Netwide Assembler Project"
|
|
|
5fc368 |
-.SH NAME
|
|
|
5fc368 |
-nasm \- the Netwide Assembler, a portable 80x86 assembler
|
|
|
5fc368 |
-.SH SYNOPSIS
|
|
|
5fc368 |
-.B nasm
|
|
|
5fc368 |
-[
|
|
|
5fc368 |
-.B \-@
|
|
|
5fc368 |
-response file
|
|
|
5fc368 |
-] [
|
|
|
5fc368 |
-.B \-f
|
|
|
5fc368 |
-format
|
|
|
5fc368 |
-] [
|
|
|
5fc368 |
-.B \-o
|
|
|
5fc368 |
-outfile
|
|
|
5fc368 |
-] [
|
|
|
5fc368 |
-.B \-l
|
|
|
5fc368 |
-listfile
|
|
|
5fc368 |
-] [
|
|
|
5fc368 |
-.IR options ...
|
|
|
5fc368 |
-] filename
|
|
|
5fc368 |
-.br
|
|
|
5fc368 |
-.B nasm \-h
|
|
|
5fc368 |
-.br
|
|
|
5fc368 |
-.B nasm \-v
|
|
|
5fc368 |
-.SH DESCRIPTION
|
|
|
5fc368 |
-The
|
|
|
5fc368 |
-.B nasm
|
|
|
5fc368 |
-command assembles the file
|
|
|
5fc368 |
-.I filename
|
|
|
5fc368 |
-and directs output to the file
|
|
|
5fc368 |
-.I outfile
|
|
|
5fc368 |
-if specified. If
|
|
|
5fc368 |
-.I outfile
|
|
|
5fc368 |
-is not specified,
|
|
|
5fc368 |
-.B nasm
|
|
|
5fc368 |
-will derive a default output file name from the name of its input
|
|
|
5fc368 |
-file, usually by appending `.o' or `.obj', or by removing all
|
|
|
5fc368 |
-extensions for a raw binary file. Failing that, the output file name
|
|
|
5fc368 |
-will be `nasm.out'.
|
|
|
5fc368 |
-.SS OPTIONS
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-@ " filename"
|
|
|
5fc368 |
-Causes
|
|
|
5fc368 |
-.B nasm
|
|
|
5fc368 |
-to process options from
|
|
|
5fc368 |
-.I filename
|
|
|
5fc368 |
-as if they were included on the command line.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.B \-a
|
|
|
5fc368 |
-Causes
|
|
|
5fc368 |
-.B nasm
|
|
|
5fc368 |
-to assemble the given input file without first applying the macro
|
|
|
5fc368 |
-preprocessor.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-D " macro[=value]"
|
|
|
5fc368 |
-Pre-defines a single-line macro.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-d " macro[=value]"
|
|
|
5fc368 |
-Same as the
|
|
|
5fc368 |
-.B \-D
|
|
|
5fc368 |
-option.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.B \-e
|
|
|
5fc368 |
-Causes
|
|
|
5fc368 |
-.B nasm
|
|
|
5fc368 |
-to preprocess the given input file, and write the output to
|
|
|
5fc368 |
-.I stdout
|
|
|
5fc368 |
-(or the specified output file name), and not actually assemble
|
|
|
5fc368 |
-anything.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-f " format"
|
|
|
5fc368 |
-Specifies the output file format. To see a list of valid output
|
|
|
5fc368 |
-formats, use the
|
|
|
5fc368 |
-.B -hf
|
|
|
5fc368 |
-option.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.B \-g
|
|
|
5fc368 |
-Causes
|
|
|
5fc368 |
-.B nasm
|
|
|
5fc368 |
-to generate debug information in selected format
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.B \-h
|
|
|
5fc368 |
-Causes
|
|
|
5fc368 |
-.B nasm
|
|
|
5fc368 |
-to exit immediately, after giving a summary of its invocation
|
|
|
5fc368 |
-options.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.B \-hf
|
|
|
5fc368 |
-Same as
|
|
|
5fc368 |
-.B -h
|
|
|
5fc368 |
-, but also lists all valid output formats.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-I " directory"
|
|
|
5fc368 |
-Adds a directory to the search path for include files. The directory
|
|
|
5fc368 |
-specification must include the trailing slash, as it will be
|
|
|
5fc368 |
-directly prepended to the name of the include file.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-i " directory"
|
|
|
5fc368 |
-Same as the
|
|
|
5fc368 |
-.B \-I
|
|
|
5fc368 |
-option.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-l " listfile"
|
|
|
5fc368 |
-Causes an assembly listing to be directed to the given file, in
|
|
|
5fc368 |
-which the original source is displayed on the right hand side (plus
|
|
|
5fc368 |
-the source for included files and the expansions of multi-line
|
|
|
5fc368 |
-macros) and the generated code is shown in hex on the left.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.B \-M
|
|
|
5fc368 |
-Causes
|
|
|
5fc368 |
-.B nasm
|
|
|
5fc368 |
-to output Makefile-style dependencies to stdout; normal output is
|
|
|
5fc368 |
-suppressed.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-MG " file"
|
|
|
5fc368 |
-Same as
|
|
|
5fc368 |
-.B \-M
|
|
|
5fc368 |
-but assumes that missing Makefile dependecies are generated and added
|
|
|
5fc368 |
-to dependency list without a prefix.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-MF " file"
|
|
|
5fc368 |
-Output Makefile-style dependencies to the specified file.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-MD " file"
|
|
|
5fc368 |
-Same as a combination of
|
|
|
5fc368 |
-.B \-M
|
|
|
5fc368 |
-and
|
|
|
5fc368 |
-.B \-MF
|
|
|
5fc368 |
-options.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-MT " file"
|
|
|
5fc368 |
-Override the default name of the dependency target
|
|
|
5fc368 |
-dependency target name. This is normally the same
|
|
|
5fc368 |
-as the output filename, specified by the
|
|
|
5fc368 |
-.B \-o
|
|
|
5fc368 |
-option.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-MQ " file"
|
|
|
5fc368 |
-The same as
|
|
|
5fc368 |
-.B \-MT
|
|
|
5fc368 |
-except it tries to quote characters that have special
|
|
|
5fc368 |
-meaning in Makefile syntax. This is not foolproof,
|
|
|
5fc368 |
-as not all characters with special meaning are quotable
|
|
|
5fc368 |
-in Make.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-MP
|
|
|
5fc368 |
-Emit phony target
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-O " number"
|
|
|
5fc368 |
-Optimize branch offsets.
|
|
|
5fc368 |
-.ti
|
|
|
5fc368 |
-.B \-O0
|
|
|
5fc368 |
-:No optimization
|
|
|
5fc368 |
-.ti
|
|
|
5fc368 |
-.B \-O1
|
|
|
5fc368 |
-:Minimal optimization
|
|
|
5fc368 |
-.ti
|
|
|
5fc368 |
-.B \-Ox
|
|
|
5fc368 |
-:Multipass optimization (default)
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-o " outfile"
|
|
|
5fc368 |
-Specifies a precise name for the output file, overriding
|
|
|
5fc368 |
-.BR nasm 's
|
|
|
5fc368 |
-default means of determining it.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-P " file"
|
|
|
5fc368 |
-Specifies a file to be pre-included, before the main source file
|
|
|
5fc368 |
-starts to be processed.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-p " file"
|
|
|
5fc368 |
-Same as the
|
|
|
5fc368 |
-.B \-P
|
|
|
5fc368 |
-option.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-r
|
|
|
5fc368 |
-Causes
|
|
|
5fc368 |
-.B nasm
|
|
|
5fc368 |
-to exit immediately, after displaying its version number.
|
|
|
5fc368 |
-.I (obsolete)
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.B \-s
|
|
|
5fc368 |
-Causes
|
|
|
5fc368 |
-.B nasm
|
|
|
5fc368 |
-to send its error messages and/or help text to
|
|
|
5fc368 |
-.I stdout
|
|
|
5fc368 |
-instead of
|
|
|
5fc368 |
-.IR stderr .
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.B \-t
|
|
|
5fc368 |
-Causes
|
|
|
5fc368 |
-.B nasm
|
|
|
5fc368 |
-to assemble in SciTech TASM compatible mode
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-U " macro"
|
|
|
5fc368 |
-Undefines a single-line macro.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-u " macro"
|
|
|
5fc368 |
-Same as the
|
|
|
5fc368 |
-.B \-U
|
|
|
5fc368 |
-option.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-v
|
|
|
5fc368 |
-Causes
|
|
|
5fc368 |
-.B nasm
|
|
|
5fc368 |
-to exit immediately, after displaying its version number.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-w [+-]foo
|
|
|
5fc368 |
-Causes
|
|
|
5fc368 |
-.B nasm
|
|
|
5fc368 |
-to enable or disable certain classes of warning messages, for
|
|
|
5fc368 |
-example
|
|
|
5fc368 |
-.B \-w+orphan-labels
|
|
|
5fc368 |
-or
|
|
|
5fc368 |
-.B \-w-macro-params
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-X " format"
|
|
|
5fc368 |
-specifies error reporting format (gnu or vc).
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-Z " filename"
|
|
|
5fc368 |
-Causes
|
|
|
5fc368 |
-.B nasm
|
|
|
5fc368 |
-to redirect error messages to
|
|
|
5fc368 |
-.IR filename .
|
|
|
5fc368 |
-This option exists to support operating systems on which stderr is not
|
|
|
5fc368 |
-easily redirected.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-\-prefix
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-\-postfix
|
|
|
5fc368 |
-Prepend or append (respectively) the given argument to all
|
|
|
5fc368 |
-global or extern variables.
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-.RE
|
|
|
5fc368 |
-.SS SYNTAX
|
|
|
5fc368 |
-This man page does not fully describe the syntax of
|
|
|
5fc368 |
-.BR nasm 's
|
|
|
5fc368 |
-assembly language, but does give a summary of the differences from
|
|
|
5fc368 |
-other assemblers.
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-.I Registers
|
|
|
5fc368 |
-have no leading `%' sign, unlike
|
|
|
5fc368 |
-.BR gas ,
|
|
|
5fc368 |
-and floating-point stack registers are referred to as
|
|
|
5fc368 |
-.IR st0 ,
|
|
|
5fc368 |
-.IR st1 ,
|
|
|
5fc368 |
-and so on.
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-.I Floating-point instructions
|
|
|
5fc368 |
-may use either the single-operand form or the double. A
|
|
|
5fc368 |
-.I TO
|
|
|
5fc368 |
-keyword is provided; thus, one could either write
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-.ti +15n
|
|
|
5fc368 |
-fadd st0,st1
|
|
|
5fc368 |
-.br
|
|
|
5fc368 |
-.ti +15n
|
|
|
5fc368 |
-fadd st1,st0
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-or one could use the alternative single-operand forms
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-.ti +15n
|
|
|
5fc368 |
-fadd st1
|
|
|
5fc368 |
-.br
|
|
|
5fc368 |
-.ti +15n
|
|
|
5fc368 |
-fadd to st1
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-.I Uninitialised storage
|
|
|
5fc368 |
-is reserved using the
|
|
|
5fc368 |
-.IR RESB ,
|
|
|
5fc368 |
-.IR RESW ,
|
|
|
5fc368 |
-.IR RESD ,
|
|
|
5fc368 |
-.IR RESQ ,
|
|
|
5fc368 |
-.I REST
|
|
|
5fc368 |
-and
|
|
|
5fc368 |
-.I RESO
|
|
|
5fc368 |
-pseudo-opcodes, each taking one parameter which gives the number of
|
|
|
5fc368 |
-bytes, words, doublewords, quadwords or ten-byte words to reserve.
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-.I Repetition
|
|
|
5fc368 |
-of data items is not done by the
|
|
|
5fc368 |
-.I DUP
|
|
|
5fc368 |
-keyword as seen in DOS assemblers, but by the use of the
|
|
|
5fc368 |
-.I TIMES
|
|
|
5fc368 |
-prefix, like this:
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-.ti +6n
|
|
|
5fc368 |
-.ta 9n
|
|
|
5fc368 |
-message: times 3 db 'abc'
|
|
|
5fc368 |
-.br
|
|
|
5fc368 |
-.ti +15n
|
|
|
5fc368 |
-times 64-$+message db 0
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-which defines the string `abcabcabc', followed by the right number
|
|
|
5fc368 |
-of zero bytes to make the total length up to 64 bytes.
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-.I Symbol references
|
|
|
5fc368 |
-are always understood to be immediate (i.e. the address of the
|
|
|
5fc368 |
-symbol), unless square brackets are used, in which case the contents
|
|
|
5fc368 |
-of the memory location are used. Thus:
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-.ti +15n
|
|
|
5fc368 |
-mov ax,wordvar
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-loads AX with the address of the variable `wordvar', whereas
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-.ti +15n
|
|
|
5fc368 |
-mov ax,[wordvar]
|
|
|
5fc368 |
-.br
|
|
|
5fc368 |
-.ti +15n
|
|
|
5fc368 |
-mov ax,[wordvar+1]
|
|
|
5fc368 |
-.br
|
|
|
5fc368 |
-.ti +15n
|
|
|
5fc368 |
-mov ax,[es:wordvar+bx]
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-all refer to the
|
|
|
5fc368 |
-.I contents
|
|
|
5fc368 |
-of memory locations. The syntaxes
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-.ti +15n
|
|
|
5fc368 |
-mov ax,es:wordvar[bx]
|
|
|
5fc368 |
-.br
|
|
|
5fc368 |
-.ti +15n
|
|
|
5fc368 |
-es mov ax,wordvar[1]
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-are not legal at all, although the use of a segment register name as
|
|
|
5fc368 |
-an instruction prefix is valid, and can be used with instructions
|
|
|
5fc368 |
-such as
|
|
|
5fc368 |
-.I LODSB
|
|
|
5fc368 |
-which can't be overridden any other way.
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-.I Constants
|
|
|
5fc368 |
-may be expressed numerically in most formats: a trailing H, Q or B
|
|
|
5fc368 |
-denotes hex, octal or binary respectively, and a leading `0x' or `$'
|
|
|
5fc368 |
-denotes hex as well. Leading zeros are not treated specially at all.
|
|
|
5fc368 |
-Character constants may be enclosed in single or double quotes;
|
|
|
5fc368 |
-there is no escape character. The ordering is little-endian
|
|
|
5fc368 |
-(reversed), so that the character constant
|
|
|
5fc368 |
-.I 'abcd'
|
|
|
5fc368 |
-denotes 0x64636261 and not 0x61626364.
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-.I Local labels
|
|
|
5fc368 |
-begin with a period, and their `locality' is granted by the
|
|
|
5fc368 |
-assembler prepending the name of the previous non-local symbol. Thus
|
|
|
5fc368 |
-declaring a label `.loop' after a label `label' has actually defined
|
|
|
5fc368 |
-a symbol called `label.loop'.
|
|
|
5fc368 |
-.SS DIRECTIVES
|
|
|
5fc368 |
-.I SECTION name
|
|
|
5fc368 |
-or
|
|
|
5fc368 |
-.I SEGMENT name
|
|
|
5fc368 |
-causes
|
|
|
5fc368 |
-.B nasm
|
|
|
5fc368 |
-to direct all following code to the named section. Section names
|
|
|
5fc368 |
-vary with output file format, although most formats support the
|
|
|
5fc368 |
-names
|
|
|
5fc368 |
-.IR .text ,
|
|
|
5fc368 |
-.I .data
|
|
|
5fc368 |
-and
|
|
|
5fc368 |
-.IR .bss .
|
|
|
5fc368 |
-(The exception is the
|
|
|
5fc368 |
-.I obj
|
|
|
5fc368 |
-format, in which all segments are user-definable.)
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-.I ABSOLUTE address
|
|
|
5fc368 |
-causes
|
|
|
5fc368 |
-.B nasm
|
|
|
5fc368 |
-to position its notional assembly point at an absolute address: so
|
|
|
5fc368 |
-no code or data may be generated, but you can use
|
|
|
5fc368 |
-.IR RESB ,
|
|
|
5fc368 |
-.I RESW
|
|
|
5fc368 |
-and
|
|
|
5fc368 |
-.I RESD
|
|
|
5fc368 |
-to move the assembly point further on, and you can define labels. So
|
|
|
5fc368 |
-this directive may be used to define data structures. When you have
|
|
|
5fc368 |
-finished doing absolute assembly, you must issue another
|
|
|
5fc368 |
-.I SECTION
|
|
|
5fc368 |
-directive to return to normal assembly.
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-.I BITS 16,
|
|
|
5fc368 |
-.I BITS 32
|
|
|
5fc368 |
-or
|
|
|
5fc368 |
-.I BITS 64
|
|
|
5fc368 |
-switches the default processor mode for which
|
|
|
5fc368 |
-.B nasm
|
|
|
5fc368 |
-is generating code: it is equivalent to
|
|
|
5fc368 |
-.I USE16
|
|
|
5fc368 |
-or
|
|
|
5fc368 |
-.I USE32
|
|
|
5fc368 |
-in DOS assemblers.
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-.I EXTERN symbol
|
|
|
5fc368 |
-and
|
|
|
5fc368 |
-.I GLOBAL symbol
|
|
|
5fc368 |
-import and export symbol definitions, respectively, from and to
|
|
|
5fc368 |
-other modules. Note that the
|
|
|
5fc368 |
-.I GLOBAL
|
|
|
5fc368 |
-directive must appear before the definition of the symbol it refers
|
|
|
5fc368 |
-to.
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-.I STRUC strucname
|
|
|
5fc368 |
-and
|
|
|
5fc368 |
-.IR ENDSTRUC ,
|
|
|
5fc368 |
-when used to bracket a number of
|
|
|
5fc368 |
-.IR RESB ,
|
|
|
5fc368 |
-.I RESW
|
|
|
5fc368 |
-or similar instructions, define a data structure. In addition to
|
|
|
5fc368 |
-defining the offsets of the structure members, the construct also
|
|
|
5fc368 |
-defines a symbol for the size of the structure, which is simply the
|
|
|
5fc368 |
-structure name with
|
|
|
5fc368 |
-.I _size
|
|
|
5fc368 |
-tacked on to the end.
|
|
|
5fc368 |
-.SS FORMAT-SPECIFIC DIRECTIVES
|
|
|
5fc368 |
-.I ORG address
|
|
|
5fc368 |
-is used by the
|
|
|
5fc368 |
-.I bin
|
|
|
5fc368 |
-flat-form binary output format, and specifies the address at which
|
|
|
5fc368 |
-the output code will eventually be loaded.
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-.I GROUP grpname seg1 seg2...
|
|
|
5fc368 |
-is used by the
|
|
|
5fc368 |
-.I obj
|
|
|
5fc368 |
-(Microsoft 16-bit) output format, and defines segment groups. This
|
|
|
5fc368 |
-format also uses
|
|
|
5fc368 |
-.IR UPPERCASE ,
|
|
|
5fc368 |
-which directs that all segment, group and symbol names output to the
|
|
|
5fc368 |
-object file should be in uppercase. Note that the actual assembly is
|
|
|
5fc368 |
-still case sensitive.
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-.I LIBRARY libname
|
|
|
5fc368 |
-is used by the
|
|
|
5fc368 |
-.I rdf
|
|
|
5fc368 |
-output format, and causes a dependency record to be written to the
|
|
|
5fc368 |
-output file which indicates that the program requires a certain
|
|
|
5fc368 |
-library in order to run.
|
|
|
5fc368 |
-.SS MACRO PREPROCESSOR
|
|
|
5fc368 |
-Single-line macros are defined using the
|
|
|
5fc368 |
-.I %define
|
|
|
5fc368 |
-or
|
|
|
5fc368 |
-.I %idefine
|
|
|
5fc368 |
-commands, in a similar fashion to the C preprocessor. They can be
|
|
|
5fc368 |
-overloaded with respect to number of parameters, although defining a
|
|
|
5fc368 |
-macro with no parameters prevents the definition of any macro with
|
|
|
5fc368 |
-the same name taking parameters, and vice versa.
|
|
|
5fc368 |
-.I %define
|
|
|
5fc368 |
-defines macros whose names match case-sensitively, whereas
|
|
|
5fc368 |
-.I %idefine
|
|
|
5fc368 |
-defines case-insensitive macros.
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-Multi-line macros are defined using
|
|
|
5fc368 |
-.I %macro
|
|
|
5fc368 |
-and
|
|
|
5fc368 |
-.I %imacro
|
|
|
5fc368 |
-(the distinction is the same as that between
|
|
|
5fc368 |
-.I %define
|
|
|
5fc368 |
-and
|
|
|
5fc368 |
-.IR %idefine ),
|
|
|
5fc368 |
-whose syntax is as follows:
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-.ti +6n
|
|
|
5fc368 |
-%macro
|
|
|
5fc368 |
-.I name
|
|
|
5fc368 |
-.IR minprm [- maxprm "][+][.nolist] [" defaults ]
|
|
|
5fc368 |
-.br
|
|
|
5fc368 |
-.ti +15n
|
|
|
5fc368 |
-<some lines of macro expansion text>
|
|
|
5fc368 |
-.br
|
|
|
5fc368 |
-.ti +6n
|
|
|
5fc368 |
-%endmacro
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-Again, these macros may be overloaded. The trailing plus sign
|
|
|
5fc368 |
-indicates that any parameters after the last one get subsumed, with
|
|
|
5fc368 |
-their separating commas, into the last parameter. The
|
|
|
5fc368 |
-.I defaults
|
|
|
5fc368 |
-part can be used to specify defaults for unspecified macro
|
|
|
5fc368 |
-parameters after
|
|
|
5fc368 |
-.IR minparam .
|
|
|
5fc368 |
-.I %endm
|
|
|
5fc368 |
-is a valid synonym for
|
|
|
5fc368 |
-.IR %endmacro .
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-To refer to the macro parameters within a macro expansion, you use
|
|
|
5fc368 |
-.IR %1 ,
|
|
|
5fc368 |
-.I %2
|
|
|
5fc368 |
-and so on. You can also enforce that a macro parameter should
|
|
|
5fc368 |
-contain a condition code by using
|
|
|
5fc368 |
-.IR %+1 ,
|
|
|
5fc368 |
-and you can invert the condition code by using
|
|
|
5fc368 |
-.IR %-1 .
|
|
|
5fc368 |
-You can also define a label specific to a macro invocation by
|
|
|
5fc368 |
-prefixing it with a double % sign.
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-Files can be included using the
|
|
|
5fc368 |
-.I %include
|
|
|
5fc368 |
-directive, which works like C.
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-The preprocessor has a `context stack', which may be used by one
|
|
|
5fc368 |
-macro to store information that a later one will retrieve. You can
|
|
|
5fc368 |
-push a context on the stack using
|
|
|
5fc368 |
-.IR %push ,
|
|
|
5fc368 |
-remove one using
|
|
|
5fc368 |
-.IR %pop ,
|
|
|
5fc368 |
-and change the name of the top context (without disturbing any
|
|
|
5fc368 |
-associated definitions) using
|
|
|
5fc368 |
-.IR %repl .
|
|
|
5fc368 |
-Labels and
|
|
|
5fc368 |
-.I %define
|
|
|
5fc368 |
-macros specific to the top context may be defined by prefixing their
|
|
|
5fc368 |
-names with %$, and things specific to the next context down with
|
|
|
5fc368 |
-%$$, and so on.
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-Conditional assembly is done by means of
|
|
|
5fc368 |
-.IR %ifdef ,
|
|
|
5fc368 |
-.IR %ifndef ,
|
|
|
5fc368 |
-.I %else
|
|
|
5fc368 |
-and
|
|
|
5fc368 |
-.I %endif
|
|
|
5fc368 |
-as in C. (Except that
|
|
|
5fc368 |
-.I %ifdef
|
|
|
5fc368 |
-can accept several putative macro names, and will evaluate TRUE if
|
|
|
5fc368 |
-any of them is defined.) In addition, the directives
|
|
|
5fc368 |
-.I %ifctx
|
|
|
5fc368 |
-and
|
|
|
5fc368 |
-.I %ifnctx
|
|
|
5fc368 |
-can be used to condition on the name of the top context on the
|
|
|
5fc368 |
-context stack. The obvious set of `else-if' directives,
|
|
|
5fc368 |
-.IR %elifdef ,
|
|
|
5fc368 |
-.IR %elifndef ,
|
|
|
5fc368 |
-.IR %elifctx
|
|
|
5fc368 |
-and
|
|
|
5fc368 |
-.IR %elifnctx
|
|
|
5fc368 |
-are also supported.
|
|
|
5fc368 |
-.SH BUGS
|
|
|
5fc368 |
-Please report bugs through the bug tracker function at http://nasm.sourceforge.org.
|
|
|
5fc368 |
-.SH SEE ALSO
|
|
|
5fc368 |
-.BR as "(" 1 "),"
|
|
|
5fc368 |
-.BR ld "(" 1 ")."
|
|
|
5fc368 |
diff --git a/nasm.txt b/nasm.txt
|
|
|
5fc368 |
new file mode 100644
|
|
|
5fc368 |
index 0000000..55f9a05
|
|
|
5fc368 |
--- /dev/null
|
|
|
5fc368 |
+++ b/nasm.txt
|
|
|
5fc368 |
@@ -0,0 +1,303 @@
|
|
|
5fc368 |
+nasm(1)
|
|
|
5fc368 |
+=======
|
|
|
5fc368 |
+:doctype: manpage
|
|
|
5fc368 |
+:man source: NASM
|
|
|
5fc368 |
+:man manual: The Netwide Assembler Project
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+NAME
|
|
|
5fc368 |
+----
|
|
|
5fc368 |
+nasm - the Netwide Assembler, a portable 80x86 assembler
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+SYNOPSIS
|
|
|
5fc368 |
+--------
|
|
|
5fc368 |
+*nasm* [*-@* response file] [*-f* format] [*-o* outfile] [*-l* listfile] ['options'...] filename
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+DESCRIPTION
|
|
|
5fc368 |
+-----------
|
|
|
5fc368 |
+The *nasm* command assembles the file 'filename' and directs output to the file
|
|
|
5fc368 |
+'outfile' if specified. If 'outfile' is not specified, *nasm* will derive a default
|
|
|
5fc368 |
+output file name from the name of its input file, usually by appending `.o' or
|
|
|
5fc368 |
+`.obj', or by removing all extensions for a raw binary file. Failing that, the
|
|
|
5fc368 |
+output file name will be `nasm.out'.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+OPTIONS
|
|
|
5fc368 |
+-------
|
|
|
5fc368 |
+*-@* 'filename'::
|
|
|
5fc368 |
+ Causes *nasm* to process options from filename as if they were included on
|
|
|
5fc368 |
+ the command line.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-a*::
|
|
|
5fc368 |
+ Causes *nasm* to assemble the given input file without first applying the
|
|
|
5fc368 |
+ macro preprocessor.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-D*|*-d* 'macro[=value]'::
|
|
|
5fc368 |
+ Pre-defines a single-line macro.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-E*|*-e*::
|
|
|
5fc368 |
+ Causes *nasm* to preprocess the given input file, and write the output to
|
|
|
5fc368 |
+ 'stdout' (or the specified output file name), and not actually assemble
|
|
|
5fc368 |
+ anything.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-f* 'format'::
|
|
|
5fc368 |
+ Specifies the output file format. To see a list of valid output formats,
|
|
|
5fc368 |
+ use the *-hf* option.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-F* 'format'::
|
|
|
5fc368 |
+ Specifies the debug information format. To see a list of valid output
|
|
|
5fc368 |
+ formats, use the *-y* option (for example *-felf -y*).
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-g*::
|
|
|
5fc368 |
+ Causes *nasm* to generate debug information in selected format.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-h*::
|
|
|
5fc368 |
+ Causes *nasm* to exit immediately, after giving a summary of its
|
|
|
5fc368 |
+ invocation options.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-hf*::
|
|
|
5fc368 |
+ Same as *-h* , but also lists all valid output formats.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-I*|*-i* 'directory'::
|
|
|
5fc368 |
+ Adds a directory to the search path for include files. The directory
|
|
|
5fc368 |
+ specification must include the trailing slash, as it will be directly
|
|
|
5fc368 |
+ prepended to the name of the include file.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-l* 'listfile'::
|
|
|
5fc368 |
+ Causes an assembly listing to be directed to the given file, in which
|
|
|
5fc368 |
+ the original source is displayed on the right hand side (plus the source
|
|
|
5fc368 |
+ for included files and the expansions of multi-line macros) and the
|
|
|
5fc368 |
+ generated code is shown in hex on the left.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-M*::
|
|
|
5fc368 |
+ Causes *nasm* to output Makefile-style dependencies to stdout; normal
|
|
|
5fc368 |
+ output is suppressed.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-MG* 'file'::
|
|
|
5fc368 |
+ Same as *-M* but assumes that missing Makefile dependecies are generated
|
|
|
5fc368 |
+ and added to dependency list without a prefix.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-MF* 'file'::
|
|
|
5fc368 |
+ Output Makefile-style dependencies to the specified file.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-MD* 'file'::
|
|
|
5fc368 |
+ Same as a combination of *-M* and *-MF* options.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-MT* 'file'::
|
|
|
5fc368 |
+ Override the default name of the dependency target dependency target name.
|
|
|
5fc368 |
+ This is normally the same as the output filename, specified by
|
|
|
5fc368 |
+ the *-o* option.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-MQ* 'file'::
|
|
|
5fc368 |
+ The same as *-MT* except it tries to quote characters that have special
|
|
|
5fc368 |
+ meaning in Makefile syntax. This is not foolproof, as not all characters
|
|
|
5fc368 |
+ with special meaning are quotable in Make.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-MP*::
|
|
|
5fc368 |
+ Emit phony target.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-O* 'number'::
|
|
|
5fc368 |
+ Optimize branch offsets.
|
|
|
5fc368 |
+ * *-O0*: No optimization
|
|
|
5fc368 |
+ * *-O1*: Minimal optimization
|
|
|
5fc368 |
+ * *-Ox*: Multipass optimization (default)
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-o* 'outfile'::
|
|
|
5fc368 |
+ Specifies a precise name for the output file, overriding *nasm*'s default
|
|
|
5fc368 |
+ means of determining it.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-P*|*-p* 'file'::
|
|
|
5fc368 |
+ Specifies a file to be pre-included, before the main source file
|
|
|
5fc368 |
+ starts to be processed.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-s*::
|
|
|
5fc368 |
+ Causes *nasm* to send its error messages and/or help text to stdout
|
|
|
5fc368 |
+ instead of stderr.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-t*::
|
|
|
5fc368 |
+ Causes *nasm* to assemble in SciTech TASM compatible mode.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-U*|*-u* 'macro'::
|
|
|
5fc368 |
+ Undefines a single-line macro.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-v*::
|
|
|
5fc368 |
+ Causes *nasm* to exit immediately, after displaying its version number.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-W[no-]foo'::
|
|
|
5fc368 |
+ Causes *nasm* to enable or disable certain classes of warning messages,
|
|
|
5fc368 |
+ in gcc-like style, for example *-Worphan-labels* or *-Wno-orphan-labels*.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-w*'[+-]foo'::
|
|
|
5fc368 |
+ Causes *nasm* to enable or disable certain classes of warning messages,
|
|
|
5fc368 |
+ for example *-w+orphan-labels* or *-w-macro-params*.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-X* 'format'::
|
|
|
5fc368 |
+ Specifies error reporting format (gnu or vc).
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-y*::
|
|
|
5fc368 |
+ Causes *nasm* to list supported debug formats.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-Z* 'filename'::
|
|
|
5fc368 |
+ Causes *nasm* to redirect error messages to 'filename'. This option exists
|
|
|
5fc368 |
+ to support operating systems on which stderr is not easily redirected.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+--prefix::
|
|
|
5fc368 |
+--postfix::
|
|
|
5fc368 |
+ Prepend or append (respectively) the given argument to all global or
|
|
|
5fc368 |
+ extern variables.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+SYNTAX
|
|
|
5fc368 |
+------
|
|
|
5fc368 |
+This man page does not fully describe the syntax of *nasm*'s assembly language,
|
|
|
5fc368 |
+but does give a summary of the differences from other assemblers.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+'Registers' have no leading `%' sign, unlike *gas*, and floating-point stack
|
|
|
5fc368 |
+registers are referred to as 'st0', 'st1', and so on.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+'Floating-point instructions' may use either the single-operand form or the
|
|
|
5fc368 |
+double. A 'TO' keyword is provided; thus, one could either write
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+ fadd st0,st1
|
|
|
5fc368 |
+ fadd st1,st0
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+or one could use the alternative single-operand forms
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+ fadd st1
|
|
|
5fc368 |
+ fadd to st1
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+'Uninitialised storage' is reserved using the 'RESB', 'RESW', 'RESD', 'RESQ',
|
|
|
5fc368 |
+'REST' and 'RESO' pseudo-opcodes, each taking one parameter which gives the
|
|
|
5fc368 |
+number of bytes, words, doublewords, quadwords or ten-byte words to reserve.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+'Repetition' of data items is not done by the 'DUP' keyword as seen in DOS
|
|
|
5fc368 |
+assemblers, but by the use of the 'TIMES' prefix, like this:
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+ message: times 3 db 'abc'
|
|
|
5fc368 |
+ times 64-$+message db 0
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+which defines the string `abcabcabc`, followed by the right number of zero
|
|
|
5fc368 |
+bytes to make the total length up to 64 bytes.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+'Symbol references' are always understood to be immediate (i.e. the address
|
|
|
5fc368 |
+of the symbol), unless square brackets are used, in which case the contents
|
|
|
5fc368 |
+of the memory location are used. Thus:
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+ mov ax,wordvar
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+loads AX with the address of the variable `wordvar`, whereas
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+ mov ax,[wordvar]
|
|
|
5fc368 |
+ mov ax,[wordvar+1]
|
|
|
5fc368 |
+ mov ax,[es:wordvar+bx]
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+all refer to the 'contents' of memory locations. The syntaxes
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+ mov ax,es:wordvar[bx]
|
|
|
5fc368 |
+ es mov ax,wordvar[1]
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+are not legal at all, although the use of a segment register name as an instruction
|
|
|
5fc368 |
+prefix is valid, and can be used with instructions such as 'LODSB' which can't
|
|
|
5fc368 |
+be overridden any other way.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+'Constants' may be expressed numerically in most formats: a trailing H, Q or
|
|
|
5fc368 |
+B denotes hex, octal or binary respectively, and a leading `0x' or `$' denotes
|
|
|
5fc368 |
+hex as well. Leading zeros are not treated specially at all. Character constants
|
|
|
5fc368 |
+may be enclosed in single or double quotes; there is no escape character. The
|
|
|
5fc368 |
+ordering is little-endian (reversed), so that the character constant ''abcd''
|
|
|
5fc368 |
+denotes 0x64636261 and not 0x61626364.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+Local labels begin with a period, and their `locality' is granted by the assembler
|
|
|
5fc368 |
+prepending the name of the previous non-local symbol. Thus declaring a label
|
|
|
5fc368 |
+`.loop' after a label `label' has actually defined a symbol called `label.loop'.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+DIRECTIVES
|
|
|
5fc368 |
+----------
|
|
|
5fc368 |
+'SECTION' 'name' or 'SEGMENT' 'name' causes *nasm* to direct all following code
|
|
|
5fc368 |
+to the named section. Section names vary with output file format, although most
|
|
|
5fc368 |
+formats support the names '.text', '.data' and '.bss'. (The exception is the
|
|
|
5fc368 |
+'obj' format, in which all segments are user-definable.)
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+'ABSOLUTE' 'address' causes *nasm* to position its notional assembly point at
|
|
|
5fc368 |
+an absolute address: so no code or data may be generated, but you can use 'RESB',
|
|
|
5fc368 |
+'RESW' and 'RESD' to move the assembly point further on, and you can define labels.
|
|
|
5fc368 |
+So this directive may be used to define data structures. When you have finished
|
|
|
5fc368 |
+doing absolute assembly, you must issue another 'SECTION' directive to return to
|
|
|
5fc368 |
+normal assembly.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+'BITS' '16', 'BITS' '32' or 'BITS' '64' switches the default processor mode for
|
|
|
5fc368 |
+which *nasm* is generating code: it is equivalent to 'USE16' or 'USE32' in DOS
|
|
|
5fc368 |
+assemblers.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+'EXTERN' 'symbol' and 'GLOBAL' 'symbol' import and export symbol definitions,
|
|
|
5fc368 |
+respectively, from and to other modules. Note that the 'GLOBAL' directive must
|
|
|
5fc368 |
+appear before the definition of the symbol it refers to.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+'STRUC' 'strucname' and 'ENDSTRUC', when used to bracket a number of 'RESB',
|
|
|
5fc368 |
+'RESW' or similar instructions, define a data structure. In addition to
|
|
|
5fc368 |
+defining the offsets of the structure members, the construct also defines a symbol
|
|
|
5fc368 |
+for the size of the structure, which is simply the structure name with 'size'
|
|
|
5fc368 |
+tacked on to the end.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+FORMAT-SPECIFIC DIRECTIVES
|
|
|
5fc368 |
+--------------------------
|
|
|
5fc368 |
+'ORG' 'address' is used by the 'bin' flat-form binary output format, and
|
|
|
5fc368 |
+specifies the address at which the output code will eventually be loaded.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+'GROUP' 'grpname' 'seg1' 'seg2'... is used by the obj (Microsoft 16-bit)
|
|
|
5fc368 |
+output format, and defines segment groups. This format also uses 'UPPERCASE',
|
|
|
5fc368 |
+which directs that all segment, group and symbol names output to the object
|
|
|
5fc368 |
+file should be in uppercase. Note that the actual assembly is still case
|
|
|
5fc368 |
+sensitive.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+'LIBRARY' 'libname' is used by the 'rdf' output format, and causes a
|
|
|
5fc368 |
+dependency record to be written to the output file which indicates that
|
|
|
5fc368 |
+the program requires a certain library in order to run.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+MACRO PREPROCESSOR
|
|
|
5fc368 |
+------------------
|
|
|
5fc368 |
+Single-line macros are defined using the '%define' or '%idefine' commands, in
|
|
|
5fc368 |
+a similar fashion to the C preprocessor. They can be overloaded with respect
|
|
|
5fc368 |
+to number of parameters, although defining a macro with no parameters prevents
|
|
|
5fc368 |
+the definition of any macro with the same name taking parameters, and vice versa.
|
|
|
5fc368 |
+'%define' defines macros whose names match case-sensitively, whereas '%idefine'
|
|
|
5fc368 |
+defines case-insensitive macros.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+Multi-line macros are defined using '%macro' and '%imacro' (the distinction is the
|
|
|
5fc368 |
+same as that between '%define' and '%idefine'), whose syntax is as follows
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+ %macro name minprm[-maxprm][+][.nolist] [defaults]
|
|
|
5fc368 |
+ <some lines of macro expansion text>
|
|
|
5fc368 |
+ %endmacro
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+Again, these macros may be overloaded. The trailing plus sign indicates that
|
|
|
5fc368 |
+any parameters after the last one get subsumed, with their separating commas,
|
|
|
5fc368 |
+into the last parameter. The 'defaults' part can be used to specify defaults for
|
|
|
5fc368 |
+unspecified macro parameters after 'minparam'. '%endm' is a valid synonym for
|
|
|
5fc368 |
+'%endmacro'.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+To refer to the macro parameters within a macro expansion, you use '%1', '%2' and
|
|
|
5fc368 |
+so on. You can also enforce that a macro parameter should contain a condition
|
|
|
5fc368 |
+code by using '%+1', and you can invert the condition code by using '%-1'. You can also
|
|
|
5fc368 |
+define a label specific to a macro invocation by prefixing it with a double `%' sign.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+Files can be included using the '%include' directive, which works like C.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+The preprocessor has a `context stack', which may be used by one macro to store
|
|
|
5fc368 |
+information that a later one will retrieve. You can push a context on the stack
|
|
|
5fc368 |
+using '%push', remove one using '%pop', and change the name of the top context (without
|
|
|
5fc368 |
+disturbing any associated definitions) using '%repl'. Labels and '%define' macros
|
|
|
5fc368 |
+specific to the top context may be defined by prefixing their names with %$,
|
|
|
5fc368 |
+and things specific to the next context down with %$$, and so on.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+Conditional assembly is done by means of '%ifdef', '%ifndef', '%else' and '%endif'
|
|
|
5fc368 |
+as in C. (Except that '%ifdef' can accept several putative macro names, and
|
|
|
5fc368 |
+will evaluate TRUE if any of them is defined.) In addition, the directives
|
|
|
5fc368 |
+'%ifctx' and '%ifnctx' can be used to condition on the name of the top context
|
|
|
5fc368 |
+on the context stack. The obvious set of `else-if' directives, '%elifdef',
|
|
|
5fc368 |
+'%elifndef', '%elifctx' and '%elifnctx' are also supported.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+BUGS
|
|
|
5fc368 |
+----
|
|
|
5fc368 |
+Please report bugs through the bug tracker function at http://nasm.us.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+SEE ALSO
|
|
|
5fc368 |
+--------
|
|
|
5fc368 |
+*as*(1), *ld*(1).
|
|
|
5fc368 |
diff --git a/ndisasm.1 b/ndisasm.1
|
|
|
5fc368 |
deleted file mode 100644
|
|
|
5fc368 |
index 622500f..0000000
|
|
|
5fc368 |
--- a/ndisasm.1
|
|
|
5fc368 |
+++ /dev/null
|
|
|
5fc368 |
@@ -1,129 +0,0 @@
|
|
|
5fc368 |
-.\"
|
|
|
5fc368 |
-.\" This file is part of NASM and is released under the NASM License.
|
|
|
5fc368 |
-.\"
|
|
|
5fc368 |
-.TH NDISASM 1 "The Netwide Assembler Project"
|
|
|
5fc368 |
-.SH NAME
|
|
|
5fc368 |
-ndisasm \- the Netwide Disassembler, an 80x86 binary file disassembler
|
|
|
5fc368 |
-.SH SYNOPSIS
|
|
|
5fc368 |
-.B ndisasm
|
|
|
5fc368 |
-[
|
|
|
5fc368 |
-.B \-o
|
|
|
5fc368 |
-origin
|
|
|
5fc368 |
-] [
|
|
|
5fc368 |
-.B \-s
|
|
|
5fc368 |
-sync-point [...]]
|
|
|
5fc368 |
-[
|
|
|
5fc368 |
-.B \-a
|
|
|
5fc368 |
-|
|
|
|
5fc368 |
-.B \-i
|
|
|
5fc368 |
-] [
|
|
|
5fc368 |
-.B \-b
|
|
|
5fc368 |
-bits
|
|
|
5fc368 |
-] [
|
|
|
5fc368 |
-.B -u
|
|
|
5fc368 |
-] [
|
|
|
5fc368 |
-.B \-e
|
|
|
5fc368 |
-hdrlen
|
|
|
5fc368 |
-] [
|
|
|
5fc368 |
-.B \-k
|
|
|
5fc368 |
-offset,length [...]]
|
|
|
5fc368 |
-infile
|
|
|
5fc368 |
-.br
|
|
|
5fc368 |
-.B ndisasm \-h
|
|
|
5fc368 |
-.br
|
|
|
5fc368 |
-.B ndisasm \-r
|
|
|
5fc368 |
-.SH DESCRIPTION
|
|
|
5fc368 |
-The
|
|
|
5fc368 |
-.B ndisasm
|
|
|
5fc368 |
-command generates a disassembly listing of the binary file
|
|
|
5fc368 |
-.I infile
|
|
|
5fc368 |
-and directs it to stdout.
|
|
|
5fc368 |
-.SS OPTIONS
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.B \-h
|
|
|
5fc368 |
-Causes
|
|
|
5fc368 |
-.B ndisasm
|
|
|
5fc368 |
-to exit immediately, after giving a summary of its invocation
|
|
|
5fc368 |
-options.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-r
|
|
|
5fc368 |
-Causes
|
|
|
5fc368 |
-.B ndisasm
|
|
|
5fc368 |
-to exit immediately, after displaying its version number.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-o " origin"
|
|
|
5fc368 |
-Specifies the notional load address for the file. This option causes
|
|
|
5fc368 |
-.B ndisasm
|
|
|
5fc368 |
-to get the addresses it lists down the left hand margin, and the
|
|
|
5fc368 |
-target addresses of PC-relative jumps and calls, right.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-s " sync-point"
|
|
|
5fc368 |
-Manually specifies a synchronisation address, such that
|
|
|
5fc368 |
-.B ndisasm
|
|
|
5fc368 |
-will not output any machine instruction which encompasses bytes on
|
|
|
5fc368 |
-both sides of the address. Hence the instruction which
|
|
|
5fc368 |
-.I starts
|
|
|
5fc368 |
-at that address will be correctly disassembled.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-e " hdrlen"
|
|
|
5fc368 |
-Specifies a number of bytes to discard from the beginning of the
|
|
|
5fc368 |
-file before starting disassembly. This does not count towards the
|
|
|
5fc368 |
-calculation of the disassembly offset: the first
|
|
|
5fc368 |
-.I disassembled
|
|
|
5fc368 |
-instruction will be shown starting at the given load address.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-k " offset,length"
|
|
|
5fc368 |
-Specifies that
|
|
|
5fc368 |
-.I length
|
|
|
5fc368 |
-bytes, starting from disassembly offset
|
|
|
5fc368 |
-.IR offset ,
|
|
|
5fc368 |
-should be skipped over without generating any output. The skipped
|
|
|
5fc368 |
-bytes still count towards the calculation of the disassembly offset.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BR \-a " or " \-i
|
|
|
5fc368 |
-Enables automatic (or intelligent) sync mode, in which
|
|
|
5fc368 |
-.B ndisasm
|
|
|
5fc368 |
-will attempt to guess where synchronisation should be performed, by
|
|
|
5fc368 |
-means of examining the target addresses of the relative jumps and
|
|
|
5fc368 |
-calls it disassembles.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-b " bits"
|
|
|
5fc368 |
-Specifies 16-, 32- or 64-bit mode. The default is 16-bit mode.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.B \-u
|
|
|
5fc368 |
-Specifies 32-bit mode, more compactly than using `-b 32'.
|
|
|
5fc368 |
-.TP
|
|
|
5fc368 |
-.BI \-p " vendor"
|
|
|
5fc368 |
-Prefers instructions as defined by
|
|
|
5fc368 |
-.I vendor
|
|
|
5fc368 |
-in case of a conflict. Known
|
|
|
5fc368 |
-.I vendor
|
|
|
5fc368 |
-names include
|
|
|
5fc368 |
-.BR intel ,
|
|
|
5fc368 |
-.BR amd ,
|
|
|
5fc368 |
-.BR cyrix ,
|
|
|
5fc368 |
-and
|
|
|
5fc368 |
-.BR idt .
|
|
|
5fc368 |
-The default is
|
|
|
5fc368 |
-.BR intel .
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-.RE
|
|
|
5fc368 |
-.SH RESTRICTIONS
|
|
|
5fc368 |
-.B ndisasm
|
|
|
5fc368 |
-only disassembles binary files: it has no understanding of the
|
|
|
5fc368 |
-header information present in object or executable files. If you
|
|
|
5fc368 |
-want to disassemble an object file, you should probably be using
|
|
|
5fc368 |
-.BR objdump "(" 1 ")."
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-Auto-sync mode won't necessarily cure all your synchronisation
|
|
|
5fc368 |
-problems: a sync marker can only be placed automatically if a jump
|
|
|
5fc368 |
-or call instruction is found to refer to it
|
|
|
5fc368 |
-.I before
|
|
|
5fc368 |
-.B ndisasm
|
|
|
5fc368 |
-actually disassembles that part of the code. Also, if spurious jumps
|
|
|
5fc368 |
-or calls result from disassembling non-machine-code data, sync
|
|
|
5fc368 |
-markers may get placed in strange places. Feel free to turn
|
|
|
5fc368 |
-auto-sync off and go back to doing it manually if necessary.
|
|
|
5fc368 |
-.PP
|
|
|
5fc368 |
-.SH SEE ALSO
|
|
|
5fc368 |
-.BR objdump "(" 1 ")."
|
|
|
5fc368 |
diff --git a/ndisasm.txt b/ndisasm.txt
|
|
|
5fc368 |
new file mode 100644
|
|
|
5fc368 |
index 0000000..eaccfe4
|
|
|
5fc368 |
--- /dev/null
|
|
|
5fc368 |
+++ b/ndisasm.txt
|
|
|
5fc368 |
@@ -0,0 +1,94 @@
|
|
|
5fc368 |
+ndisasm(1)
|
|
|
5fc368 |
+==========
|
|
|
5fc368 |
+:doctype: manpage
|
|
|
5fc368 |
+:man source: NASM
|
|
|
5fc368 |
+:man manual: The Netwide Assembler Project
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+NAME
|
|
|
5fc368 |
+----
|
|
|
5fc368 |
+ndisasm - the Netwide Disassembler, an 80x86 binary file disassembler
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+SYNOPSIS
|
|
|
5fc368 |
+--------
|
|
|
5fc368 |
+*ndisasm* [ *-o* origin ] [ *-s* sync-point [...]] [ *-a* | *-i* ]
|
|
|
5fc368 |
+ [ *-b* bits ] [ *-u* ] [ *-e* hdrlen ] [ *-p* vendor ]
|
|
|
5fc368 |
+ [ *-k* offset,length [...]] infile
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+DESCRIPTION
|
|
|
5fc368 |
+-----------
|
|
|
5fc368 |
+The *ndisasm* command generates a disassembly listing of the binary file
|
|
|
5fc368 |
+infile and directs it to stdout.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+OPTIONS
|
|
|
5fc368 |
+-------
|
|
|
5fc368 |
+*-h*::
|
|
|
5fc368 |
+ Causes *ndisasm* to exit immediately, after giving a summary
|
|
|
5fc368 |
+ of its invocation options.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-r*|*-v*::
|
|
|
5fc368 |
+ Causes *ndisasm* to exit immediately, after displaying its
|
|
|
5fc368 |
+ version number.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-o* 'origin'::
|
|
|
5fc368 |
+ Specifies the notional load address for the file. This
|
|
|
5fc368 |
+ option causes *ndisasm* to get the addresses it lists
|
|
|
5fc368 |
+ down the left hand margin, and the target addresses
|
|
|
5fc368 |
+ of PC-relative jumps and calls, right.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-s* 'sync-point'::
|
|
|
5fc368 |
+ Manually specifies a synchronisation address, such that
|
|
|
5fc368 |
+ *ndisasm* will not output any machine instruction which
|
|
|
5fc368 |
+ encompasses bytes on both sides of the address. Hence
|
|
|
5fc368 |
+ the instruction which starts at that address will be
|
|
|
5fc368 |
+ correctly disassembled.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-e* 'hdrlen'::
|
|
|
5fc368 |
+ Specifies a number of bytes to discard from the beginning
|
|
|
5fc368 |
+ of the file before starting disassembly. This does not
|
|
|
5fc368 |
+ count towards the calculation of the disassembly offset:
|
|
|
5fc368 |
+ the first 'disassembled' instruction will be shown starting
|
|
|
5fc368 |
+ at the given load address.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-k* 'offset,length'::
|
|
|
5fc368 |
+ Specifies that 'length' bytes, starting from disassembly
|
|
|
5fc368 |
+ offset 'offset', should be skipped over without generating
|
|
|
5fc368 |
+ any output. The skipped bytes still count towards the
|
|
|
5fc368 |
+ calculation of the disassembly offset.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-a*|*-i*::
|
|
|
5fc368 |
+ Enables automatic (or intelligent) sync mode, in which
|
|
|
5fc368 |
+ *ndisasm* will attempt to guess where synchronisation should
|
|
|
5fc368 |
+ be performed, by means of examining the target addresses
|
|
|
5fc368 |
+ of the relative jumps and calls it disassembles.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-b* 'bits'::
|
|
|
5fc368 |
+ Specifies 16-, 32- or 64-bit mode. The default is 16-bit
|
|
|
5fc368 |
+ mode.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-u*::
|
|
|
5fc368 |
+ Specifies 32-bit mode, more compactly than using `-b 32'.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+*-p* 'vendor'::
|
|
|
5fc368 |
+ Prefers instructions as defined by 'vendor' in case of
|
|
|
5fc368 |
+ a conflict. Known 'vendor' names include *intel*, *amd*,
|
|
|
5fc368 |
+ *cyrix*, and *idt*. The default is *intel*.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+RESTRICTIONS
|
|
|
5fc368 |
+------------
|
|
|
5fc368 |
+*ndisasm* only disassembles binary files: it has no understanding of
|
|
|
5fc368 |
+the header information present in object or executable files.
|
|
|
5fc368 |
+If you want to disassemble an object file, you should probably
|
|
|
5fc368 |
+be using *objdump*(1).
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+Auto-sync mode won't necessarily cure all your synchronisation
|
|
|
5fc368 |
+problems: a sync marker can only be placed automatically if a
|
|
|
5fc368 |
+jump or call instruction is found to refer to it 'before'
|
|
|
5fc368 |
+*ndisasm* actually disassembles that part of the code. Also,
|
|
|
5fc368 |
+if spurious jumps or calls result from disassembling
|
|
|
5fc368 |
+non-machine-code data, sync markers may get placed in strange
|
|
|
5fc368 |
+places. Feel free to turn auto-sync off and go back to doing
|
|
|
5fc368 |
+it manually if necessary.
|
|
|
5fc368 |
+
|
|
|
5fc368 |
+SEE ALSO
|
|
|
5fc368 |
+--------
|
|
|
5fc368 |
+*objdump*(1)
|
|
|
5fc368 |
--
|
|
|
5fc368 |
1.8.1.4
|
|
|
5fc368 |
|