Introduction to UNIX assembly programming

Konstantin Boldyshev

Version 0.8

$Date: 2000/11/11 12:07:08 $

This document is intended to be a tutorial, showing how to write a simple assembly program in several UNIX operating systems on the IA-32 (i386) platform. Included material may or may not be applicable to other hardware and/or software platforms. This document explains program layout, system call convention, and the build process. It accompanies the Linux Assembly HOWTO, which may also be of interest, though it is more Linux specific.

1. Introduction

1.1. Legal blurb

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License Version 1.1; with no Invariant Sections, with no Front-Cover Texts, and no Back-Cover texts.

1.2. Obtaining this document

The latest version of this document is available from If you are reading a few-months-old copy, please check the url above for a new version.

1.3. Tools you need

You will need several tools to play with programs included in this tutorial.

First of all you need the assembler (compiler). As a rule modern UNIX distributions include as (or gas), but all of the examples here use another assembler -- nasm (Netwide Assembler). It comes with full source code, and you can download it from the nasm page, or install it from the ports (or package) system. Compile it, or try to find precompiled binary for your OS; note that several distributions (at least Linux ones) already have nasm, check first.

Second, you need a linker -- ld, since assembler produces only object code. All distributions with the compilation tools installed will have ld.

If you're going to dig in, you should also install include files for your OS, and if possible, kernel source.

Now you should be ready to start, welcome..