[bits 16]
global loader           ; making entry point visible to linker
extern kmain		; kmain is defined elsewhere

[SEGMENT .text]
loader:
        mov ax,cs
        mov ds,ax
        mov es,ax

        ;mov bx,000Fh   ;Page 0, colour attribute 15 (white) for the int 10 calls below
        ;mov cx,1       ;We will want to write 1 character
        ;xor dx,dx      ;Start at top left corner
        ;mov ds,dx      ;Ensure ds = 0 (to let us load the message)
        ;cld             ;Ensure direction flag is cleared (for LODSB)

        ;mov ax,stack_start+1024*68
        ;mov ss,ax
        ;mov sp,stack_start+1024*68

        jmp kernel_main

[bits 32]
kernel_main:
	mov [temp],dword 0
	mov [temp],word sp
	mov esp,[temp]
	mov ebp,[temp]
	call kmain
        jmp $

stack_start:
	times 1024 * 68 db 0

temp:
	dw 0

;times 1474560 - 2 - ($ - $$) db 0
