2 This document covers the Z-machine, a virtual machine that was
3 developed in 1979 and used by Infocom for its text-based games. The
4 name came from their their first adventure, Zork.
7 This document is written using CommonMark, a markup language. More
8 information about CommonMark can be found at <http://commonmark.org>.
10 ## Copyright And Licensing
11 Permission is granted to copy, distribute and/or modify this document
12 under the terms of the GNU Affero General Public License as published
13 by the Free Software Foundation ("FSF"), either version 3 of the
14 License, or (at your option) any later version published by the FSF.
16 You should have received a copy of the GNU Affero General Public
17 License along with this document. If not see
18 <https://gnu.org/licenses/>.
21 The Z-machine's memory map is made up of byte addresses that run from
22 0 on up. These addresses are then divided into the three regions of
23 dynamic, static and high.
25 Dynamic memory starts at $00000 and must contain at least 64 bits
26 (with the first 64 known as the "header"). This portion then runs up
27 to the address before the word at $0e. It can be read or written with
28 either direct commands (GET, GETB, PUT, PUTB) or indirect (MOVE,
29 REMOVE). Because of this ease of access, it is legal for games to
30 alter the tables stored here and above the header.
32 Immediately following the dynamic memory is static. This memory must
33 end by the last byte of the story file or by $0ffff, whichever comes
34 first. Unlike dynamic, it is illegal for games to write or attempt to
35 write to this memory. It can be read using GET and GETB. It is also
36 not defined anywhere, even in the header.
38 Finally, high memory begins at what is known as the "high memory
39 mark," or the word at $04 in the header. Since it continues until the
40 end of the story file, it has the potential to overlap with the static
41 but never the dynamic. Unlike both the static and dynamic, it cannot
42 be accessed directly in any form by a game program. Its contents are
43 routines that can be called and strings that can be printed with