Skip to content

Instantly share code, notes, and snippets.

@chiro
Last active August 29, 2015 14:04
Show Gist options
  • Save chiro/c5a6d3319da3c63d7fce to your computer and use it in GitHub Desktop.
Save chiro/c5a6d3319da3c63d7fce to your computer and use it in GitHub Desktop.
LDC 10 ; n
LDF 5
AP 1
DBUG
RTN
LD 0 0 ; entry point
LDC 1
CGT
SEL 10 22
RTN
LD 0 0 ;; n > 1
LDC 2
SUB
LDF 5
AP 1 ;; call fib(n-2)
LD 0 0
LDC 1
SUB
LDF 5
AP 1 ;; call fib(n-1)
ADD ;; calc fib(n-2) + fib(n-1)
JOIN
LDC 1 ;; if n <= 1 then return 1
JOIN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment