diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2024-02-20 16:55:14 +0200 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2024-02-20 16:56:09 +0200 |
| commit | 549901c85044b6ccd912688d6be007c2fdacc6c6 (patch) | |
| tree | 15d1123eedb4347472e4b47fec880e2e5b79927e /asm/fibo.atk16 | |
| parent | abf0594c78087434bced59054896f7f411e18faf (diff) | |
Refactor dir structure
Diffstat (limited to 'asm/fibo.atk16')
| -rw-r--r-- | asm/fibo.atk16 | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/asm/fibo.atk16 b/asm/fibo.atk16 deleted file mode 100644 index 34999a9..0000000 --- a/asm/fibo.atk16 +++ /dev/null @@ -1,57 +0,0 @@ -@opt stack_pointer RG -@opt csr_scratch RH -@use ext_std:* - -; 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 |
