diff options
| author | Jan Tuomi <jan@jantuomi.fi> | 2024-04-26 15:40:14 +0300 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2024-04-26 15:40:14 +0300 |
| commit | 7ca56c1a730fcecd0fe3af5e6b652fa09514a18b (patch) | |
| tree | e2ef6a4d28fa26adf11e00d138ef21b8316497f6 /resources/asm/fibo.atk16 | |
| parent | 2b18b320e97260f1d27143a37fe14953cf62e56d (diff) | |
Refactor project structure, add README and LICENSE
Diffstat (limited to 'resources/asm/fibo.atk16')
| -rw-r--r-- | resources/asm/fibo.atk16 | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/resources/asm/fibo.atk16 b/resources/asm/fibo.atk16 deleted file mode 100644 index b2c20bd..0000000 --- a/resources/asm/fibo.atk16 +++ /dev/null @@ -1,53 +0,0 @@ -; bootstrap code (must be called to setup mandatory data) -; will jump to label main -@include %bootstrap - -@label main -; call fibo subroutine with parameter 10 - ldi 10 RA - csi fibo - hlt - -@label fibo -;;; subroutine fibo -;;; param RA N -;;; return RA Nth fibonacci number - -; store RB, RC on stack - spu RB - spu RC -; if n < 2, return n - subi RA 2 RA - bri sign fibo_early -; store also RD on stack - spu RD -; a = 0 - ldi 0 RB -; b = 1 - ldi 1 RC -@label fibo_loop -; v = a + b - add RB RC RD -; a = b - mov RC RB -; b = v - mov RD RC -; n -= 1 - dec RA -; loop while n > 0 - bri zero fibo_done - jpi fibo_loop -@label fibo_early -; restore used registers - spo RC - spo RB -; return from subroutine - rsr -@label fibo_done - mov RD RA -; restore used registers - spo RD - spo RC - spo RB -; return from subroutine - rsr |
