I should go to sleep frfr.

This commit is contained in:
2025-06-19 02:56:15 +01:00
parent 11a107e56d
commit ccc4421bb1
3 changed files with 36 additions and 26 deletions
+15 -22
View File
@@ -1,27 +1,20 @@
db fib_count: 10 // How many more numbers to calculate after F(0) and F(1)
init:
lli 0, rg0 // F(0) = 0
lli 1, rg1 // F(1) = 1
ldb fib_count, rg2
fib_n:
pop ret
pop rg0 // n
loop:
add rg0, rg1, acc // rg4 = rg0 + rg1 (new Fibonacci number)
lli 0, rg1
lli 1, rg2
push rg0
mov rg1, rg0 // rg0 = previous rg1 (F(n-2) = F(n-1))
mov acc, rg1 // rg1 = rg4 (F(n-1) = F(n))
start:
add rg1, rg2, acc
push rg1
mov rg2, rg1
mov acc, rg2
dec rg2 // rg2 = rg2 - 1
cmp rg2, zero // Compare counter with 0
jgt loop // Jump back if counter > 0
finish:
push rg0,
push rg1,
// Final Fibonacci number is in rg1
hlt
// jmp print::run
cmp rg0, zero
dec rg0
jgt start
jmp 4, ret
+19 -2
View File
@@ -1,12 +1,15 @@
include print "../resources/dsa/print.dsa"
include fib "../resources/dsa/fib.dsa"
dw stack: 0x10000
db string: "Hello world! This is about to be dependency hell..."
db string2: "And extremely jank. Ridiculously, unfathomably jank."
init:
dw stack: 0x10000
ldw stack, bpr
mov bpr, spr
start:
db string: "Damn this works pretty well"
lwi string, rg1
// push variables
@@ -15,4 +18,18 @@ start:
// call
jmp print::print
lli 25, rg0
push rg0
push pcx
jmp fib::fib_n
lwi string2, rg1
push rg1
push pcx
jmp print::print
hlt