[org 0x7c00]
    KERNEL_OFFSET equ 0x1000 ; Same one used while linking!

    mov [BOOT_DRIVE], dl ; BIOS sets boot drive to 'dl' for us
    mov bp, 0x9000
    mov sp, bp

    mov bx, MSG_REAL_MODE
    call print
    call print_nl

    call load_kernel
    call enable_protected

    jmp $ ; never executed

%include "output/print.asm"
%include "output/print_hex.asm"
%include "disk/disk.asm"
%include "protected/gdt.asm"
%include "output/vga-print.asm"
%include "protected/protected-switch.asm"
%include "kernel.asm"

[bits 32]
BEGIN_PROTECTED:
    mov ebx, MSG_PROT_MODE
    call print_string_pm

    call KERNEL_OFFSET ; give control to kernel
    jmp $ ; infinite loop if kernel returns control to us

BOOT_DRIVE db 0
MSG_REAL_MODE db "llb: started, preparing protected mode initialization", 0
MSG_PROT_MODE db "llb: loaded protected mode successfully, jumping to llb2", 0
MSG_LOAD_KERNEL db "llb: loading kernel into memory at 0x1000", 0

times 510 - ($-$$) db 0
dw 0xaa55