A tiny two-stage x86 operating system that boots from a 512-byte boot sector into a real interactive shell — with system-info tools and two built-in games. Written from scratch in NASM assembly.
- Language: x86 real-mode assembly (NASM)
- Firmware interface: BIOS interrupts —
int 0x10(video),int 0x16(keyboard),int 0x13(disk),int 0x15(memory),int 0x1A(timer),CPUID - I/O: direct VGA text buffer (
0xB800) + a 16550 UART serial console (COM1) - Tooling: NASM to assemble, QEMU to run
NanoKernel started life as a single 512-byte boot-sector shell (still preserved in
legacy/). It has since grown into a two-stage system: a small boot
sector (boot/stage1.asm) loads a larger second-stage kernel (kernel/stage2.asm) from disk and
jumps to it. Stage 2 is a proper little text-mode environment — its own console with scrolling and
colour, a command shell, BIOS-backed system-info commands, and two games — all in real mode,
no OS underneath.
Every character printed is also mirrored to the serial port, so NanoKernel can be driven and scripted over COM1 as well as from the keyboard.
- Two-stage bootloader — a valid 512-byte boot sector that loads the kernel sector-by-sector (handling track/head boundaries) and hands off control.
- Text-mode console — direct
0xB800writes with a hardware cursor, line scrolling, backspace, and selectable colour. - Command shell with:
help— list commandsecho <text>— print textclear/cls— clear the screencolor <0-15>— set the text coloursysinfo— CPU vendor viaCPUID, RAM size via BIOSint 15h/E801, boot drivemem— full BIOSE820memory map (base / length / type)about— banner and creditsreboot— restart via the 8042 controllershutdown— ACPI power-off (QEMU)
- Games:
guess— number-guessing game (1–100) with higher/lower feedbacksnake— a real-time text-mode snake with score, growing tail, and food
You need nasm and qemu.
# build the bootable floppy image -> build/nanokernel.img
./build.sh # or: make
# run it in QEMU
make run # or: qemu-system-i386 -drive file=build/nanokernel.img,format=raw,if=floppyNanoKernel's shell reads from COM1 as well as the keyboard, so you can script it:
qemu-system-i386 -drive file=build/nanokernel.img,format=raw,if=floppy \
-display none -serial tcp:127.0.0.1:4455,server,nowait
# then connect to 127.0.0.1:4455 and type commands| Path | What it is |
|---|---|
boot/stage1.asm |
512-byte boot sector; loads and jumps to stage 2 |
kernel/stage2.asm |
the mini-kernel: console, shell, sysinfo, games |
build.sh / Makefile |
assemble the two stages into a bootable image |
legacy/boot_shell.asm |
the original single-sector shell NanoKernel grew from |
Released under the MIT License.

