top of page

NASM Programming Language

NASM - Netwide Assembler

The Netwide Assembler (NASM) is an assembler and disassembler for the Intelx86 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.

The Netwide Assembler, NASM, is an 80x86 and x86-64 assembler designed for portability and modularity. It supports a range of object file formats, including Linux and *BSD a.out, ELF, Mach-O, 16-bit and 32-bit .obj (OMF) format, COFF (including its Win32 and Win64 variants.) It can also output plain binary files, Intel hex and Motorola S-Record formats. Its syntax is designed to be simple and easy to understand, similar to the syntax in the Intel Software Developer Manual with minimal complexity. It supports all currently known x86 architectural extensions, and has strong support for macros.

NASM is line-based. Most programs consist of directives followed by one or more sections. Lines can have an optional label. Most lines have an instruction followed by zero or more operands.

Generally, you put code in a section called .text and your constant data in a section called .data


NASM was originally written by Simon Tatham with assistance from Julian Hall. As of 2016, it is maintained by a small team led by H. Peter Anvin. It is open-source software released under the terms of a simplified (2-clause) BSD license


; include directives 

segment .data  ; 
DX directives 

segment .bss  
; RESX directives 

segment .text  
; instructions


; Define variables in the data section
	hello:     db 'Hello world!',10
	helloLen:  equ $-hello

; Code goes in the text section
	GLOBAL _start 

	mov eax,4            ; 'write' system call = 4
	mov ebx,1            ; file descriptor 1 = STDOUT
	mov ecx,hello        ; string to write
	mov edx,helloLen     ; length of string to write
	int 80h              ; call the kernel

	; Terminate program
	mov eax,1            ; 'exit' system call
	mov ebx,0            ; exit with error code 0
	int 80h              ; call the kernel


  1. NASM can output several binary formats, including COFF, OMF, a.out, Executable and Linkable Format (ELF), Mach-O and binary file (.bin, binary disk image, used to compile operating systems), though position-independent code is supported only for ELF object files. NASM also has its own binary format called RDOFF.

  2. The variety of output formats allows retargeting programs to virtually any x86 operating system (OS). Also, NASM can create flat binary files, usable to write boot loaders, read-only memory (ROM) images, and in various facets of OS development. NASM can run on non-x86 platforms as a cross assembler, such as PowerPC and SPARC, though it cannot generate programs usable by those machines.

  3. NASM uses a variant 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


  1. It allows complex jobs to run in a simpler way.

  2. It is memory efficient, as it requires less memory.

  3. It is faster in speed, as its execution time is less.

  4. It is mainly hardware-oriented.

  5. It requires less instruction to get the result.

  6. It is used for critical jobs.

  7. It is not required to keep track of memory locations.

  8. It is a low-level embedded system.


  1. It takes a lot of time and effort to write the code for the same.

  2. It is very complex and difficult to understand.

  3. The syntax is difficult to remember.

  4. It has a lack of portability of program between different computer architectures.

  5. It needs more size or memory of the computer to run the long programs written in Assembly Language.

Source: Wikipedia

The Tech Platform



bottom of page