Lion Cipher Lab

Write a boot sector from scratch and make QEMU jump into 32-bit protected mode

Why it matters

Every computer you have ever used started the same way: firmware powered on, read a single 512-byte sector off a disk into a fixed address in memory, and jumped to it -- in a primitive 16-bit mode with no memory protection and a 1MB ceiling. That tiny program's whole job is to climb the CPU out of that mode and hand control to something bigger. Almost nobody has watched it happen a byte at a time, which is exactly why the boot process feels like magic and why bootkits, Secure Boot, and 'measured boot' sound like abstractions instead of mechanisms. Writing the boot sector yourself dissolves…

What you'll learn

Steps in this lab

  1. Read this first: why an emulator, and the mental model of a boot sector
  2. The contract: what the firmware gives you, and the one byte-pair it demands
  3. Install the toolchain and open a terminal
  4. Act 1: write the minimal boot sector (boot.asm)
  5. Assemble, boot it, and deliberately break the signature
  6. Act 2: why real mode is a dead end, and what the climb costs
  7. Enable the A20 line (and know why it exists)
  8. Build the GDT: the table protected mode reads to define your segments
  9. Make the jump and write to the screen's memory (boot32.asm)
  10. Catch a triple fault: read QEMU's -d int log and step it in gdb
  11. When it fails, and do it better

Open the full interactive lab →