The program stack is also reversed every cycle.
There is a binary variable called flip, which starts out at 0, and flips its value every cycle.
||Creates a label called foo (doesn't trigger a cycle)|
||Jumps to the label foo if the top stack element is nonzero if flip is 0, else jump if zero (doesn't trigger a cycle)|
||Adds the top two stack elements, pops them, and pushes the sum if flip is 0, else subtract if flip is 1|
|*||Pushes a 1 onto the stack if flip is 0, else pop a value from the stack|
|'||Inputs a character and pushes it onto the stack if flip is 0, else output the top stack value|
Finite State Automaton
Switchy is not Turing complete and acts as a Finite-state automaton.
|State||Flip||State After *||State After '||Description|
|Empty||0||A||B||Stack is empty(This is also the starting point)|
|A||1||Empty||Empty(Output 1)||Stack contains a single 1|
|B||1||Empty||Empty(Output the input from ')||Stack contains a single character|
Note: because none of the states result in a stack of size two or more, a # can not be used.