NASM (computer program)
Encyclopedia
The Netwide Assembler is an assembler and disassembler
for the Intel x86 architecture. It can be used to write 16-bit
, 32-bit
(IA-32
) and 64-bit
(x86-64
) programs. NASM is considered to be one of the most popular assemblers for Linux
.
NASM was originally written by Simon Tatham
with assistance from Julian Hall, and is currently maintained by a small team led by H. Peter Anvin. It is available as free software
under the terms of the simplified (2-clause) BSD license
.
, Portable Executable
, a.out
, ELF
and Mach-O
, though position-independent code
is only supported for ELF object files. NASM also has its own binary format called RDOFF
.
The variety of output formats allows programs to be retargetted to virtually any x86 operating system. In addition, NASM can create flat binary files, usable in writing boot loaders, ROM
images, and in various facets of OS development. NASM can run on non-x86 platforms, such as SPARC
and PowerPC
, though it generate programs usable by those machines.
NASM uses variation of Intel assembly syntax instead of AT&T
syntax. It also avoids features such as automatic generation of segment overrides (and the related ASSUME directive) used by MASM and compatible assemblers.
for the DOS
operating system.
An example of a similar program for Microsoft Windows
:
An equivalent program for Linux
:
s, which are generally not executable in and of themselves. The only exception to this are flat binaries (e.g., .COM
) which are inherently limited in modern use. To translate the object files into executable programs, an appropriate linker must be used, such as the Visual Studio "LINK" utility for Windows or ld for UNIX-like systems.
extensions. The development versions are not uploaded to SourceForge.net
; instead, they are checked in to the project's own Git
repository with binary snapshots available from the project web page.
A search engine for NASM docs is also available.
As of version 2.07, NASM is now under the Simplified (2-clause) BSD license.
Disassembler
A disassembler is a computer program that translates machine language into assembly language—the inverse operation to that of an assembler. A disassembler differs from a decompiler, which targets a high-level language rather than an assembly language...
for the Intel x86 architecture. It can be used to write 16-bit
16-bit
-16-bit architecture:The HP BPC, introduced in 1975, was the world's first 16-bit microprocessor. Prominent 16-bit processors include the PDP-11, Intel 8086, Intel 80286 and the WDC 65C816. The Intel 8088 was program-compatible with the Intel 8086, and was 16-bit in that its registers were 16...
, 32-bit
32-bit
The range of integer values that can be stored in 32 bits is 0 through 4,294,967,295. Hence, a processor with 32-bit memory addresses can directly access 4 GB of byte-addressable memory....
(IA-32
IA-32
IA-32 , also known as x86-32, i386 or x86, is the CISC instruction-set architecture of Intel's most commercially successful microprocessors, and was first implemented in the Intel 80386 as a 32-bit extension of x86 architecture...
) and 64-bit
64-bit
64-bit is a word size that defines certain classes of computer architecture, buses, memory and CPUs, and by extension the software that runs on them. 64-bit CPUs have existed in supercomputers since the 1970s and in RISC-based workstations and servers since the early 1990s...
(x86-64
X86-64
x86-64 is an extension of the x86 instruction set. It supports vastly larger virtual and physical address spaces than are possible on x86, thereby allowing programmers to conveniently work with much larger data sets. x86-64 also provides 64-bit general purpose registers and numerous other...
) programs. NASM is considered to be one of the most popular assemblers for Linux
Linux
Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...
.
NASM was originally written by Simon Tatham
Simon Tatham
Simon Tatham is an English programmer known primarily for creating and maintaining PuTTY, a free software implementation of Telnet and SSH clients for Unix and Windows API platforms, along with an xterm terminal emulator...
with assistance from Julian Hall, and is currently maintained by a small team led by H. Peter Anvin. It is available as free software
Free software
Free software, software libre or libre software is software that can be used, studied, and modified without restriction, and which can be copied and redistributed in modified or unmodified form either without restriction, or with restrictions that only ensure that further recipients can also do...
under the terms of the simplified (2-clause) BSD license
BSD licenses
BSD licenses are a family of permissive free software licenses. The original license was used for the Berkeley Software Distribution , a Unix-like operating system after which it is named....
.
Features
NASM can output several binary formats including COFFCOFF
The Common Object File Format is a specification of a format for executable, object code, and shared library computer files used on Unix systems...
, Portable Executable
Portable Executable
The Portable Executable format is a file format for executables, object code and DLLs, used in 32-bit and 64-bit versions of Windows operating systems. The term "portable" refers to the format's versatility in numerous environments of operating system software architecture...
, a.out
A.out (file format)
a.out is a file format used in older versions of Unix-like computer operating systems for executables, object code, and, in later systems, shared libraries...
, ELF
Executable and Linkable Format
In computing, the Executable and Linkable Format is a common standard file format for executables, object code, shared libraries, and core dumps. First published in the System V Application Binary Interface specification, and later in the Tool Interface Standard, it was quickly accepted among...
and Mach-O
Mach-O
Mach-O, short for Mach object file format, is a file format for executables, object code, shared libraries, dynamically-loaded code, and core dumps. A replacement for the a.out format, Mach-O offered more extensibility and faster access to information in the symbol table.Mach-O was once used by...
, though position-independent code
Position-independent code
In computing, position-independent code or position-independent executable is machine instruction code that executes properly regardless of where in memory it resides...
is only supported for ELF object files. NASM also has its own binary format called RDOFF
RDOFF
RDOFF, the Relocatable Dynamic Object File Format, was born from the need for NASM developers to test the integrity of NASM's object file output capabilities. It is based heavily on the internal structure of NASM, essentially consisting of a header containing a serialization of the output driver...
.
The variety of output formats allows programs to be retargetted to virtually any x86 operating system. In addition, NASM can create flat binary files, usable in writing boot loaders, ROM
Read-only memory
Read-only memory is a class of storage medium used in computers and other electronic devices. Data stored in ROM cannot be modified, or can be modified only slowly or with difficulty, so it is mainly used to distribute firmware .In its strictest sense, ROM refers only...
images, and in various facets of OS development. NASM can run on non-x86 platforms, such as SPARC
SPARC
SPARC is a RISC instruction set architecture developed by Sun Microsystems and introduced in mid-1987....
and PowerPC
PowerPC
PowerPC is a RISC architecture created by the 1991 Apple–IBM–Motorola alliance, known as AIM...
, though it generate programs usable by those machines.
NASM uses variation of Intel assembly syntax instead of AT&T
AT&T
AT&T Inc. is an American multinational telecommunications corporation headquartered in Whitacre Tower, Dallas, Texas, United States. It is the largest provider of mobile telephony and fixed telephony in the United States, and is also a provider of broadband and subscription television services...
syntax. It also avoids features such as automatic generation of segment overrides (and the related ASSUME directive) used by MASM and compatible assemblers.
Examples of programs for various operating systems
This is a Hello world programHello world program
A "Hello world" program is a computer program that outputs "Hello world" on a display device. Because it is typically one of the simplest programs possible in most programming languages, it is by tradition often used to illustrate to beginners the most basic syntax of a programming language, or to...
for the DOS
DOS
DOS, short for "Disk Operating System", is an acronym for several closely related operating systems that dominated the IBM PC compatible market between 1981 and 1995, or until about 2000 if one includes the partially DOS-based Microsoft Windows versions 95, 98, and Millennium Edition.Related...
operating system.
An example of a similar program for Microsoft Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...
:
An equivalent program for Linux
Linux
Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...
:
Linking
NASM principally outputs object fileObject file
An object file is a file containing relocatable format machine code that is usually not directly executable. Object files are produced by an assembler, compiler, or other language translator, and used as input to the linker....
s, which are generally not executable in and of themselves. The only exception to this are flat binaries (e.g., .COM
.com
The domain name com is a generic top-level domain in the Domain Name System of the Internet. Its name is derived from commercial, indicating its original intended purpose for domains registered by commercial organizations...
) which are inherently limited in modern use. To translate the object files into executable programs, an appropriate linker must be used, such as the Visual Studio "LINK" utility for Windows or ld for UNIX-like systems.
Development
On 28 November 2007, version 2.00 was released, adding support for x86-64X86-64
x86-64 is an extension of the x86 instruction set. It supports vastly larger virtual and physical address spaces than are possible on x86, thereby allowing programmers to conveniently work with much larger data sets. x86-64 also provides 64-bit general purpose registers and numerous other...
extensions. The development versions are not uploaded to SourceForge.net
SourceForge.net
SourceForge is a web-based source code repository. It acts as a centralized location for software developers to control and manage open source software development. The website runs a version of SourceForge Enterprise Edition, forked from the last open-source version available...
; instead, they are checked in to the project's own Git
Git (software)
Git is a distributed revision control system with an emphasis on speed. Git was initially designed and developed by Linus Torvalds for Linux kernel development. Every Git working directory is a full-fledged repository with complete history and full revision tracking capabilities, not dependent on...
repository with binary snapshots available from the project web page.
A search engine for NASM docs is also available.
As of version 2.07, NASM is now under the Simplified (2-clause) BSD license.
External links
- NASM website
- SourceForge Page
- Special edition for Win32 and BeOS.
- A comparison of GAS and NASM at IBMIBMInternational Business Machines Corporation or IBM is an American multinational technology and consulting corporation headquartered in Armonk, New York, United States. IBM manufactures and sells computer hardware and software, and it offers infrastructure, hosting and consulting services in areas...
- intel2gas : a converter between the source format of the NASM and GASGNU AssemblerThe GNU Assembler, commonly known as GAS , is the assembler used by the GNU Project. It is the default back-end of GCC. It is used to assemble the GNU operating system and the Linux kernel, and various other software. It is a part of the GNU Binutils package.GAS' executable is named after as, a...
assemblers