📄 nasmdoc1.htm
字号:
<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 forportability 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 willalso output plain binary files. Its syntax is designed to be simple andeasy 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 wasessentially that there didn't seem to be a good <em>free</em> x86-seriesassembler around, and that maybe someone ought to write one.<ul><li><code><nobr>a86</nobr></code> is good, but not free, and in particularyou 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, butit'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 itserror checking is minimal. Also, its syntax is horrible, from the point ofview of anyone trying to actually <em>write</em> anything in it. Plus youcan't write 16-bit code in it (properly).<li><code><nobr>as86</nobr></code> is Minix- and Linux-specific, and (myversion 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 MASMcompatibility, which means millions of directives and tons of red tape. Andits syntax is essentially MASM's, with the contradictions and quirks thatentails (although it sorts out some of those by means of Ideal mode). It'sexpensive too. And it's DOS-only.</ul><p>So here, for your coding pleasure, is NASM. At present it's still inprototype stage - we don't promise that it can outperform any of theseassemblers. But please, <em>please</em> send us bug reports, fixes, helpfulinformation, and anything else you can get your hands on (and thanks to themany people who've done this already! You all know who you are), and we'llimprove 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 partof any NASM distribution archive, for the licence conditions under whichyou may use NASM. NASM is now under the so-called GNU Lesser General PublicLicense, 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 ateam 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 currentdevelopment 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 itinto its own directory (for example <code><nobr>c:\nasm</nobr></code>).<p>The archive will contain four executable files: the NASM executablefiles <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 nameends 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 (atleast) one of <code><nobr>nasm.exe</nobr></code> and<code><nobr>nasmw.exe</nobr></code> to a directory on your PATH, oralternatively 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 bepresent to run NASM (unless you've added it to your<code><nobr>PATH</nobr></code>), so you can delete it if you need to savespace; 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 ofMakefiles you can (hopefully) use to rebuild your copy of NASM fromscratch.<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 themaster instruction table <code><nobr>insns.dat</nobr></code> by a Perlscript; the file <code><nobr>macros.c</nobr></code> is generated from<code><nobr>standard.mac</nobr></code> by another Perl script. Although theNASM source distribution includes these generated files, you will need torebuild them (and hence, will need a Perl interpreter) if you changeinsns.dat, standard.mac or the documentation. It is possible future sourcedistributions may not include these files at all. Ports of Perl for avariety 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 containedin the archive), unpack it into a directory such as<code><nobr>/usr/local/src</nobr></code>. The archive, when unpacked, willcreate 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 andtype <code><nobr>./configure</nobr></code>. This shell script will find thebest 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 giveoptions such as <code><nobr>--prefix</nobr></code> to the configure script(see the file <code><nobr>INSTALL</nobr></code> for more details), orinstall 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 canbuild 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 itcompile 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>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -