Newer
Older
tree-os / src / multiboot / boot.asm
section .multiboot
header_start:
    dd 0xe85250d6                ; magic number
    dd 0                         ; protected mode code
    dd .end - header_start

    dd 0x100000000 - (0xe85250d6 + 0 + (.end - header_start))

    dw 0
    dw 0
    dd 8
.end:

extern kernelMain

KERNEL_STACK_SIZE equ 4096 * 32  ; 4kb of stack
global _start
section .text
_start:
    ; setup stack for kernel main function
    mov esp, stack + KERNEL_STACK_SIZE
    lgdt [gdt32.end]
    ; call main function
    mov ax, 16
    mov ds, ax
    mov ss, ax
    mov es, ax
    mov fs, ax
    mov gs, ax
    call 0x08:kernelMain
.loop:
    jmp .loop

section .data

ALIGN 4
 
gdt32:
	dq 0
 
.code:
	dw 0xffff
	dw 0
	db 0
	db 10011010b
	db 11001111b
	db 0
 
.data:
	dw 0xffff
	dw 0
	db 0
	db 10010010b
	db 11001111b
	db 0
.end:
    dw .end - gdt32 - 1
    dd gdt32

section .bss
align 4
stack:
    resb KERNEL_STACK_SIZE