The memory map of the Z-machine is an array of bytes with "byte addresses" running from 0 upwards. This is divided into three regions: "dynamic", "static" and "high". Dynamic memory begins from byte address $00000 and runs up to the byte before the byte address stored in the word at $0e in the header. (Dynamic memory must contain at least 64 bytes.) Static memory follows immediately on. Its extent is not defined in the header (or anywhere else), though it must end by the last byte of the story file or by byte address $0ffff (whichever is lower). High memory begins at the "high memory mark" (the byte address stored in the word at $04 in the header) and continues to the end of the story file. The bottom of high memory may overlap with the top of static memory (but not with dynamic memory).
1.1.1
Dynamic memory can be read or written to (either directly, using loadb, loadw, storeb and storew, or indirectly with opcodes such as insert_obj and remove_obj).
1.1.1.1
By tradition, the first 64 bytes are known as the "header". The contents of this are given later but note that games are not permitted to alter many bits inside it.
1.1.1.2
It is legal for games to alter any of the tables stored in dynamic memory above the header, provided they leave the tables in legal states.
1.1.2
Static memory can be read using the opcodes loadb and loadw. It is illegal for a game to attempt to write to static memory.
1.1.3
Except for its (possible) overlap with static memory, high memory cannot be directly accessed at all by a game program. It contains routines, which can be called, and strings, which can be printed using print_paddr.
1.1.4
The maximum permitted length of a story file depends on the Version, as follows:
V1-3 V4-5 V6 V7 V8 128 256 512 320 512
Dynamic | 00000 | header |
00040 | abbreviation strings | |
00042 | abbreviation table | |
00102 | property defaults | |
00140 | objects | |
002f0 | object descriptions and properties | |
006e3 | global variables | |
008c3 | arrays | |
Static | 00b48 | grammar table |
010a7 | actions table | |
01153 | preactions table | |
01201 | adjectives table | |
0124d | dictionary | |
High | 01a0a | Z-code |
05d56 | static strings | |
06ae6 | end of file |
Note that the total of dynamic plus static memory must not exceed 64K. (In fact, 64K minus 2 bytes.) This is the most serious limitation on the Z-machine (though it has not yet been reached by anyone).
Throughout the specification, Versions 7 and 8 are identical to Version 5 except as stated at 1.1.4 and 1.2.3 above.
Section 1 / 2 / 3 / 4 / 5 / 6 / 7 / 8 / 9 / 10 / 11 / 12 / 13 / 14 / 15 / 16
Appendix A / B / C / D / E / F