67 lines
957 B
Plaintext
67 lines
957 B
Plaintext
// lib:
|
|
// print.dsa
|
|
|
|
// usage:
|
|
//
|
|
// include print "<relative path>""
|
|
//
|
|
// usage for print:
|
|
// push (register containing address of string)
|
|
// push pcx
|
|
// jmp print::print
|
|
//
|
|
// usage for reset:
|
|
// push pcx
|
|
// jmp print::reset
|
|
|
|
dw display: 0x20000
|
|
dw current: 0x20000
|
|
|
|
// prints the given text to the screen.
|
|
print:
|
|
push bpr
|
|
mov spr, bpr
|
|
|
|
ldw bpr, rg0, 8
|
|
ldw current, rg1
|
|
|
|
print_loop:
|
|
ldb rg0, acc
|
|
stb acc, rg1
|
|
|
|
addi rg0, 1
|
|
addi rg1, 1
|
|
|
|
cmp acc, zero
|
|
jne print_loop
|
|
jmp end
|
|
|
|
// return
|
|
end:
|
|
stw rg1, current
|
|
|
|
mov bpr, spr
|
|
pop bpr
|
|
return
|
|
|
|
// resets the cursor position on the screen
|
|
reset:
|
|
push bpr
|
|
mov spr, bpr
|
|
ldw display, rg1
|
|
jmp end
|
|
|
|
clear:
|
|
push bpr
|
|
mov spr, bpr
|
|
// display size = 2000 bytes / 500 words
|
|
lli 500 rg0
|
|
ldw display, rg1
|
|
|
|
clear_loop:
|
|
dec rg0
|
|
stw zero, rg1
|
|
addi rg1, 4
|
|
cmp rg0, zero
|
|
jgt clear_loop
|
|
jmp end |