The Z-machine had two types of storage: memory and stack. The memory contains the code and object tree for the program, while the stack holds local variables and temporary values. The Z-machine executed one instruction at a time starting at the program counter (PC). Its basic instructions included:
The Z-machine made it easy to express adventure games compactly by providing instructions for common operations. The mainframe version of Zork duplicated code for tasks like moving objects from one place to another, checking objects for certain properties, modifying properties, testing for hierarchical relationships. In the Z-machine, these operations could be expressed in several bytes of code-a huge savings factor. Table 2 shows a listing of some of the basic instructions of the Z-machine.
Several other techniques were used to make Zork even smaller. The Z-machine compressed text, which constituted a large portion of the data, by using a representation that required approximately five and a half bits per character instead of the usual eight. In addition, Infocom stripped out many unnecessary features of MDL, such as associative storage, and created a language called the Zork Implementation Language (ZIL).
With the Z-machine design completed, Berez and Blank began writing a two-stage compiler that would convert the high-level ZIL code first to assembly code and then to Z-machine byte-codes. Blank then wrote a Z-machine software emulator-which came to be known as a Z-machine Interpretive Program (ZIP)-for the DECsystem-20. In 1980, Scott Cutler, a member of the DM group who went on to work in New York, finished writing a ZIP for the TRS-80 Model I. And in 1981, working remotely from California, Bruce Daniels completed a ZIP for the Apple II.
Now that you are a Z-machine expert. Would you like to:
Go back to the page on the overview of the z-machine
Or go forward and learn about the culture at Infocom