81 lines
1.2 KiB
Plaintext
81 lines
1.2 KiB
Plaintext
include print "./lib/io/print.dsa"
|
|
|
|
dw idt: 0xFFFF0000
|
|
dw stack: 0x10000
|
|
init:
|
|
// setup interrupt handlers
|
|
ldw idt, idr
|
|
lwi handle_hard_fault, rg0
|
|
stw rg0, idr, 4
|
|
// set up a stack.
|
|
ldw stack, bpr
|
|
mov bpr, spr
|
|
|
|
|
|
db string: "I won, the game!"
|
|
db hexbyte: 0xab
|
|
dw hexword: 0x1234abcd
|
|
db replace: "I lost"
|
|
|
|
start:
|
|
// test print string
|
|
lwi string, rg0
|
|
push rg0
|
|
call print::print
|
|
pop zero
|
|
|
|
// test print hex byte.
|
|
ldb hexbyte, rg0
|
|
push rg0
|
|
call print::print_hex_byte
|
|
pop zero
|
|
|
|
// test print hex word.
|
|
ldw hexword, rg0
|
|
push rg0
|
|
call print::print_hex_word
|
|
pop zero
|
|
|
|
// test print char
|
|
lli 0x40, rg0 // print @
|
|
push rg0
|
|
call print::print_byte
|
|
pop zero
|
|
|
|
// test newline
|
|
call print::print_newline
|
|
|
|
lwi string rg0
|
|
push rg0
|
|
call print::print
|
|
|
|
// test print word
|
|
lwi 0x31323334, rg0 // print 1234
|
|
push rg0
|
|
call print::print_word
|
|
pop zero
|
|
|
|
// test reset cursor pos
|
|
call print::reset
|
|
|
|
// test print string at reset pos
|
|
lwi replace, rg0
|
|
push rg0
|
|
call print::print
|
|
pop zero
|
|
|
|
hlt
|
|
|
|
|
|
|
|
// fault handler in case we fail DSA.
|
|
dw hard_fault_err: "FATAL: Illegal Instruction or Memory Access!"
|
|
handle_hard_fault:
|
|
call print::clear
|
|
call print::reset
|
|
lwi hard_fault_err, rg0
|
|
push rg0
|
|
call print::print
|
|
pop zero
|
|
hlt
|