Learning x86 with NASM — Your First Program

Scott Cosentino
4 min readMay 31, 2022

In this article, we will create a simple x86 assembly program using the NASM assembler on Linux. Our program will trigger an exit system call. The exit system call with quit our program, setting a status code on exit. Let’s start by building the basic structure of our x86 program.

The code for this article can be found at: https://github.com/scprogramming/Learning-x86-with-NASM/tree/main/first%20program

Structuring NASM x86 Programs

Every x86 program in NASM will contain a few key components required to get the program up and running. The first two components are known as sections. We will declare two sections in our program named .data and .text, as shown below.

The .data section is used to declare variables used by the program at runtime. For our program, the data section will be empty since no variables are required. The .text section contains the code for our program. When we first create a program in x86, we need to start by adding an entry point to the .text section.

--

--