Boot a 512-byte program that prints your first message.
01 / BEFORE YOU TYPE
A computer can run your code
before an OS is loaded.
Today you’ll write a tiny program that a legacy PC BIOS can boot. It prints a message and stops. There’s no C runtime and no installed operating system underneath your program.
We’ll use an emulator so you can experiment in a window. This is the legacy, 16-bit starting point. The full PeachOS series later moves through 32-bit development into 64-bit UEFI and graphics.
You don’t need kernel experience for this exercise. You should be comfortable creating a text file and running a command. Set aside extra time for installing the tools.
02 / PREPARE YOUR WORKSPACE
Two tools. One small file.
NASM
Turns assembly source into the bytes the processor executes.
QEMU
Emulates a PC and boots the image you create.
The commands below use an Ubuntu/Debian terminal. On Windows, use Ubuntu through WSL with GUI support for QEMU. The build/run commands also work in a native terminal when NASM and QEMU are installed and on your PATH.
sudo apt update
sudo apt install nasm qemu-system-x86
mkdir -p first-boot
cd first-boot
nasm -v
qemu-system-i386 --versionKeep the printed version numbers with your notes. These are Linux setup instructions; a Mac setup is outside this guide.
03 / BUILD SOMETHING YOU CAN SEE
Your first boot sector.
Create a file named boot.asm, then paste the complete source below. Or download it directly. The setup at the top establishes the segment registers and stack; the loop prints one byte at a time.
boot.asm COMPLETE DAY 1 SOURCE
; DragonZap First Boot / Day 1. Educational example, MIT licence.
bits 16
org 0x7c00
start:
cli
xor ax, ax
mov ds, ax
mov es, ax
mov ss, ax
mov sp, 0x7c00
sti
cld
mov ax, 0x0003 ; BIOS: clear screen, 80x25 text mode
int 0x10
mov si, message
.print:
lodsb ; read one byte from DS:SI into AL
test al, al ; zero marks the end of the message
jz .halt
mov ah, 0x0e ; BIOS: print the character in AL
xor bx, bx ; display page 0
int 0x10
jmp .print
.halt:
cli
hlt
jmp .halt
message db 'Hello from my first boot!', 0
times 510-($-$$) db 0 ; pad to the last two bytes
dw 0xaa55 ; boot signature: bytes 55 AA
Assemble and boot it
nasm -f bin boot.asm -o boot.bin
qemu-system-i386 -drive format=raw,file=boot.bin -boot cAssemble first, then launch QEMU. Close the emulator before rebuilding. The output is a boot image, so run it inside QEMU.
Hello from my first boot!The program stops after printing. That is the intended result.Can you see that exact message?
If yes, you’ve gone from a text file to code running at boot. Keep both boot.asm and boot.bin for Day 2.
04 / IF IT DOESN’T BOOT
Check the simple things first.
“nasm: command not found”
NASM is missing from this terminal’s PATH. On Ubuntu, run sudo apt install nasm and check nasm -v again. An installation in a different host environment won’t automatically appear inside WSL.
“qemu-system-i386: command not found”
Install the x86 system emulator with sudo apt install qemu-system-x86. Use qemu-system-i386, not a user-mode emulator such as qemu-i386.
“could not open” boot.asm or boot.bin
Check your current directory with pwd and list its files with ls. The assembler reads boot.asm and creates boot.bin. Assemble successfully before running the QEMU command. File names are case sensitive on Linux.
“TIMES value … is negative”
The code and message have grown past the 510 bytes reserved before the signature. Return to the complete example above, use ordinary straight quotes, and shorten any message you added. Do not remove the padding or signature to suppress the error.
QEMU opens, but the message never appears
Close QEMU, rebuild, and check that boot.bin is exactly 512 bytes. On Linux, run wc -c boot.bin. Check the last two bytes with od -An -tx1 -j510 -N2 boot.bin; they should be 55 aa. Use the exact launch command above, without a UEFI/OVMF firmware option.
The emulator can’t open a display
Run QEMU from a graphical desktop session. For WSL, confirm that GUI apps work in your WSL installation. A terminal-only SSH session needs a separately configured display; -nographic does not automatically turn this VGA text example into serial output.
Keep these two references handy
The NASM binary-format documentation explains -f bin and org. The QEMU invocation guide documents the drive and boot options.
DAY 2 IS ONE SMALL CHANGE AWAY
Make that message yours.
Enter your email to open Day 2 immediately: change the output and understand the bytes behind it. Days 3–5 will arrive at that email address, each with a link to open the next lesson.
By continuing, you agree to receive the five First Boot emails, including the final lesson’s course offer. Your welcome email arrives shortly; the rest follow daily. Unsubscribe anytime.