Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 335 lines (311 sloc) 3.44 KB
# Rock Paper Scissors
# Simple two player game based on Nate Young's original challenge: http://twoguysarguing.wordpress.com/2009/12/09/rock-paper-scissors/
# **** Player 1 Name: ****
push 32 58 101 109 97 78 32 49 32 114 101 121 97 108 80
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
# **** push delimeter ****
push 1 11
subtract
# **** push word count ****
push 1
push 1
subtract
# **** Input player 1 name until new line and reverse ****
:p1inputname
push 1
add
in
duplicate
roll 3 1
push 10
subtract
not
not
goto p1inputname IGNORE
push 1
subtract
roll 2 1
pop
# **** reverse player 1 name so that it can later be printed
:reverseplayer1name
duplicate
push 1
subtract
not
goto donereverseplayer1name NOWHERE
duplicate
push 1
subtract
push 3
push 1
roll
push 1
add
push 1
roll
push 1
goto reverseplayer1name NOWHERE
:donereverseplayer1name
pop
# **** Player 2 Name: ****
push 32 58 101 109 97 78 32 40 32 114 101 121 97 108 80
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
# **** push delimeter ****
push 1 11
subtract
# **** push word count ****
push 1
push 1
subtract
# **** Input player 2 name until new line and reverse ****
:p2inputname
push 1
add
in
duplicate
roll 3 1
push 10
subtract
not
not
goto p2inputname IGNORE
push 1
subtract
roll 2 1
pop
# **** reverse player 2 name so that it can later be printed
:reverseplayer2name
duplicate
push 1
subtract
not
goto donereverseplayer2name NOWHERE
duplicate
push 1
subtract
push 3
push 1
roll
push 1
add
push 1
roll
push 1
goto reverseplayer2name NOWHERE
:donereverseplayer2name
pop
# **** [R]ock, [P]aper, or [S]cissors? for player 1 ****
push 32 63 115 114 111 115 115 105 99 93 83 91 32 114 111 32 44 114 101 112 97 93 80 91 32 44 107 99 111 93 82 91
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
# **** input player 1 move ****
in
in
pop
# **** [R]ock, [P]aper, or [S]cissors? for player 2 ****
push 32 63 115 114 111 115 115 105 99 93 83 91 32 114 111 32 44 114 101 112 97 93 80 91 32 44 107 99 111 93 82 91
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
out
# **** input player 2 move ****
in
in
pop
# **** figure out who won, leave 1 for player 1, leave 3 for player 2, leave 0 for tie
# R 82
# P 80
# S 83
# RS -1 player 1
# PR -2 player 1
# SP 3 player 1
# RP 2 player 2
# PS -3 player 2
# SR 1 player 2
subtract
duplicate
push 0
subtract
not
goto tie NOWHERE
duplicate
push 1
subtract
not
goto winplayer2 NOWHERE
duplicate
push 2
subtract
not
goto winplayer2 NOWHERE
duplicate
push 0
push 3
subtract
subtract
not
goto winplayer2 NOWHERE
duplicate
push 0
push 1
subtract
subtract
not
goto winplayer1 NOWHERE
duplicate
push 0
push 2
subtract
subtract
not
goto winplayer1 NOWHERE
duplicate
push 3
subtract
not
goto winplayer1 NOWHERE
:bad inputs
push 100000
out
end
:tie
push 33 69 73 84
out
out
out
out
end
:winplayer2
pop
:trytoprintplayer2name
duplicate
push 1
push 11
subtract
subtract
not
goto finalprint NOWHERE
out
push 1
goto trytoprintplayer2name NOWHERE
:winplayer1
pop
:ignoreplayer2name
duplicate
push 1
push 11
subtract
subtract
not
goto printplayer1name NOWHERE
pop
push 1
goto ignoreplayer2name NOWHERE
:printplayer1name
pop
:trytoprintplayer1name
duplicate
push 1
push 11
subtract
subtract
not
goto finalprint NOWHERE
out
push 1
goto trytoprintplayer1name NOWHERE
:finalprint
push 33 115 110 105 87 32
out
out
out
out
out
out
end