# Kernel from Scratch

One of my 3 major goals for Hacker School was to create a bootable, 64-bit kernel image from scratch, using only nasm and my text editor. Well, folks, one down, two to go.

The NASM/x64 assembly code is listed below, with copious comments for your pleasure. It comprises 136 lines including comments; 75 with comments removed. You may wish to refer to the Intel® 64 Software Developers’ Manual (16.5MB PDF), especially if you’re interested in doing something similar yourself. Building and running is as simple as

$nasm boot.asm -o bootable.bin$ qemu-system-x86_64 bootable.bin

That is, assuming that you have recent versions of nasm and qemu installed.

Let’s get to the code!