added a create-project system to assembler, and fixed a couple of parsing bugs

This commit is contained in:
2025-06-20 03:25:28 +01:00
parent f791b05292
commit 42c26d4184
15 changed files with 392 additions and 107 deletions
+30
View File
@@ -0,0 +1,30 @@
// multiply.dsa
// usage:
//
// include multiply "<relative path>"
//
// usage for multiply:
// push (arg1)
// push (arg0)
// call multiply::multiply
// pop (arg0)
// pop (arg1)
multiply:
push bpr
mov spr, bpr
ldw bpr, rg0, 8 // load op 1
ldw bpr, rg1, 12 // load op 2
start:
add acc, rg0, acc
dec rg1
cmp rg1, zero
jgt start
end:
mov bpr, spr
pop bpr
return
+35 -13
View File
@@ -17,18 +17,15 @@
dw display: 0x20000
dw current: 0x20000
reset:
pop ret
ldw display, rg1
stw rg1, current
jmp 4, ret
// prints the given text to the screen.
print:
pop ret // return address
pop rg0 // string
push bpr
mov spr, bpr
ldw bpr, rg0, 8
ldw current, rg1
loop:
print_loop:
ldb rg0, acc
stb acc, rg1
@@ -36,10 +33,35 @@ loop:
addi rg1, 1
cmp acc, zero
jne loop
jne print_loop
jmp end
// return
// return
end:
// set current to
stw rg1, current
jmp 4, ret
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
+5 -14
View File
@@ -1,5 +1,4 @@
include print "./print.dsa"
include fib "./fib.dsa"
dw stack: 0x10000
db string: "An idiot admires complexity, a genius admires simplicity,
@@ -9,23 +8,15 @@ gonna think you're a god cause you made it so complicated nobody can understand
That's how they write journals in Academics, they try to make it so complicated people think you're a genius"
init:
// set up a stack.
ldw stack, bpr
mov bpr, spr
start:
lwi string, rg1
// push variables
push rg1 // string address.
push pcx // return address.
// call
jmp print::print
lli 25, rg0
push rg0
push pcx
jmp fib::fib_n
push rg1
call print::print
pop rg1
hlt
Binary file not shown.