Writing your own bootloader for a toy operating system (5)

In our endeavor to write a boot loader for a toy operating system, we’ve come far already. Our boot loader does the following so far:

  • Setup data segments
  • Reset the drive system
  • Write a “loading” message
  • Find the kernel file on disk, using parameters found in the boot sector
  • Read the FAT table into memory
  • Read the kernel file into memory, using the FAT table
  • Reboot gracefully if the file could not be found or if reading fails

We are now in a position to put all the code fragments together and compile our boot loader. We’ll also add some initial code to our kernel, so that it can say “Hello”.

Read more


Writing your own bootloader for a toy operating system (3)

In part 2 of this guide to writing your own toy operating system, we set it to write our own (floppy) disk boot sector in assembly code. We ended up with a piece of code that writes a message to the screen, initializes the drive system, waits for a key press, and reboots. Before we move in, let’s create a development environment: a toolset that we can use to compile and test our code repeatedly (and when fiddling with low-level assembly code, you’ll find that “repeatedly” is the operative word here).

Our code so far was written in for the GNU assembler, as, although we use the Intel syntax (which GNU supports) as this is easier on the eyes for most people (I like the GNU syntax, but if you’ve never used it, you’ll find that it requires looking at everything upside down). The GNU assembler is free, and any other tools we’ll use will also be free.

We’ll also use Windows as our development platform, which we’ll require some extra work to set things up.

Read more


Writing your own bootloader for a toy operating system (2)

Now that we know the structure of the boot parameter block (BPB) and extended boot parameter block (EBPB), we can start writing our first code. (If you need a refresher, have a look at part 1 of this article).

Read more