A Simple OS Design & Implementation — Using Assembly Language

Ashen Malaka
3 min readJun 6, 2019

--

Introduction

This is a simple guidance of showing how to implement an OS using Assembly language to show hardware information of a computer. In this article this task is performed in Linux based OS called Ubuntu.

This OS can be bootable through floppy disk, CD Rom & USB.

Note:This OS only shows hardware information only.

Pre-requisites for this task

Basic knowledge of assembly language is needed for this.

mkisofs This is to generate a CD-ROM ISO image of AMOS

sudo apt-get install cdda2wav cdrecord mkisofs

NASM — This tool can be installed using terminal in Ubuntu following code.

sudo  bash  apt-get  install  nasm

QEMU — This is an emulator and this is to run .flp/.iso file that we needed. Code to install this tool is,

sudo  bash  apt-get  install  qemu-system-x86

Above mentioned tools should be installed prior to coding of OS.

Steps

Basic steps of creating necessary files

These are the most important files and directories in the AM_OS folder which contains:

  • source/ — Contains the entire OS source code.
  • source/bootload/ — Source to generate BOOTLOAD.BIN, which is added to the disk image when building.
  • source/features/ — Components of AMOS such as keyboard and screen.
  • source/kernel.asm — The core kernel source file, which pulls in other source files.
  • programs/ — Source code for programs added to the disk image.

Codes

All code lines for this OS can be obtained from here.

Building

To build AMOS, open a terminal and switch into the expanded AMOS package. Then enter following code in terminal:

sudo  bash  ./build-linux.sh

In here sudo bash is required to get root access.

This will use NASM to assemble the bootloader, kernel and supplied programs, then write the bootloader to the amos.flp floppy disk image in the disk_images/ directory. (It writes the 512-byte bootloader to the first sector of the floppy disk image to create a boot sector and set up a DOS-like file system.)

Next, the build script loopback-mounts the amos.flp image onto the file system — in other words, mounting the image as if it was a real floppy.

The script copies over the kernel (kernel.bin) and binaries from the programs/ directory, before unmounting the floppy image.

With that done, the script runs the mkisofs utility to generate a CD-ROM ISO image of AMOS, injecting the floppy image as a boot section.

So we end up with two files in the disk_images/ directory: one for floppy disks and one for CD-Rs.

Running the OS

Now we can now use amos.iso /amos.flp in an emulator or on a real PC. In here we used qemu for this and code for that is (when we are using qemu ):

sudo  bash  qemu-system-x86  -soundhw  pcspk  -drive  format=raw,file=disk_images/amos.flp,index=0,if=floppy

If we are running this OS in windows we can use virtual box and amos .iso

Following screenshots are from AMOS

This is the homepage of the AMOS
Shows hardware information

--

--

Ashen Malaka

Associate Software Engineer @Davton Consulting | Final Year Undergraduate | University of Kelaniya | Traveller