bits 16
section .startup
-extern bootmain
-extern _stage2_start_seg
+; memory reserved at the top of RAM for the kernel stack
+STACKSZ equ 4096
+
+extern kmain
extern _bss_start_off
extern _bss_size
_start:
; TODO floppy off if necessary
+ ; move stack to the top of RAM (TODO: detect and avoid Ext. BIOS data area)
+ mov ax, (0xa0000 - STACKSZ) >> 4
+ mov ss, ax
+ mov sp, STACKSZ
+
; zero .bss
mov di, _bss_start_off
mov cx, _bss_size
xor ax, ax
mov es, ax
- call bootmain
+ call kmain
hang: hlt
jmp hang