Skip to content

Instantly share code, notes, and snippets.

@0x0dea

0x0dea/trib.asm Secret

Created October 16, 2015 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0x0dea/0e581e84658dc339d253 to your computer and use it in GitHub Desktop.
Save 0x0dea/0e581e84658dc339d253 to your computer and use it in GitHub Desktop.
Memoized Tribonacci function in Whitespace assembly
0: push 0 dup inum load
dup jn 5 dup
push 0 dup store
1: dup jz 2
dup push -1 store
push 1 sub jump 1
2: dup store
push 1 dup store
push 2 push 1 store
call 3 onum push 10 ochr jump 0
3: dup load jn 4 load ret
4: dup dup dup
push 1 sub call 3 swap
push 2 sub call 3 add swap
push 3 sub call 3 add swap
copy 1 store ret
5: pop exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment