A small x86-64 kernel. Stage 0 goes from real mode to long mode inside the boot sector.
2;
3; The BIOS loads this sector at 0x7C00 and jumps to it in 16-bit real mode.
6; nasm -f bin boot.asm -o boot.bin
7; qemu-system-x86_64 -drive format=raw,file=boot.bin
9 bits 16
10 org 0x7C00
12start:
13 cli
15 mov ds, ax
16 mov es, ax
17 mov ss, ax
18 mov sp, 0x7C00
19 cld
21 in al, 0x92 ; fast A20 gate
22 or al, 2
23 out 0x92, al
28 times 510 - ($ - $$) db 0
29 dw 0xAA55 ; boot signature