Update assembler/usage
@@ -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
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user