include print "../io/print.dsa"

dw idt: 0xFFFF0000

setup_idt:
    push bpr
    mov spr, bpr

    // load the IDT into the IDR
	ldw idt, idr

	mov bpr, spr
	pop bpr
	irt

setup_hard_fault_handler:
    push bpr
    mov spr, bpr

    lwi handle_hard_fault, rg0
    stw rg0, idr, 4

    mov bpr, spr
    pop bpr
    irt

dw hard_fault_err: "FATAL: Illegal Instruction or Memory Access!"
handle_hard_fault:
	call print::reset
	lwi hard_fault_err, rg0
	push rg0
	call print::print
	pop zero
	hlt
