reorg done
[eightysix] / kern / src / startup.asm
1 ; second stage boot loader C startup
2         cpu 8086
3         bits 16
4         section .startup
5
6 ; memory reserved at the top of RAM for the kernel stack
7 STACKSZ equ 4096
8
9 extern kmain
10 extern _bss_start_off
11 extern _bss_size
12
13 global _start
14 _start:
15         ; TODO floppy off if necessary
16
17         ; move stack to the top of RAM (TODO: detect and avoid Ext. BIOS data area)
18         mov ax, (0xa0000 - STACKSZ) >> 4
19         mov ss, ax
20         mov sp, STACKSZ
21
22         ; zero .bss
23         mov di, _bss_start_off
24         mov cx, _bss_size
25         shr cx, 1
26         rep stosw
27         xor ax, ax
28         mov es, ax
29
30         call kmain
31
32 hang:   hlt
33         jmp hang
34
35 ; vi:set ts=8 sts=8 sw=8 ft=nasm: