%include "../common/multiboot_header.asm"
%include "../common/x86_vram.asm"

extern c_entry
extern print_int

section .bss

stack resb 0x1000

section .data

keyboard_scancode db 0

[bits 32]
section .text


global boot:
    mov esp, stack + 0x1000
    xor ebp, ebp
    jmp main

main:
    push word BG.BLACK | ' '
    call clear
    add esp, 2
    call c_entry

    .loop:
        call scan
        test al, al
        jz .loop

        push 22
        push eax
        call print_int
        add esp, 8
        jmp .loop



halt:
    hlt
    jmp halt

scan:
    xor eax, eax
    in al, 0x60
    cmp al, [keyboard_scancode]
    je .zero
    mov [keyboard_scancode], al
    ret

    .zero:
    xor al, al
    ret

%include "../common/x86_vram_functions.asm"
