wrote print.dsa

This commit is contained in:
2025-06-19 01:57:47 +01:00
parent 6b58a17f03
commit 11a107e56d
3 changed files with 48 additions and 46 deletions
+35 -15
View File
@@ -1,25 +1,45 @@
// PRINT LIBRARY.
// don't run this as a program as it won't do anything useful.
// 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
start:
reset:
pop ret
ldw display, rg1
stw rg1, current
jmp 4, ret
print:
pop ret // return address
pop rg0 // length
pop rg1 // string
ldw display, rg2
pop rg0 // string
ldw current, rg1
loop:
ldw rg1, acc
stw acc, rg2
ldb rg0, acc
stb acc, rg1
dec rg0
iadd rg0, 1
iadd rg1, 1
iadd rg1, 4
iadd rg2, 4
cmp rg0, zero
jge loop
cmp acc, zero
jne loop
// return
end:
jmp ret
// set current to
stw rg1, current
jmp 4, ret