updated print with new functions

This commit is contained in:
2025-06-22 03:51:39 +01:00
parent 9c56258c48
commit 7892c44d89
4 changed files with 347 additions and 18 deletions
+64 -16
View File
@@ -13,11 +13,27 @@
// usage for reset:
// push pcx
// jmp print::reset
//
// usage for clear:
// push pcx
// jmp print::clear
//
// usage for print_byte:
// push (register containing byte)
// push pcx
// jmp print::print_byte
//
// usage for print_word:
// push (register containing word)
// push pcx
// jmp print::print_word
//
dw display: 0x20000
dw current: 0x20000
// prints the given text to the screen.
// ------------------------------------------
// prints the string at addr(arg[0]) to the screen.
print:
push bpr
mov spr, bpr
@@ -25,7 +41,7 @@ print:
ldw bpr, rg0, 8
ldw current, rg1
print_loop:
_print_loop:
ldb rg0, acc
stb acc, rg1
@@ -33,24 +49,47 @@ print_loop:
addi rg1, 1
cmp acc, zero
jne print_loop
jmp end
jne _print_loop
jmp _end
// return
end:
stw rg1, current
mov bpr, spr
pop bpr
return
// ------------------------------------------
// prints the value of arg[0] to the screen.
print_word:
// initialise
push bpr
mov spr, bpr
// resets the cursor position on the screen
// load byte into acc
ldw bpr, rg0, 8
ldw current, rg1
stw rg0, rg1
addi rg1, 4
jmp _end
// ------------------------------------------
// prints the last byte of arg[0] to the screen.
print_byte:
push bpr
mov spr, bpr
ldw bpr, rg0, 8
ldw current, rg1
stb rg0, rg1
addi rg1, 1
jmp _end
// ------------------------------------------
// resets the cursor position on the screen to 0x20000. (0,0)
reset:
push bpr
mov spr, bpr
ldw display, rg1
jmp end
jmp _end
// ------------------------------------------
// clears the screen
clear:
push bpr
mov spr, bpr
@@ -58,10 +97,19 @@ clear:
lli 500 rg0
ldw display, rg1
clear_loop:
_clear_loop:
dec rg0
stw zero, rg1
addi rg1, 4
cmp rg0, zero
jgt clear_loop
jmp end
jgt _clear_loop
jmp _end
// ------------------------------------------
// return
_end:
stw rg1, current
mov bpr, spr
pop bpr
return
+4 -2
View File
@@ -9,10 +9,12 @@ init:
mov bpr, spr
start:
lwi string, rg1
// string, rg1
lli 87, rg1
push rg1
call print::print
call print::print_byte
pop rg1
hlt