Update assembler/usage

2025-06-19 18:06:52 +01:00
parent 11a87b40c8
commit f1ca75fd09
+29
@@ -774,3 +774,32 @@ include print "../resources/dsa/print.dsa"
include fib "../resources/dsa/fib.dsa"
```
## Example Programs and libraries.
```dsa
// this is a simple library to calculate the fibonacci sequence up to n, writing each value to the stack.
fib_n:
pop ret // pops the return address from the stack
pop rg0 // pops the function arg (n) from the stack
lli 0, rg1
lli 1, rg2
start:
add rg1, rg2, acc
push rg1
mov rg2, rg1
mov acc, rg2
cmp rg0, zero
dec rg0
jgt start
jmp 4, ret
```