A very important aspect of the Pop-11 "virtual machine" is the stack. This is a part of the computer's memory used as a communication area in connection with procedures which take "arguments" (inputs) and return results, and also in connection with assignment.
(Note for experts: this is not the same as the procedure calling stack, which is a different area reserved for keeping track of which procedures are currently active.)
Consider a statement in which the value of an arithmetic expression is printed, for example:
2 + 2 => ** 4This statement is processed in two stages; firstly the arithmetic expression is evaluated and then secondly the result is printed. The result of evaluating the arithmetic expression is left on the stack, from where the print routine removes it.
As with a stack of plates, the last thing put on the stack is the first one you get off. Because the stack can accommodate more than one result, it is possible to write several expressions separated by commas, or semi-colons, each of which causes something to be put on the stack. For example:
2 + 3, 10 * 2, 5 - 3 =>If this instructions is obeyed then three numbers are put on the stack with 5 at the bottom, then 20 and finally 2 on the top. The print arrow prints the ENTIRE stack, starting from the bottom, and empties it, thus:
** 5 20 2Note that the top element of the stack is printed last.
The stack is in some ways like a datastructure, e.g. a variable-sized list or a vector, to which other Pop-11 objects can be added or removed at one end only, like a stack of dishes on to which new dishes can be added, one at a time, and from which the top item can be removed.
The stack is implemented differently from a Pop-11 datastructure, for efficiency. And it is not itself an object that can be put in a list, assigned to a variable, or given as input to a procedure. In fact there is no explicit way of referring to the stack. Rather it is implicitly referred to in very many Pop-11 instructions. It is not, what is sometimes referred to as a "first-class object".
A language that uses a stack in a similar way to Pop-11 is Forth. Some pocket calculators also use a stack in the same sort of way.