Browse Source

add recursive fibonacci function as example

Mistivia 4 months ago
parent
commit
60b8fb64bb
1 changed files with 26 additions and 0 deletions
  1. 26 0
      examples/fibo.asm

+ 26 - 0
examples/fibo.asm

@@ -0,0 +1,26 @@
+    imm 40
+    fibo rel call
+    pop rv
+    imm 1 syscall
+    exit
+fibo:
+    bp sp sbp
+    imm 2 bpick
+    imm 2 gt
+    .else rel jz
+    imm 2 bpick
+    imm 1 sub
+    fibo rel call
+    pop rv
+    imm 2 bpick
+    imm 2 sub
+    fibo rel call
+    pop rv add
+    srv
+    .end rel jmp
+.else:
+    imm 1 srv
+    .end rel jmp
+.end:
+    bp ssp sbp
+    ret