Skip to content

Instantly share code, notes, and snippets.

@nyuichi
Created March 5, 2012 13:06
Show Gist options
  • Save nyuichi/1978242 to your computer and use it in GitHub Desktop.
Save nyuichi/1978242 to your computer and use it in GitHub Desktop.
(def fib (n)
(if (< n 2)
1
(+ (fib (- n 1)) (fib (- n 2)))))
(fib 30)
-------------------------------------------
[0] const 0x79 ; fixnum(30)
[5] call 6 ; fib
[10] halt
fib:
[11] const 0x09 ; fixnum(2)
[16] lref -1 ; n
[21] lt
[22] jnz 11 ; [33]
[27] const 0x05 ; fixnum(1)
[32] ret
[33] const 0x09 ; fixnum(2)
[38] lref -1 ; n
[43] sub
[44] call -33 ; fib
[49] const 0x05 ; fixnum(1)
[54] lref -1 ; n
[59] sub
[60] call -49 ; fib
[65] add
[66] ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment