From f1ca75fd098972eea00c0fcc313583743facb3a6 Mon Sep 17 00:00:00 2001 From: zxq5 Date: Thu, 19 Jun 2025 18:06:52 +0100 Subject: [PATCH] Update assembler/usage --- assembler%2Fusage.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/assembler%2Fusage.md b/assembler%2Fusage.md index 581e07a..7fe3075 100644 --- a/assembler%2Fusage.md +++ b/assembler%2Fusage.md @@ -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 +``` + + + + +