diff options
| author | Mistivia <i@mistivia.com> | 2024-12-07 17:57:20 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2024-12-07 17:57:20 +0800 |
| commit | 60b8fb64bbaf4e13bac7a616fdffa785777efe94 (patch) | |
| tree | a0573b33395c8887cb20ad2a3251fbc481a38ef2 /examples | |
| parent | cd818993399f1fc8fa000b4144730affd291761f (diff) | |
add recursive fibonacci function as example
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/fibo.asm | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/examples/fibo.asm b/examples/fibo.asm new file mode 100644 index 0000000..a1a3e82 --- /dev/null +++ b/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 |
