-
Notifications
You must be signed in to change notification settings - Fork 4
/
sect05.html
104 lines (82 loc) · 2.97 KB
/
sect05.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<!DOCTYPE html>
<html>
<head>
<title>The Z-Machine Standards Document</title>
<link rel="stylesheet" type="text/css" href="zspec.css">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
</head>
<body>
<img class="icon" src="images/icon05.gif" alt="">
<h1>5. How routines are encoded</h1>
<hr>
<p>5.1 <a href="#5.1">Start position</a> /
5.2 <a href="#5.2">Header</a> /
5.3 <a href="#5.3">First instruction</a> /
5.4 <a href="#5.4">Main routine (V6)</a> /
5.5 <a href="#5.5">Initial execution point (other versions)</a>
</p>
<hr>
<h2 id="5.1">5.1</h2>
<p>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).
</p>
<h2 id="5.2">5.2</h2>
<p>A routine begins with one byte indicating the number of local
variables it has (between 0 and 15 inclusive).
</p>
<h2 id="5.2.1">5.2.1</h2>
<p>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.
</p>
<h2 id="5.3">5.3</h2>
<p>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).
</p>
<h2 id="5.4">5.4</h2>
<p>In Version 6, there is a "main" routine (whose packed address
is stored in the word at <strong>$06</strong> in the header) called when the game
starts up. It is illegal to return from this routine.
</p>
<h2 id="5.5">5.5</h2>
<p>In all other Versions, the word at <strong>$06</strong> 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.
</p>
<hr>
<h2 id="remarks">Remarks</h2>
<p>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!
</p>
<p>In Versions 3 and 4, Inform always stores 0 as the initial values
for local variables.
</p>
<hr>
<p>
<a href="index.html">Contents</a> /
<a href="preface.html">Preface</a> /
<a href="overview.html">Overview</a>
</p>
<p>Section
<a href="sect01.html">1</a> / <a href="sect02.html">2</a> /
<a href="sect03.html">3</a> / <a href="sect04.html">4</a> /
<a href="sect05.html">5</a> / <a href="sect06.html">6</a> /
<a href="sect07.html">7</a> / <a href="sect08.html">8</a> /
<a href="sect09.html">9</a> / <a href="sect10.html">10</a> /
<a href="sect11.html">11</a> / <a href="sect12.html">12</a> /
<a href="sect13.html">13</a> / <a href="sect14.html">14</a> /
<a href="sect15.html">15</a> / <a href="sect16.html">16</a>
</p>
<p>Appendix
<a href="appa.html">A</a> / <a href="appb.html">B</a> /
<a href="appc.html">C</a> / <a href="appd.html">D</a> /
<a href="appe.html">E</a> / <a href="appf.html">F</a>
</p>
<hr>
</body>
</html>