That’s awesome — learning assembly language for OS boot development is one of the best ways to understand how computers really work. 💻
Let’s build a structured roadmap together so you can go from zero to writing your own bootable OS in assembly.
When a computer boots, it goes through this process:
- Power on → BIOS/UEFI runs
- BIOS loads the bootloader from the first sector of the boot disk (512 bytes, called the boot sector)
- The bootloader runs in 16-bit real mode
- The bootloader sets up the system (memory, segments, etc.)
- It loads and jumps to your kernel (which can be in assembly or C)
So your first goal is to write a bootloader in assembly that can:
- Run in 16-bit real mode
- Print text on the screen
- Load another program (like your kernel)
You’ll need a few tools to assemble and test your code:
| Tool | Purpose | Install |
|---|---|---|
| NASM | Assembler | sudo apt install nasm or brew install nasm |
| QEMU | Emulator for testing | sudo apt install qemu |
| dd | To write boot sectors | Preinstalled on Linux/macOS |
| hex editor | (optional) to inspect binaries | e.g. xxd, HxD, etc. |
You’ll be writing .asm files, assembling them with nasm, and testing them in QEMU.
Let’s make a simple “Hello, world” boot sector.
File: boot.asm
; boot.asm - simple bootloader
BITS 16 ; We're in 16-bit real mode
ORG 0x7C00 ; BIOS loads the boot sector here
start:
mov si, message ; Point to our string
call print_string ; Print it
jmp $ ; Infinite loop (halt here)
print_string:
lodsb ; Load next char from [SI] into AL
or al, al ; Check if null terminator (AL == 0?)
jz done ; If yes, we're done
mov ah, 0x0E ; BIOS teletype function
int 0x10 ; Print character in AL
jmp print_string
done:
ret
message db "Hello from Bootloader!", 0
times 510-($-$$) db 0 ; Pad up to 510 bytes
dw 0xAA55 ; Boot signaturenasm -f bin boot.asm -o boot.bin
qemu-system-x86_64 -drive format=raw,file=boot.binIf everything’s right, you’ll see:
Hello from Bootloader!🎉 Congratulations — you just wrote a working bootloader in pure assembly!
Once you understand this basic bootloader, the next things to learn are:
- Real Mode basics — registers, memory addressing, segment:offset
- BIOS interrupts (for I/O, disk reads, etc.)
- Loading a kernel from disk
- Switching to 32-bit protected mode
- Writing your kernel in C or assembly
- (Optional) Moving to 64-bit long mode
- 🔹 Book: “Programming from the Ground Up” by Jonathan Bartlett (great intro to assembly)
- 🔹 Book: “Operating Systems: From 0 to 1” (free online)
- 🔹 Tutorial series: os-dev wiki → the “Bare Bones” tutorial
- 🔹 YouTube: “Write your own OS” by Low Level Learning or Poncho
Would you like me to make a step-by-step mini course (like a week-by-week plan) where each day you build a new piece — from bootloader → kernel → basic OS shell? That’s the best way to stay consistent.