Getting Started

Getting Started

Robbert Haarman



Before you start writing an operating system, there are a few things you need to have. In this tutorial, we will be using assembly language written for the Netwide assembler (nasm).


The assembly code in this tutorial is targeted at the Netwide assembler, an excellent Free assembler for the x86 architecture. There is an extensive manual, but you won't really need that to follow this tutorial. You may want to read an assembly language tutorial, though.

I picked nasm, because I find it one of the easiest to use assemblers, and because it is Free. You are free to use any other assembler, but be aware that you will need to make modifications to the code presented here. For assemblers that use Intel syntax, these modifications will be minor. However, if your assembler of choice uses AT&T syntax, the changes will be major and require the addition of lots of syntactic salt, rendering the code here all but useless. If you don't know what I'm talking about, just stick with nasm.


Although not required, I highly recommend using an emulator to run the code that will be developed. This saves you the hassle of rebooting all the time, limits any damage you do to the virtual machine, and could provide helpful debug information. It also allows you to use the x86 code on a non-x86 computer.

The emulator I recommend is QEMU. It runs fast and emulates a complete x86-based system. It runs on x86 and PowerPC machines (and possibly other architectures).

Instead of QEMU, you could use Bochs. Bochs is an order of magnitude slower than QEMU, but it works on more architectures.

Host OS

I assume that you are building your operating system from a UNIX-like system. Other systems may lack some of the commands mentioned in the tutorial. UNIX-like operating systems are freely available for most computers (virtually any Linux distribution will do, as will FreeBSD, NetBSD, or OpenBSD. Alternatively, you may find a port of the dd command to your platform, or substitue a program that provides equivalent functionality.

Next part: The Bootsector