nasm
portable x86 and x86-64 assembler using Intel syntax
TLDR
Assemble to object file
SYNOPSIS
nasm [-f format] [-o outfile] [-l listfile] [-D name=value] [options] source.asm
DESCRIPTION
NASM (Netwide Assembler) is a portable x86 and x86-64 assembler using Intel syntax. It produces object files for various operating systems and formats, making it suitable for cross-platform assembly development.
The Intel syntax NASM uses is generally considered more readable than AT&T syntax: destination comes first (mov eax, 1), memory references use brackets ([var]), and size specifiers are explicit (dword, qword).
Output formats cover major platforms: ELF for Linux/Unix, PE/COFF for Windows, Mach-O for macOS, and flat binary for bootloaders and embedded systems. The -f option selects the target format.
NASM includes a powerful macro preprocessor supporting multi-line macros, conditional assembly, string manipulation, and file inclusion. Context-local labels enable reusable code structures.
For debugging, NASM generates debugging information in formats like DWARF and CodeView, compatible with GDB, LLDB, and Visual Studio debuggers.
PARAMETERS
-f format
Output format (elf64, elf32, win64, win32, macho64, bin, etc.).-o file
Output file name.-l file
Generate listing file.-M
Generate Makefile dependencies.-E
Preprocess only, output to stdout.-a
Preprocess only, no output.-D macro[=value]
Define preprocessor macro.-U macro
Undefine preprocessor macro.-I path
Add include file search directory.-P file
Pre-include file before source.-w[+|-]warning
Enable/disable warning type.-g
Generate debug information.-F format
Debug information format.-O level
Optimization level (0, 1, x for multi-pass).-s
Output errors to stdout.-v
Display version.-h
Display help.-hf
List output formats.
CAVEATS
Intel syntax differs from GNU as (AT&T syntax). Object files must be linked (ld, gcc, link.exe) to create executables. Platform-specific calling conventions matter for function calls. Binary output requires manual memory layout. 16-bit and 32-bit modes need attention to processor mode.
HISTORY
NASM was written by Simon Tatham and Julian Hall starting in 1996, aiming to create a free, portable assembler with clean Intel syntax. It became the assembler of choice for many open-source projects needing low-level code. The project has seen contributions from many developers and remains actively maintained for modern processor extensions including AVX-512.
