# Multiply
# multiply two numbers (written as a sum of ones)
#
# Input 11..11011..11
#
# Output 11..11 (product)
# St R W M New
0 1 _ r 2
0 0 _ r 13 # Fix this
2 0 _ r 10 # Zero here -- clean up!
2 1 _ r 3 # Erase this one, copy y
3 1 1 r 3 # Skip remainder of x.
3 0 0 r 4 # At beginning of y
4 1 j r 5
4 x x l 9
5 _ x l 8 # Wrote the one (as an x)
5 1 1 r 5
5 x x r 6
6 1 1 r 6
6 _ 1 l 7
7 1 1 l 7
7 x x l 8
8 1 1 l 8 # Move left until we hit a j
8 j j r 4
9 j 1 l 9 # We've finished the copy. Rewrite j as 1
9 0 0 l 9
9 1 1 l 9
9 _ _ r 2
10 1 1 r 10
10 x 1 l 11
#11 1 1 l 11
#11 _ _ r 12
#12 1 _ l 12
13 1 _ r 13
#14 1 1 l 14
#14 j j r 4