Some more information on the language Mach. The supplied instructions are: declare c halt pushv c pushi x pop c add sub negate output input toss dup All but declare are actual operations that affect the program and/or the runtime. declare defines a variable for later use in pushv and pop operations. The variables can be named, but are actually integers representing integer memory addresses. halt stops the computation pushv c pushes the current value of c from the memory onto the stack pushi x pushes the literal integer x onto the stack pop c pops the stack and places the result in variable c with the value popped add pops the stack twice adds the result and pushes it back onto the stack sub pops the stack twice, subtracts the first value popped from the second and pushes the result negate negates the value at the top of the stack in place output outputs (prints) the value at the top of the stack, leaving the value in place input obtains a value from the input and pushes it on the stack toss discards the value at the top of the stack dup copies the value at the top of the stack and pushes that value so that the two top values are equal. The conditions that can be tested are boolean pos boolean zero Using the condition operations. Most real assemblers provide a way for jumping from instruction to instruction at will. For example: // warning. Not legal Mach declare a; declare b; input; pop a; input; pop b; pushv a; pushv b; sub; if pos goto next; pushv b; next: pushv a; output; halt; The line "next:" is called a label. The line "if pos goto next" is a conditional jump. If the top of the stack is positive, then the next instruction to be executed will be the "pushv a" instruction after the label. If not, then the next instruction will be the one following the conditional jump. Jumps can be either forward or backwrd in the text of the program. A forward jump is like an if-then. A backward jump is like a loop. We can simulate this in Mach using a simple if statement for forward jumps and a do-while statement for backward jumps. The following could be written as: declare a; declare b; input; pop a; input; pop b; pushv a; pushv b; sub; dup negate if (pos)} pushv b; } toss; pushv a; output; halt; Note that we used dup and negate to reverse the sense of the test so that it would have the same effect as the jump-logic version. Likewise the following program can be made to jump backwards and hence repeat. declare a; declare b; input; output; pop a; input; output; pop b; pushv a; dup; pushv b; div; pushv b; mult; sub; output; halt; We just mark the top of the loop with a do at the place where we might put a label to be jumped to. We then put a conditional test (while) at the place where we wish to test the jump condition. declare a; declare b; input; do { output; pop a; input; output; pop b; pushv a; dup; pushv b; div; pushv b; mult; sub; output; input; } while (pos); halt; This version will repeatedly do its computation until the user enters a zero (after the first input). Note that we had to repeat the input command. The only allowable structures in this form are if(test){ ... } and do { ... } whil () where "" is one of pos and zero from the Mach language. The first form is a forward jump and the second is a backward one.