165 lines
9.9 KiB
HTML
165 lines
9.9 KiB
HTML
<html><head><title>NASM Manual</title></head>
|
|
<body><h1 align=center>The Netwide Assembler: NASM</h1>
|
|
|
|
<p align=center><a href="nasmdoc2.html">Next Chapter</a> |
|
|
<a href="nasmdoc0.html">Contents</a> |
|
|
<a href="nasmdoci.html">Index</a>
|
|
<h2><a name="chapter-1">Chapter 1: Introduction</a></h2>
|
|
<h3><a name="section-1.1">1.1 What Is NASM?</a></h3>
|
|
<p>The Netwide Assembler, NASM, is an 80x86 assembler designed for
|
|
portability and modularity. It supports a range of object file formats,
|
|
including Linux and <code><nobr>NetBSD/FreeBSD</nobr></code>
|
|
<code><nobr>a.out</nobr></code>, <code><nobr>ELF</nobr></code>,
|
|
<code><nobr>COFF</nobr></code>, Microsoft 16-bit
|
|
<code><nobr>OBJ</nobr></code> and <code><nobr>Win32</nobr></code>. It will
|
|
also output plain binary files. Its syntax is designed to be simple and
|
|
easy to understand, similar to Intel's but less complex. It supports
|
|
<code><nobr>Pentium</nobr></code>, <code><nobr>P6</nobr></code>,
|
|
<code><nobr>MMX</nobr></code>, <code><nobr>3DNow!</nobr></code>,
|
|
<code><nobr>SSE</nobr></code> and <code><nobr>SSE2</nobr></code> opcodes,
|
|
and has macro capability.
|
|
<h4><a name="section-1.1.1">1.1.1 Why Yet Another Assembler?</a></h4>
|
|
<p>The Netwide Assembler grew out of an idea on
|
|
<code><nobr>comp.lang.asm.x86</nobr></code> (or possibly
|
|
<code><nobr>alt.lang.asm</nobr></code> - I forget which), which was
|
|
essentially that there didn't seem to be a good <em>free</em> x86-series
|
|
assembler around, and that maybe someone ought to write one.
|
|
<ul>
|
|
<li><code><nobr>a86</nobr></code> is good, but not free, and in particular
|
|
you don't get any 32-bit capability until you pay. It's DOS only, too.
|
|
<li><code><nobr>gas</nobr></code> is free, and ports over DOS and Unix, but
|
|
it's not very good, since it's designed to be a back end to
|
|
<code><nobr>gcc</nobr></code>, which always feeds it correct code. So its
|
|
error checking is minimal. Also, its syntax is horrible, from the point of
|
|
view of anyone trying to actually <em>write</em> anything in it. Plus you
|
|
can't write 16-bit code in it (properly).
|
|
<li><code><nobr>as86</nobr></code> is Minix- and Linux-specific, and (my
|
|
version at least) doesn't seem to have much (or any) documentation.
|
|
<li><code><nobr>MASM</nobr></code> isn't very good, and it's (was)
|
|
expensive, and it runs only under DOS.
|
|
<li><code><nobr>TASM</nobr></code> is better, but still strives for MASM
|
|
compatibility, which means millions of directives and tons of red tape. And
|
|
its syntax is essentially MASM's, with the contradictions and quirks that
|
|
entails (although it sorts out some of those by means of Ideal mode). It's
|
|
expensive too. And it's DOS-only.
|
|
</ul>
|
|
<p>So here, for your coding pleasure, is NASM. At present it's still in
|
|
prototype stage - we don't promise that it can outperform any of these
|
|
assemblers. But please, <em>please</em> send us bug reports, fixes, helpful
|
|
information, and anything else you can get your hands on (and thanks to the
|
|
many people who've done this already! You all know who you are), and we'll
|
|
improve it out of all recognition. Again.
|
|
<h4><a name="section-1.1.2">1.1.2 Licence Conditions</a></h4>
|
|
<p>Please see the file <code><nobr>COPYING</nobr></code>, supplied as part
|
|
of any NASM distribution archive, for the licence conditions under which
|
|
you may use NASM. NASM is now under the so-called GNU Lesser General Public
|
|
License, LGPL.
|
|
<h3><a name="section-1.2">1.2 Contact Information</a></h3>
|
|
<p>The current version of NASM (since about 0.98.08) are maintained by a
|
|
team of developers, accessible through the
|
|
<code><nobr>nasm-devel</nobr></code> mailing list (see below for the link).
|
|
If you want to report a bug, please read
|
|
<a href="nasmdo10.html#section-10.2">section 10.2</a> first.
|
|
<p>NASM has a WWW page at
|
|
<a href="http://nasm.sourceforge.net"><code><nobr>http://nasm.sourceforge.net</nobr></code></a>.
|
|
If it's not there, google for us!
|
|
<p>The original authors are e-mailable as
|
|
<a href="mailto:jules@dsf.org.uk"><code><nobr>jules@dsf.org.uk</nobr></code></a>
|
|
and
|
|
<a href="mailto:anakin@pobox.com"><code><nobr>anakin@pobox.com</nobr></code></a>.
|
|
The latter is no longer involved in the development team.
|
|
<p>New releases of NASM are uploaded to the official sites
|
|
<a href="http://nasm.sourceforge.net"><code><nobr>http://nasm.sourceforge.net</nobr></code></a>
|
|
and to
|
|
<a href="ftp://ftp.kernel.org/pub/software/devel/nasm/"><code><nobr>ftp.kernel.org</nobr></code></a>
|
|
and
|
|
<a href="ftp://ibiblio.org/pub/Linux/devel/lang/assemblers/"><code><nobr>ibiblio.org</nobr></code></a>.
|
|
<p>Announcements are posted to
|
|
<a href="news:comp.lang.asm.x86"><code><nobr>comp.lang.asm.x86</nobr></code></a>,
|
|
<a href="news:alt.lang.asm"><code><nobr>alt.lang.asm</nobr></code></a> and
|
|
<a href="news:comp.os.linux.announce"><code><nobr>comp.os.linux.announce</nobr></code></a>
|
|
<p>If you want information about NASM beta releases, and the current
|
|
development status, please subscribe to the
|
|
<code><nobr>nasm-devel</nobr></code> email list by registering at
|
|
<a href="http://sourceforge.net/projects/nasm"><code><nobr>http://sourceforge.net/projects/nasm</nobr></code></a>.
|
|
<h3><a name="section-1.3">1.3 Installation</a></h3>
|
|
<h4><a name="section-1.3.1">1.3.1 Installing NASM under MS-DOS or Windows</a></h4>
|
|
<p>Once you've obtained the DOS archive for NASM,
|
|
<code><nobr>nasmXXX.zip</nobr></code> (where <code><nobr>XXX</nobr></code>
|
|
denotes the version number of NASM contained in the archive), unpack it
|
|
into its own directory (for example <code><nobr>c:\nasm</nobr></code>).
|
|
<p>The archive will contain four executable files: the NASM executable
|
|
files <code><nobr>nasm.exe</nobr></code> and
|
|
<code><nobr>nasmw.exe</nobr></code>, and the NDISASM executable files
|
|
<code><nobr>ndisasm.exe</nobr></code> and
|
|
<code><nobr>ndisasmw.exe</nobr></code>. In each case, the file whose name
|
|
ends in <code><nobr>w</nobr></code> is a <code><nobr>Win32</nobr></code>
|
|
executable, designed to run under <code><nobr>Windows 95</nobr></code> or
|
|
<code><nobr>Windows NT</nobr></code> Intel, and the other one is a 16-bit
|
|
<code><nobr>DOS</nobr></code> executable.
|
|
<p>The only file NASM needs to run is its own executable, so copy (at
|
|
least) one of <code><nobr>nasm.exe</nobr></code> and
|
|
<code><nobr>nasmw.exe</nobr></code> to a directory on your PATH, or
|
|
alternatively edit <code><nobr>autoexec.bat</nobr></code> to add the
|
|
<code><nobr>nasm</nobr></code> directory to your
|
|
<code><nobr>PATH</nobr></code>. (If you're only installing the
|
|
<code><nobr>Win32</nobr></code> version, you may wish to rename it to
|
|
<code><nobr>nasm.exe</nobr></code>.)
|
|
<p>That's it - NASM is installed. You don't need the nasm directory to be
|
|
present to run NASM (unless you've added it to your
|
|
<code><nobr>PATH</nobr></code>), so you can delete it if you need to save
|
|
space; however, you may want to keep the documentation or test programs.
|
|
<p>If you've downloaded the DOS source archive,
|
|
<code><nobr>nasmXXXs.zip</nobr></code>, the <code><nobr>nasm</nobr></code>
|
|
directory will also contain the full NASM source code, and a selection of
|
|
Makefiles you can (hopefully) use to rebuild your copy of NASM from
|
|
scratch.
|
|
<p>Note that the source files <code><nobr>insnsa.c</nobr></code>,
|
|
<code><nobr>insnsd.c</nobr></code>, <code><nobr>insnsi.h</nobr></code> and
|
|
<code><nobr>insnsn.c</nobr></code> are automatically generated from the
|
|
master instruction table <code><nobr>insns.dat</nobr></code> by a Perl
|
|
script; the file <code><nobr>macros.c</nobr></code> is generated from
|
|
<code><nobr>standard.mac</nobr></code> by another Perl script. Although the
|
|
NASM source distribution includes these generated files, you will need to
|
|
rebuild them (and hence, will need a Perl interpreter) if you change
|
|
insns.dat, standard.mac or the documentation. It is possible future source
|
|
distributions may not include these files at all. Ports of Perl for a
|
|
variety of platforms, including DOS and Windows, are available from
|
|
<a href="http://www.cpan.org/ports/">www.cpan.org</a>.
|
|
<h4><a name="section-1.3.2">1.3.2 Installing NASM under Unix</a></h4>
|
|
<p>Once you've obtained the Unix source archive for NASM,
|
|
<code><nobr>nasm-X.XX.tar.gz</nobr></code> (where
|
|
<code><nobr>X.XX</nobr></code> denotes the version number of NASM contained
|
|
in the archive), unpack it into a directory such as
|
|
<code><nobr>/usr/local/src</nobr></code>. The archive, when unpacked, will
|
|
create its own subdirectory <code><nobr>nasm-X.XX</nobr></code>.
|
|
<p>NASM is an auto-configuring package: once you've unpacked it,
|
|
<code><nobr>cd</nobr></code> to the directory it's been unpacked into and
|
|
type <code><nobr>./configure</nobr></code>. This shell script will find the
|
|
best C compiler to use for building NASM and set up Makefiles accordingly.
|
|
<p>Once NASM has auto-configured, you can type
|
|
<code><nobr>make</nobr></code> to build the <code><nobr>nasm</nobr></code>
|
|
and <code><nobr>ndisasm</nobr></code> binaries, and then
|
|
<code><nobr>make install</nobr></code> to install them in
|
|
<code><nobr>/usr/local/bin</nobr></code> and install the man pages
|
|
<code><nobr>nasm.1</nobr></code> and <code><nobr>ndisasm.1</nobr></code> in
|
|
<code><nobr>/usr/local/man/man1</nobr></code>. Alternatively, you can give
|
|
options such as <code><nobr>--prefix</nobr></code> to the configure script
|
|
(see the file <code><nobr>INSTALL</nobr></code> for more details), or
|
|
install the programs yourself.
|
|
<p>NASM also comes with a set of utilities for handling the
|
|
<code><nobr>RDOFF</nobr></code> custom object-file format, which are in the
|
|
<code><nobr>rdoff</nobr></code> subdirectory of the NASM archive. You can
|
|
build these with <code><nobr>make rdf</nobr></code> and install them with
|
|
<code><nobr>make rdf_install</nobr></code>, if you want them.
|
|
<p>If NASM fails to auto-configure, you may still be able to make it
|
|
compile by using the fall-back Unix makefile
|
|
<code><nobr>Makefile.unx</nobr></code>. Copy or rename that file to
|
|
<code><nobr>Makefile</nobr></code> and try typing
|
|
<code><nobr>make</nobr></code>. There is also a Makefile.unx file in the
|
|
<code><nobr>rdoff</nobr></code> subdirectory.
|
|
<p align=center><a href="nasmdoc2.html">Next Chapter</a> |
|
|
<a href="nasmdoc0.html">Contents</a> |
|
|
<a href="nasmdoci.html">Index</a>
|
|
</body></html>
|