The Netwide Assembler: NASM

Next Chapter | Contents | Index

Chapter 1: Introduction

1.1 What Is NASM?

The Netwide Assembler, NASM, is an 80x86 assembler designed for portability and modularity. It supports a range of object file formats, including Linux a.out and ELF, NetBSD/FreeBSD, COFF, Microsoft 16-bit OBJ and Win32. 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 Pentium, P6 and MMX opcodes, and has macro capability.

1.1.1 Why Yet Another Assembler?

The Netwide Assembler grew out of an idea on comp.lang.asm.x86 (or possibly alt.lang.asm - I forget which), which was essentially that there didn't seem to be a good free x86-series assembler around, and that maybe someone ought to write one.

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, please 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.

1.1.2 Licence Conditions

Please see the file Licence, supplied as part of any NASM distribution archive, for the licence conditions under which you may use NASM.

1.2 Contact Information

The current version of NASM (since 0.98) are maintained by H. Peter Anvin, hpa@zytor.com. If you want to report a bug, please read section 10.2 first.

NASM has a WWW page at http://www.cryogen.com/Nasm.

The original authors are e-mailable as jules@earthcorp.com and anakin@pobox.com.

New releases of NASM are uploaded to ftp.kernel.org, sunsite.unc.edu, ftp.simtel.net and ftp.coast.net. Announcements are posted to comp.lang.asm.x86, alt.lang.asm, comp.os.linux.announce and comp.archives.msdos.announce (the last one is done automagically by uploading to ftp.simtel.net).

If you don't have Usenet access, or would rather be informed by e-mail when new releases come out, you can subscribe to the nasm-announce email list by sending an email containing the line subscribe nasm-announce to majordomo@linux.kernel.org.

If you want information about NASM beta releases, please subscribe to the nasm-beta email list by sending an email containing the line subscribe nasm-beta to majordomo@linux.kernel.org.

1.3 Installation

1.3.1 Installing NASM under MS-DOS or Windows

Once you've obtained the DOS archive for NASM, nasmXXX.zip (where XXX denotes the version number of NASM contained in the archive), unpack it into its own directory (for example c:\nasm).

The archive will contain four executable files: the NASM executable files nasm.exe and nasmw.exe, and the NDISASM executable files ndisasm.exe and ndisasmw.exe. In each case, the file whose name ends in w is a Win32 executable, designed to run under Windows 95 or Windows NT Intel, and the other one is a 16-bit DOS executable.

The only file NASM needs to run is its own executable, so copy (at least) one of nasm.exe and nasmw.exe to a directory on your PATH, or alternatively edit autoexec.bat to add the nasm directory to your PATH. (If you're only installing the Win32 version, you may wish to rename it to nasm.exe.)

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 PATH), so you can delete it if you need to save space; however, you may want to keep the documentation or test programs.

If you've downloaded the DOS source archive, nasmXXXs.zip, the nasm 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. The file Readme lists the various Makefiles and which compilers they work with.

Note that the source files insnsa.c, insnsd.c, insnsi.h and insnsn.c are automatically generated from the master instruction table insns.dat by a Perl script; the file macros.c is generated from standard.mac by another Perl script. Although the NASM 0.98 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 www.cpan.org.

1.3.2 Installing NASM under Unix

Once you've obtained the Unix source archive for NASM, nasm-X.XX.tar.gz (where X.XX denotes the version number of NASM contained in the archive), unpack it into a directory such as /usr/local/src. The archive, when unpacked, will create its own subdirectory nasm-X.XX.

NASM is an auto-configuring package: once you've unpacked it, cd to the directory it's been unpacked into and type ./configure. This shell script will find the best C compiler to use for building NASM and set up Makefiles accordingly.

Once NASM has auto-configured, you can type make to build the nasm and ndisasm binaries, and then make install to install them in /usr/local/bin and install the man pages nasm.1 and ndisasm.1 in /usr/local/man/man1. Alternatively, you can give options such as --prefix to the configure script (see the file INSTALL for more details), or install the programs yourself.

NASM also comes with a set of utilities for handling the RDOFF custom object-file format, which are in the rdoff subdirectory of the NASM archive. You can build these with make rdf and install them with make rdf_install, if you want them.

If NASM fails to auto-configure, you may still be able to make it compile by using the fall-back Unix makefile Makefile.unx. Copy or rename that file to Makefile and try typing make. There is also a Makefile.unx file in the rdoff subdirectory.

Next Chapter | Contents | Index