format elf
	use32

MULTIBOOT_PAGE_ALIGN	    equ (1 shl 0)
MULTIBOOT_MEMORY_INFO	    equ (1 shl 1)
MULTIBOOT_AOUT_KLUDGE	    equ (1 shl 16)
MULTIBOOT_HEADER_MAGIC	    equ 0x1BADB002
MULTIBOOT_HEADER_FLAGS	    equ MULTIBOOT_PAGE_ALIGN or MULTIBOOT_MEMORY_INFO
MULTIBOOT_CHECKSUM          equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)

.multiboot: align 4
	dd MULTIBOOT_HEADER_MAGIC
	dd MULTIBOOT_HEADER_FLAGS
	dd MULTIBOOT_CHECKSUM

section '.bss' writable align 16
	stack_bottom:
	rb 16384
	stack_top:

section '.text' executable
	public  _start
	extrn   kmain

disable_cursor:
	pushf
	push eax
	push edx
  
	mov dx, 0x3D4
	mov al, 0xA	; low cursor shape register
	out dx, al
  
	inc dx
	mov al, 0x20	; bits 6-7 unused, bit 5 disables the cursor, bits 0-4 control the cursor shape
	out dx, al
  
	pop edx
	pop eax
	popf
	ret

_start:
	; Setup stack
	;mov esp, stack_top

	; Call the main kernel function.
	call disable_cursor
	call kmain



@@:
	cli
	hlt
	jmp     @b