From: Jason Self Date: Fri, 31 Jul 2015 22:38:19 +0000 (-0700) Subject: Adding initial work on Z-machine X-Git-Url: https://jxself.org/git/?p=substrate.git;a=commitdiff_plain;h=ae0396abd3b3b68a03f678ca409e8528165c9383 Adding initial work on Z-machine --- diff --git a/documentation/z-machine.md b/documentation/z-machine.md new file mode 100644 index 0000000..521b9a5 --- /dev/null +++ b/documentation/z-machine.md @@ -0,0 +1,44 @@ +# Introduction +This document covers the Z-machine, a virtual machine that was +developed in 1979 and used by Infocom for its text-based games. The +name came from their their first adventure, Zork. + +## Format +This document is written using CommonMark, a markup language. More +information about CommonMark can be found at . + +## Copyright And Licensing +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Affero General Public License as published +by the Free Software Foundation ("FSF"), either version 3 of the +License, or (at your option) any later version published by the FSF. + +You should have received a copy of the GNU Affero General Public +License along with this document. If not see +. + +# Memory Map +The Z-machine's memory map is made up of byte addresses that run from +0 on up. These addresses are then divided into the three regions of +dynamic, static and high. + +Dynamic memory starts at $00000 and must contain at least 64 bits +(with the first 64 known as the "header"). This portion then runs up +to the address before the word at $0e. It can be read or written with +either direct commands (GET, GETB, PUT, PUTB) or indirect (MOVE, +REMOVE). Because of this ease of access, it is legal for games to +alter the tables stored here and above the header. + +Immediately following the dynamic memory is static. This memory must +end by the last byte of the story file or by $0ffff, whichever comes +first. Unlike dynamic, it is illegal for games to write or attempt to +write to this memory. It can be read using GET and GETB. It is also +not defined anywhere, even in the header. + +Finally, high memory begins at what is known as the "high memory +mark," or the word at $04 in the header. Since it continues until the +end of the story file, it has the potential to overlap with the static +but never the dynamic. Unlike both the static and dynamic, it cannot +be accessed directly in any form by a game program. Its contents are +routines that can be called and strings that can be printed with +PRINT.