about summary refs log tree commit diff stats
path: root/subx
diff options
context:
space:
mode:
Diffstat (limited to 'subx')
-rw-r--r--subx/Readme.md35
1 files changed, 21 insertions, 14 deletions
diff --git a/subx/Readme.md b/subx/Readme.md
index a0fff7ca..404f4dc6 100644
--- a/subx/Readme.md
+++ b/subx/Readme.md
@@ -303,15 +303,15 @@ Within the code segment, each line contains a comment, label or instruction.
 Comments start with a `#` and are ignored. Labels should always be the first
 word on a line, and they end with a `:`.
 
-Instructions consist of a sequence of opcode bytes and their operands. As
-mentioned above, each opcode and operand can contain _metadata_ after a `/`.
-Metadata can be either for SubX or act as a comment for the reader; SubX
-silently ignores unrecognized metadata. A single word can contain multiple
-pieces of metadata, each starting with a `/`.
-
-SubX uses metadata to express instruction encoding and get decent error
-messages. You must tag each instruction operand with the appropriate operand
-type:
+Instructions consist of a sequence of words. As mentioned above, each word can
+contain _metadata_ after a `/`. Metadata can be either required by SubX or act
+as a comment for the reader; SubX silently ignores unrecognized metadata. A
+single word can contain multiple pieces of metadata, each starting with a `/`.
+
+The words in an instruction consist of 1-3 opcode bytes, and different kinds
+of operands corresponding to the bitfields in an x86 instruction listed above.
+For error checking, these operands must be tagged with one of the following
+bits of metadata:
   - `mod`
   - `rm32` ("r/m" in the x86 instruction diagram above, but we can't use `/`
     in metadata tags)
@@ -321,11 +321,18 @@ type:
   - displacement: `disp8`, `disp16` or `disp32`
   - immediate: `imm8` or `imm32`
 
-You don't need to remember what order instruction operands are in,
-or pack bitfields by hand. SubX will do all that for you. If you get the types
-wrong, giving an instruction an incorrect operand or forgetting an operand,
-you should get a clear error message. Remember, don't use `subop` (sub-operand
-above) and `r32` (reg in the x86 figure above) in a single instruction.
+Different instructions (opcodes) require different operands. SubX will
+validate each instruction in your programs, and raise an error anytime you
+miss or spuriously add an operand.
+
+I recommend you order operands consistently in your programs. SubX allows
+operands in any order, but only because that's simplest to explain/implement.
+Switching order from instruction to instruction is likely to add to the
+reader's burden. Here's the order I've been using:
+
+```
+/subop  /mod /rm32  /base /index /scale  /r32  /displacement  /immediate
+```
 
 Instructions can refer to labels in displacement or immediate operands, and
 they'll obtain a value based on the address of the label: immediate operands
-12-28 08:56:21 -0800

4881' href='/akkartik/mu/commit/subx/052kernel_string_equal.subx?h=main&id=5a9795bb661314d658afffd84059cc32e3b3b709'>5a9795bb ^
6030d7e2 ^
1666b12f ^
57628c0e ^

71ee78f2 ^
6030d7e2 ^
c98d4b1c ^
6030d7e2 ^
c98d4b1c ^
6030d7e2 ^









aff782c4 ^








6030d7e2 ^
dd9ba09a ^
6030d7e2 ^
dd9ba09a ^
6030d7e2 ^

dd9ba09a ^
6030d7e2 ^



71ee78f2 ^
6030d7e2 ^
71ee78f2 ^
57628c0e ^
6030d7e2 ^



57628c0e ^
6030d7e2 ^
71ee78f2 ^
57628c0e ^
6030d7e2 ^
71ee78f2 ^
57628c0e ^
6030d7e2 ^



71ee78f2 ^

6030d7e2 ^



71ee78f2 ^

6030d7e2 ^
71ee78f2 ^
6030d7e2 ^
71ee78f2 ^
6030d7e2 ^
71ee78f2 ^
ee9a9237 ^
6030d7e2 ^




ee9a9237 ^
6030d7e2 ^


57628c0e ^
9d27e966 ^
57628c0e ^
03d50cc8 ^
71ee78f2 ^
ee9a9237 ^
6030d7e2 ^

ee9a9237 ^
71ee78f2 ^
ee9a9237 ^
6030d7e2 ^
9d27e966 ^
ee9a9237 ^
6030d7e2 ^


ee9a9237 ^
6030d7e2 ^
ee9a9237 ^
6030d7e2 ^

57628c0e ^
03d50cc8 ^
71ee78f2 ^
ee9a9237 ^
6030d7e2 ^

ee9a9237 ^
71ee78f2 ^
ee9a9237 ^
6030d7e2 ^
9d27e966 ^
ee9a9237 ^
6030d7e2 ^


ee9a9237 ^
6030d7e2 ^
ee9a9237 ^
6030d7e2 ^

57628c0e ^
03d50cc8 ^
71ee78f2 ^
ee9a9237 ^
6030d7e2 ^
8b9dd2d1 ^
ee9a9237 ^
71ee78f2 ^
ee9a9237 ^
6030d7e2 ^
9d27e966 ^
ee9a9237 ^
6030d7e2 ^


ee9a9237 ^
6030d7e2 ^
ee9a9237 ^
6030d7e2 ^

57628c0e ^
03d50cc8 ^
71ee78f2 ^
ee9a9237 ^
6030d7e2 ^
8b9dd2d1 ^
ee9a9237 ^
71ee78f2 ^
ee9a9237 ^
6030d7e2 ^
9d27e966 ^
ee9a9237 ^
6030d7e2 ^


ee9a9237 ^
6030d7e2 ^
ee9a9237 ^
6030d7e2 ^

57628c0e ^
03d50cc8 ^
71ee78f2 ^
ee9a9237 ^
6030d7e2 ^
8b9dd2d1 ^
ee9a9237 ^
71ee78f2 ^
ee9a9237 ^
6030d7e2 ^
00439520 ^
ee9a9237 ^
6030d7e2 ^


ee9a9237 ^
6030d7e2 ^
ee9a9237 ^
6030d7e2 ^

57628c0e ^
03d50cc8 ^
71ee78f2 ^
ee9a9237 ^
6030d7e2 ^
8b9dd2d1 ^
ee9a9237 ^
71ee78f2 ^
ee9a9237 ^
6030d7e2 ^
00439520 ^
ee9a9237 ^
6030d7e2 ^


ee9a9237 ^
6030d7e2 ^
ee9a9237 ^
6030d7e2 ^

57628c0e ^
03d50cc8 ^
71ee78f2 ^
ee9a9237 ^
6030d7e2 ^
8b9dd2d1 ^
ee9a9237 ^
71ee78f2 ^
ee9a9237 ^
6030d7e2 ^
00439520 ^
ee9a9237 ^
6030d7e2 ^


ee9a9237 ^
6030d7e2 ^
ee9a9237 ^
6030d7e2 ^

57628c0e ^


03d50cc8 ^
6030d7e2 ^
8b9dd2d1 ^
6030d7e2 ^
4224ec81 ^
ee9a9237 ^
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259