BIOS Programming

Packages Required

To follow along there are a few packages that we need to install. These commands will install everything you need.

sudo apt install fasm qemu-system-x86

fasm (Flat Assembler) is the assembler we will use and qemu is the emulator we will use so you don't need to actually write your data to a floppy disk and load it into a computer at boot up to test your changes.

Basic Framework for BIOS Programming

For a program to be valid there are a are a couple things that we need in our program. We can start with a .asm file with following code.

                
    use16
    org 0x7c00
    ; code goes here
    times 510 - ($ - $$) db 0
    dw 0xaa55
                
                

use16 means that we are using 16-bit real mode. Our origin point must be 0x7c00 for the program to run so we set this next. Then the next line will fill the file with 0's so that the 511th and 512th bytes are filled with the magic number "0xaa55".