A routine is required to begin at an address in memory which can be represented by a packed address (for instance, in Version 5 it must occur at a byte address which is divisible by 4).
A routine begins with one byte indicating the number of local
variables it has (between 0 and 15 inclusive).
In Versions 1 to 4, that number of 2-byte words follows,
giving initial values for these local variables. In Versions 5 and
later, the initial values are all zero.
Execution of instructions begins from the byte after this
header information. There is no formal 'end-marker' for a routine
(it is simply assumed that execution eventually results in a return
taking place).
In Version 6, there is a "main" routine (whose packed address
is stored in the word at $06 in the header) called when the game
starts up. It is illegal to return from this routine.
In all other Versions, the word at $06 contains the
byte address of the first instruction to execute. The Z-machine
starts in an environment with no local variables from which, again,
a return is illegal.
In Versions 3 and 4, Inform always stores 0 as the initial values
for local variables.
Inform's "main" routine is required not to have local variables
and has to be the first defined routine. This ensures it is in the
bottom 64K of memory, as it must be (in Versions other than 6).
Section
1 / 2 /
3 / 4 /
5 / 6 /
7 / 8 /
9 / 10 /
11 / 12 /
13 / 14 /
15 / 16
Appendix
A / B /
C / D /
E / F
5.2
5.2.1
5.3
5.4
5.5Remarks
Note that it is permissible for a routine to be in dynamic memory.
Marnix Klooster suggests this might be used for compiling code at
run time!