Netwide Assembler

Netwide Assembler
Netwide Assembler
Original author(s) Simon Tatham, Julian Hall
Developer(s) H. Peter Anvin, et al.
Stable release 2.09.09 / July 3, 2011; 4 months ago (2011-07-03)
Preview release 2.10rc6 / June 6, 2011; 5 months ago (2011-06-06)
Operating system Microsoft Windows, Unix-like, OS/2, Mac OS, DOS
Available in English
Type x86 assembler
License 2-clause BSD
Website http://www.nasm.us/

The Netwide Assembler (NASM) 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[1].

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.[2] It is available as free software under the terms of the simplified (2-clause) BSD license.[3]

Contents

Features

NASM can output several binary formats including COFF, 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.[4]

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.[4] 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.[5] It also avoids features such as automatic generation of segment overrides (and the related ASSUME directive) used by MASM and compatible assemblers.[4]

Examples of programs for various operating systems

This is a Hello world program for the DOS operating system.

section .text
org 0x100
        mov    ah, 0x9
        mov    dx, hello
        int    0x21
 
        mov    ax, 0x4c00
        int    0x21
 
section .data
hello: db 'Hello, world!', 13, 10, '$'

An example of a similar program for Microsoft Windows:

global _start
extern _MessageBoxA@16
extern _ExitProcess@4
 
section code use32 class=code
_start:
        push   dword 0      ; UINT uType = MB_OK
        push   dword title  ; LPCSTR lpCaption
        push   dword banner ; LPCSTR lpText
        push   dword 0      ; HWND hWnd = NULL
        call   _MessageBoxA@16
 
        push   dword 0      ; UINT uExitCode
        call   _ExitProcess@4
 
section data use32 class=data
        banner:        db 'Hello, world!', 0
        title:        db 'Hello', 0

An equivalent program for Linux:

section .data
msg:   db     "Hello, world!", 10
.len: equ    $ - msg
 
section .text
global _start
_start:
        mov    eax, 4 ; write
        mov    ebx, 1 ; stdout
        mov    ecx, msg
        mov    edx, msg.len
        int    0x80
 
        mov    eax, 1 ; exit
        mov    ebx, 0      
        int    0x80

Linking

NASM principally outputs object files, which are generally not executable in and of themselves. The only exception to this are flat binaries (e.g., .COM)[4] 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-64 extensions.[2] 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.[6]

As of version 2.07, NASM is now under the Simplified (2-clause) BSD license.

See also

References

Further reading

  • Jeff Duntemann (2000). Assembly Language Step by Step. J Wiley and Sons. ISBN 0471375233. 

External links


Wikimedia Foundation. 2010.

Игры ⚽ Нужна курсовая?

Look at other dictionaries:

  • Netwide Assembler — NASM Développeurs Simon Tatham, Julian Hall, H. Peter Anvin et equipe de développeurs …   Wikipédia en Français

  • Netwide Assembler — El Netwide Assembler o NASM, es un ensamblador libre para la plataforma Intel x86. Puede ser usado para escribir programas tanto de 16 bits como de 32 bits (IA 32). En el NASM, si se usan las bibliotecas correctas, los programas de 32 bits se… …   Wikipedia Español

  • Netwide Assembler — NASM NASM 2.00 Basisdaten Aktuelle Version: 2.05.01 (29. Oktober 2008) Aktuelle Vorabversion: 2.06rc2 (19. Dezember 2008) …   Deutsch Wikipedia

  • Netwide assembler — NASM Développeurs Simon Tatham, Julian Hall, H. Peter Anvin et equipe de développeurs …   Wikipédia en Français

  • Assembler (Informatik) — Ein Assembler (nach DIN 44300: Assemblierer) ist ein Hilfsprogramm der Programmierung (Programmierwerkzeug), das ein in maschinennaher Assemblersprache geschriebenes Computerprogramm in Maschinensprache (auch Maschinencode oder Nativer Code… …   Deutsch Wikipedia

  • Flat assembler — Saltar a navegación, búsqueda FASMD Versión DOS con IDE del FASM flat assembler (FASM) es un ensamblador libre, multi paso, con el estilo de la sintaxis de Intel que soporta las arquitecturas IA 32 y x86 64. El proyecto fue iniciado en 1999 por… …   Wikipedia Español

  • Cross-Assembler — Ein Assembler (nach DIN 44300: Assemblierer) ist ein Hilfsprogramm der Programmierung (Programmierwerkzeug), das ein in einer einfachen, maschinennahen Assemblersprache geschriebenes Programm in Maschinensprache (auch Maschinencode oder Nativer… …   Deutsch Wikipedia

  • Microsoft Assembler — Der Microsoft Macro Assembler (abgekürzt MASM) ist ein von Microsoft entwickelter Assembler für x86 basierende Prozessoren. Er übersetzt Assemblerquelltext in ausführbaren, nativen Maschinencode. Der Microsoft Macro Assembler entwickelte sich… …   Deutsch Wikipedia

  • Microsoft Macro Assembler — Der Microsoft Macro Assembler (abgekürzt MASM) ist ein von Microsoft entwickelter Assembler für x86 basierende Prozessoren. Er übersetzt Assemblerquelltext in ausführbaren, nativen Maschinencode. Der Microsoft Macro Assembler entwickelte sich… …   Deutsch Wikipedia

  • Turbo Assembler — El Turbo Assembler (TASM), un paquete ensamblador principalmente destinado a la plataforma del IBM PC y sus compatibles. Fue la oferta de Borland en el mercado de herramientas de programación en lenguaje ensamblador para la familia de los… …   Wikipedia Español

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”