[Next] [Up] [Previous]
Next: Assignment Up: Appendix: Programming in POP-11 Previous: Mishaps


We now need a way of storing information in the computer's memory so that the results of expressions can be saved for later use. Earlier in the chapter we said that memory can be thought of as if it were a large number of boxes, each of which is capable of storing some information. To use them, we place a particular piece of information in a named location (box), and then refer by name to the the location that contains the information. A named location is called a variable. POP-11 carries out the work of allocating and accessing particular locations automatically. Suppose that we want to store a list of words in memory. We give that part of memory a name, say myinfo, by means of the POP-11 instruction

vars myinfo;

It is preceded by vars because myinfo is the name of a variable. Any POP-11 word can be the name of a variable, and the vars instruction declares the variable by entering the word in its list of variable names and by allocating memory for it. Once we have given the vars command, we can store a data item in the memory set aside, and refer to it again by the name myinfo. We can have as many variables as we like in a POP-11 program and we can declare more than one in a vars command; they should be separated by commas.

Cogsweb Project: luisgh@cogs.susx.ac.uk