Linuxdoc Linux Questions
Click here to ask our community of linux experts!
Custom Search

6.1. Introduction

Finally, if you still want to try this crazy idea and write something in assembly (if you've reached this section -- you're real assembly fan), here's what you need to start.

As you've read before, you can write for Linux in different ways; I'll show how to use direct kernel calls, since this is the fastest way to call kernel service; our code is not linked to any library, does not use ELF interpreter, it communicates with kernel directly.

I will show the same sample program in two assemblers, nasm and gas, thus showing Intel and AT&T syntax.

You may also want to read Introduction to UNIX assembly programming tutorial, it contains sample code for other UNIX-like OSes.

6.1.1. Tools you need

First of all you need assembler (compiler) -- nasm or gas.

Second, you need a linker -- ld, since assembler produces only object code. Almost all distributions have gas and ld, in the binutils package.

As for nasm, you may have to download and install binary packages for Linux and docs from the nasm site; note that several distributions (Stampede, Debian, SuSe, Mandrake) already have nasm, check first.

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