Created
March 1, 2015 19:23
-
-
Save ndemonner/25a76ae27fdda1725235 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Factorial! | |
push 10 | |
store 0 | |
push 1 | |
store 1 | |
# | |
# Put the counter value on the stack. If it's 0, we're done | |
# and register 1 contains the final result. | |
# | |
recurse: | |
load 0 | |
jz :finish | |
load 1 # result | |
load 0 # count | |
mul | |
store 1 # new result | |
load 0 | |
push 1 | |
sub | |
store 0 | |
jmp :recurse | |
finish: | |
load 1 | |
stop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment