summaryrefslogtreecommitdiff
path: root/src/boot.asm
blob: cbf57d6017bfe36f997beddce0098e4d68f30c7c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
;> The Multiboot header must be contained completely within the first 8192 bytes of the OS 
;> image, and must be longword (32-bit) aligned.
MULTIBOOT_ALIGN_TO_PAGE:   equ 1 << 0
MULTIBOOT_MEMORY_DESCRIBE: equ 1 << 2
MULTIBOOT_MAGIC:           equ 0x1BADB002
MULTIBOOT_FLAGS:           equ (MULTIBOOT_ALIGN_TO_PAGE | MULTIBOOT_MEMORY_DESCRIBE)
MULTIBOOT_CHECKSUM:        equ -(MULTIBOOT_MAGIC + MULTIBOOT_FLAGS)
section .multiboot_header
align 4
    dd MULTIBOOT_MAGIC
    dd MULTIBOOT_FLAGS
    dd MULTIBOOT_CHECKSUM

STACK_SIZE: equ (1 << 14)
section .bss
align 16
stack_bottom:
    resb STACK_SIZE
stack_top:

section .text
global _start:function (_start.end - _start)
_start:
    mov esp, stack_top
    extern cmain
    call cmain
    cli

jmp $

.end: