This repository has been archived by the owner on Oct 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
z80parser.pegjs
435 lines (424 loc) · 44.8 KB
/
z80parser.pegjs
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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
Start
= Z80
//
// chars
//
_
= [\t\v\f \u00A0\uFEFF]*
Identifier
= p:"."? s:[a-zA-Z_0-9\.]+ { return (p||'') + s.join(''); }
//
// basic types
//
Int3
= n:Number { if(n<0||n>7) throw new Error('Value overflow'); else return n; }
Int8
= '$nn' { return {type:'byte', expr:'$nn'}; }
/ n:Number { return {type:'byte', expr:n}; }
/ i:Identifier { return {type:'byte', expr:{id:i}}; }
Int16
= '$nn' { return [{type:'word', expr:'$nn'}, 0]; }
/ n:Number { return [{type:'word', expr:n}, 0]; }
/ i:Identifier { return [{type:'word', expr:{id:i}}, 0]; }
Offset8
= '$nn' { return {type:'relative', expr:'$nn'}; }
/ "+" n:Number { return n; }
/ "-" n:Number { return -n; }
/ n:Number { return {type:'relative', expr:n}; }
/ i:Identifier { return {type:'relative', expr:{id:i}}; }
Number
= s:([+-])? text:[0-9]+ "h" { return parseInt(s+text.join(""), 16); }
/ s:([+-])? text:[0-1]+ "b" { return parseInt(s+text.join(""), 2); }
/ s:([+-])? "0x" text:[0-9]+ { return parseInt(s+text.join(""), 16); }
/ s:([+-])? "0b" text:[0-1]+ { return parseInt(s+text.join(""), 2); }
/ s:([+-])? text:[0-9]+ { return parseInt(s+text.join("")); }
//
// tables
//
TableR
= "A"i { return 7; }
/ "B"i { return 0; }
/ "C"i { return 1; }
/ "D"i { return 2; }
/ "E"i { return 3; }
/ "H"i { return 4; }
/ "L"i { return 5; }
/ "(HL)"i { return 6; }
TableIXp
= "IXh"i { return 4; }
/ "IXl"i { return 5; }
/ "A"i { return 7; }
/ "B"i { return 0; }
/ "C"i { return 1; }
/ "D"i { return 2; }
/ "E"i { return 3; }
TableIYq
= "IYh"i { return 4; }
/ "IYl"i { return 5; }
/ "A"i { return 7; }
/ "B"i { return 0; }
/ "C"i { return 1; }
/ "D"i { return 2; }
/ "E"i { return 3; }
// generated by util/opcodes.js
Z80
= "ADC"i _ "A"i _ "," _ "(HL)"i { return [0x8E]; } // ADC A,(HL)
/ "ADC"i _ "A"i _ "," _ "(" _ "IX"i _ oo:Offset8 _ ")" { return [0xDD,0x8E,oo]; } // ADC A,(IX+o)
/ "ADC"i _ "A"i _ "," _ "(" _ "IY"i _ oo:Offset8 _ ")" { return [0xFD,0x8E,oo]; } // ADC A,(IY+o)
/ "ADC"i _ "A"i _ "," _ r:TableR { return [0x88+r]; } // ADC A,r
/ "ADC"i _ "A"i _ "," _ p:TableIXp { return [0xDD,0x88+p]; } // ADC A,IXp
/ "ADC"i _ "A"i _ "," _ q:TableIYq { return [0xFD,0x88+q]; } // ADC A,IYq
/ "ADC"i _ "A"i _ "," _ nn:Int8 { return [0xCE,nn]; } // ADC A,n
/ "ADC"i _ "HL"i _ "," _ "BC"i { return [0xED,0x4A]; } // ADC HL,BC
/ "ADC"i _ "HL"i _ "," _ "DE"i { return [0xED,0x5A]; } // ADC HL,DE
/ "ADC"i _ "HL"i _ "," _ "HL"i { return [0xED,0x6A]; } // ADC HL,HL
/ "ADC"i _ "HL"i _ "," _ "SP"i { return [0xED,0x7A]; } // ADC HL,SP
/ "ADD"i _ "A"i _ "," _ "(HL)"i { return [0x86]; } // ADD A,(HL)
/ "ADD"i _ "A"i _ "," _ "(" _ "IX"i _ oo:Offset8 _ ")" { return [0xDD,0x86,oo]; } // ADD A,(IX+o)
/ "ADD"i _ "A"i _ "," _ "(" _ "IY"i _ oo:Offset8 _ ")" { return [0xFD,0x86,oo]; } // ADD A,(IY+o)
/ "ADD"i _ "A"i _ "," _ r:TableR { return [0x80+r]; } // ADD A,r
/ "ADD"i _ "A"i _ "," _ p:TableIXp { return [0xDD,0x80+p]; } // ADD A,IXp
/ "ADD"i _ "A"i _ "," _ q:TableIYq { return [0xFD,0x80+q]; } // ADD A,IYq
/ "ADD"i _ "A"i _ "," _ nn:Int8 { return [0xC6,nn]; } // ADD A,n
/ "ADD"i _ "HL"i _ "," _ "BC"i { return [0x09]; } // ADD HL,BC
/ "ADD"i _ "HL"i _ "," _ "DE"i { return [0x19]; } // ADD HL,DE
/ "ADD"i _ "HL"i _ "," _ "HL"i { return [0x29]; } // ADD HL,HL
/ "ADD"i _ "HL"i _ "," _ "SP"i { return [0x39]; } // ADD HL,SP
/ "ADD"i _ "IX"i _ "," _ "BC"i { return [0xDD,0x09]; } // ADD IX,BC
/ "ADD"i _ "IX"i _ "," _ "DE"i { return [0xDD,0x19]; } // ADD IX,DE
/ "ADD"i _ "IX"i _ "," _ "IX"i { return [0xDD,0x29]; } // ADD IX,IX
/ "ADD"i _ "IX"i _ "," _ "SP"i { return [0xDD,0x39]; } // ADD IX,SP
/ "ADD"i _ "IY"i _ "," _ "BC"i { return [0xFD,0x09]; } // ADD IY,BC
/ "ADD"i _ "IY"i _ "," _ "DE"i { return [0xFD,0x19]; } // ADD IY,DE
/ "ADD"i _ "IY"i _ "," _ "IY"i { return [0xFD,0x29]; } // ADD IY,IY
/ "ADD"i _ "IY"i _ "," _ "SP"i { return [0xFD,0x39]; } // ADD IY,SP
/ "AND"i _ "(HL)"i { return [0xA6]; } // AND (HL)
/ "AND"i _ "(" _ "IX"i _ oo:Offset8 _ ")" { return [0xDD,0xA6,oo]; } // AND (IX+o)
/ "AND"i _ "(" _ "IY"i _ oo:Offset8 _ ")" { return [0xFD,0xA6,oo]; } // AND (IY+o)
/ "AND"i _ r:TableR { return [0xA0+r]; } // AND r
/ "AND"i _ p:TableIXp { return [0xDD,0xA0+p]; } // AND IXp
/ "AND"i _ q:TableIYq { return [0xFD,0xA0+q]; } // AND IYq
/ "AND"i _ nn:Int8 { return [0xE6,nn]; } // AND n
/ "BIT"i _ b:Int3 _ "," _ "(HL)"i { return [0xCB,0x46+0x8*b]; } // BIT b,(HL)
/ "BIT"i _ b:Int3 _ "," _ "(" _ "IX"i _ oo:Offset8 _ ")" { return [0xDD,0xCB,oo,0x46+0x8*b]; } // BIT b,(IX+o)
/ "BIT"i _ b:Int3 _ "," _ "(" _ "IY"i _ oo:Offset8 _ ")" { return [0xFD,0xCB,oo,0x46+0x8*b]; } // BIT b,(IY+o)
/ "BIT"i _ b:Int3 _ "," _ r:TableR { return [0xCB,0x40+0x8*b+r]; } // BIT b,r
/ "CALL"i _ "C"i _ "," _ nn:Int16 { return [0xDC,nn[0],nn[1]]; } // CALL C,nn
/ "CALL"i _ "M"i _ "," _ nn:Int16 { return [0xFC,nn[0],nn[1]]; } // CALL M,nn
/ "CALL"i _ "NC"i _ "," _ nn:Int16 { return [0xD4,nn[0],nn[1]]; } // CALL NC,nn
/ "CALL"i _ "NZ"i _ "," _ nn:Int16 { return [0xC4,nn[0],nn[1]]; } // CALL NZ,nn
/ "CALL"i _ "P"i _ "," _ nn:Int16 { return [0xF4,nn[0],nn[1]]; } // CALL P,nn
/ "CALL"i _ "PE"i _ "," _ nn:Int16 { return [0xEC,nn[0],nn[1]]; } // CALL PE,nn
/ "CALL"i _ "PO"i _ "," _ nn:Int16 { return [0xE4,nn[0],nn[1]]; } // CALL PO,nn
/ "CALL"i _ "Z"i _ "," _ nn:Int16 { return [0xCC,nn[0],nn[1]]; } // CALL Z,nn
/ "CALL"i _ nn:Int16 { return [0xCD,nn[0],nn[1]]; } // CALL nn
/ "CCF"i { return [0x3F]; } // CCF
/ "CP"i _ "(HL)"i { return [0xBE]; } // CP (HL)
/ "CP"i _ "(" _ "IX"i _ oo:Offset8 _ ")" { return [0xDD,0xBE,oo]; } // CP (IX+o)
/ "CP"i _ "(" _ "IY"i _ oo:Offset8 _ ")" { return [0xFD,0xBE,oo]; } // CP (IY+o)
/ "CP"i _ r:TableR { return [0xB8+r]; } // CP r
/ "CP"i _ p:TableIXp { return [0xDD,0xB8+p]; } // CP IXp
/ "CP"i _ q:TableIYq { return [0xFD,0xB8+q]; } // CP IYq
/ "CP"i _ nn:Int8 { return [0xFE,nn]; } // CP n
/ "CPDR"i { return [0xED,0xB9]; } // CPDR
/ "CPD"i { return [0xED,0xA9]; } // CPD
/ "CPIR"i { return [0xED,0xB1]; } // CPIR
/ "CPI"i { return [0xED,0xA1]; } // CPI
/ "CPL"i { return [0x2F]; } // CPL
/ "DAA"i { return [0x27]; } // DAA
/ "DEC"i _ "(HL)"i { return [0x35]; } // DEC (HL)
/ "DEC"i _ "(" _ "IX"i _ oo:Offset8 _ ")" { return [0xDD,0x35,oo]; } // DEC (IX+o)
/ "DEC"i _ "(" _ "IY"i _ oo:Offset8 _ ")" { return [0xFD,0x35,oo]; } // DEC (IY+o)
/ "DEC"i _ "BC"i { return [0x0B]; } // DEC BC
/ "DEC"i _ "DE"i { return [0x1B]; } // DEC DE
/ "DEC"i _ "HL"i { return [0x2B]; } // DEC HL
/ "DEC"i _ "IX"i { return [0xDD,0x2B]; } // DEC IX
/ "DEC"i _ "IY"i { return [0xFD,0x2B]; } // DEC IY
/ "DEC"i _ "A"i { return [0x3D]; } // DEC A
/ "DEC"i _ "B"i { return [0x05]; } // DEC B
/ "DEC"i _ "C"i { return [0x0D]; } // DEC C
/ "DEC"i _ "D"i { return [0x15]; } // DEC D
/ "DEC"i _ "E"i { return [0x1D]; } // DEC E
/ "DEC"i _ "H"i { return [0x25]; } // DEC H
/ "DEC"i _ p:TableIXp { return [0xDD,0x05+0x8*p]; } // DEC IXp
/ "DEC"i _ q:TableIYq { return [0xFD,0x05+0x8*q]; } // DEC IYq
/ "DEC"i _ "L"i { return [0x2D]; } // DEC L
/ "DEC"i _ "SP"i { return [0x3B]; } // DEC SP
/ "DI"i { return [0xF3]; } // DI
/ "DJNZ"i _ oo:Offset8 { return [0x10,oo]; } // DJNZ o
/ "EI"i { return [0xFB]; } // EI
/ "EX"i _ "(SP)"i _ "," _ "HL"i { return [0xE3]; } // EX (SP),HL
/ "EX"i _ "(SP)"i _ "," _ "IX"i { return [0xDD,0xE3]; } // EX (SP),IX
/ "EX"i _ "(SP)"i _ "," _ "IY"i { return [0xFD,0xE3]; } // EX (SP),IY
/ "EX"i _ "AF"i _ "," _ "AF'"i { return [0x08]; } // EX AF,AF'
/ "EX"i _ "DE"i _ "," _ "HL"i { return [0xEB]; } // EX DE,HL
/ "EXX"i { return [0xD9]; } // EXX
/ "HALT"i { return [0x76]; } // HALT
/ "IM"i _ "0"i { return [0xED,0x46]; } // IM 0
/ "IM"i _ "1"i { return [0xED,0x56]; } // IM 1
/ "IM"i _ "2"i { return [0xED,0x5E]; } // IM 2
/ "IN"i _ "A"i _ "," _ "(C)"i { return [0xED,0x78]; } // IN A,(C)
/ "IN"i _ "A"i _ "," _ "(" _ nn:Int8 _ ")" { return [0xDB,nn]; } // IN A,(n)
/ "IN"i _ "B"i _ "," _ "(C)"i { return [0xED,0x40]; } // IN B,(C)
/ "IN"i _ "C"i _ "," _ "(C)"i { return [0xED,0x48]; } // IN C,(C)
/ "IN"i _ "D"i _ "," _ "(C)"i { return [0xED,0x50]; } // IN D,(C)
/ "IN"i _ "E"i _ "," _ "(C)"i { return [0xED,0x58]; } // IN E,(C)
/ "IN"i _ "H"i _ "," _ "(C)"i { return [0xED,0x60]; } // IN H,(C)
/ "IN"i _ "L"i _ "," _ "(C)"i { return [0xED,0x68]; } // IN L,(C)
/ "IN"i _ "F"i _ "," _ "(C)"i { return [0xED,0x70]; } // IN F,(C)
/ "INC"i _ "(HL)"i { return [0x34]; } // INC (HL)
/ "INC"i _ "(" _ "IX"i _ oo:Offset8 _ ")" { return [0xDD,0x34,oo]; } // INC (IX+o)
/ "INC"i _ "(" _ "IY"i _ oo:Offset8 _ ")" { return [0xFD,0x34,oo]; } // INC (IY+o)
/ "INC"i _ "BC"i { return [0x03]; } // INC BC
/ "INC"i _ "DE"i { return [0x13]; } // INC DE
/ "INC"i _ "HL"i { return [0x23]; } // INC HL
/ "INC"i _ "IX"i { return [0xDD,0x23]; } // INC IX
/ "INC"i _ "IY"i { return [0xFD,0x23]; } // INC IY
/ "INC"i _ "A"i { return [0x3C]; } // INC A
/ "INC"i _ "B"i { return [0x04]; } // INC B
/ "INC"i _ "C"i { return [0x0C]; } // INC C
/ "INC"i _ "D"i { return [0x14]; } // INC D
/ "INC"i _ "E"i { return [0x1C]; } // INC E
/ "INC"i _ "H"i { return [0x24]; } // INC H
/ "INC"i _ "L"i { return [0x2C]; } // INC L
/ "INC"i _ p:TableIXp { return [0xDD,0x04+0x8*p]; } // INC IXp
/ "INC"i _ q:TableIYq { return [0xFD,0x04+0x8*q]; } // INC IYq
/ "INC"i _ "SP"i { return [0x33]; } // INC SP
/ "IND"i { return [0xED,0xAA]; } // IND
/ "INDR"i { return [0xED,0xBA]; } // INDR
/ "INI"i { return [0xED,0xA2]; } // INI
/ "INIR"i { return [0xED,0xB2]; } // INIR
/ "JP"i _ "(HL)"i { return [0xE9]; } // JP (HL)
/ "JP"i _ "(IX)"i { return [0xDD,0xE9]; } // JP (IX)
/ "JP"i _ "(IY)"i { return [0xFD,0xE9]; } // JP (IY)
/ "JP"i _ "C"i _ "," _ nn:Int16 { return [0xDA,nn[0],nn[1]]; } // JP C,nn
/ "JP"i _ "M"i _ "," _ nn:Int16 { return [0xFA,nn[0],nn[1]]; } // JP M,nn
/ "JP"i _ "NC"i _ "," _ nn:Int16 { return [0xD2,nn[0],nn[1]]; } // JP NC,nn
/ "JP"i _ "NZ"i _ "," _ nn:Int16 { return [0xC2,nn[0],nn[1]]; } // JP NZ,nn
/ "JP"i _ "P"i _ "," _ nn:Int16 { return [0xF2,nn[0],nn[1]]; } // JP P,nn
/ "JP"i _ "PE"i _ "," _ nn:Int16 { return [0xEA,nn[0],nn[1]]; } // JP PE,nn
/ "JP"i _ "PO"i _ "," _ nn:Int16 { return [0xE2,nn[0],nn[1]]; } // JP PO,nn
/ "JP"i _ "Z"i _ "," _ nn:Int16 { return [0xCA,nn[0],nn[1]]; } // JP Z,nn
/ "JP"i _ nn:Int16 { return [0xC3,nn[0],nn[1]]; } // JP nn
/ "JR"i _ "C"i _ "," _ oo:Offset8 { return [0x38,oo]; } // JR C,o
/ "JR"i _ "NC"i _ "," _ oo:Offset8 { return [0x30,oo]; } // JR NC,o
/ "JR"i _ "NZ"i _ "," _ oo:Offset8 { return [0x20,oo]; } // JR NZ,o
/ "JR"i _ "Z"i _ "," _ oo:Offset8 { return [0x28,oo]; } // JR Z,o
/ "JR"i _ oo:Offset8 { return [0x18,oo]; } // JR o
/ "LD"i _ "(BC)"i _ "," _ "A"i { return [0x02]; } // LD (BC),A
/ "LD"i _ "(DE)"i _ "," _ "A"i { return [0x12]; } // LD (DE),A
/ "LD"i _ "(HL)"i _ "," _ r:TableR { return [0x70+r]; } // LD (HL),r
/ "LD"i _ "(HL)"i _ "," _ nn:Int8 { return [0x36,nn]; } // LD (HL),n
/ "LD"i _ "(" _ "IX"i _ oo:Offset8 _ ")" _ "," _ r:TableR { return [0xDD,0x70+r,oo]; } // LD (IX+o),r
/ "LD"i _ "(" _ "IX"i _ oo:Offset8 _ ")" _ "," _ nn:Int8 { return [0xDD,0x36,oo,nn]; } // LD (IX+o),n
/ "LD"i _ "(" _ "IY"i _ oo:Offset8 _ ")" _ "," _ r:TableR { return [0xFD,0x70+r,oo]; } // LD (IY+o),r
/ "LD"i _ "(" _ "IY"i _ oo:Offset8 _ ")" _ "," _ nn:Int8 { return [0xFD,0x36,oo,nn]; } // LD (IY+o),n
/ "LD"i _ "(" _ nn:Int16 _ ")" _ "," _ "A"i { return [0x32,nn[0],nn[1]]; } // LD (nn),A
/ "LD"i _ "(" _ nn:Int16 _ ")" _ "," _ "BC"i { return [0xED,0x43,nn[0],nn[1]]; } // LD (nn),BC
/ "LD"i _ "(" _ nn:Int16 _ ")" _ "," _ "DE"i { return [0xED,0x53,nn[0],nn[1]]; } // LD (nn),DE
/ "LD"i _ "(" _ nn:Int16 _ ")" _ "," _ "HL"i { return [0x22,nn[0],nn[1]]; } // LD (nn),HL
/ "LD"i _ "(" _ nn:Int16 _ ")" _ "," _ "IX"i { return [0xDD,0x22,nn[0],nn[1]]; } // LD (nn),IX
/ "LD"i _ "(" _ nn:Int16 _ ")" _ "," _ "IY"i { return [0xFD,0x22,nn[0],nn[1]]; } // LD (nn),IY
/ "LD"i _ "(" _ nn:Int16 _ ")" _ "," _ "SP"i { return [0xED,0x73,nn[0],nn[1]]; } // LD (nn),SP
/ "LD"i _ "IXH"i _ "," _ p:TableIXp { return [0xDD,0x60+p]; } // LD IXh,p
/ "LD"i _ "IXH"i _ "," _ nn:Int8 { return [0xDD,0x26,nn]; } // LD IXh,n
/ "LD"i _ "IXL"i _ "," _ p:TableIXp { return [0xDD,0x68+p]; } // LD IXl,p
/ "LD"i _ "IXL"i _ "," _ nn:Int8 { return [0xDD,0x2E,nn]; } // LD IXl,n
/ "LD"i _ "IYH"i _ "," _ q:TableIYq { return [0xFD,0x60+q]; } // LD IYh,q
/ "LD"i _ "IYH"i _ "," _ nn:Int8 { return [0xFD,0x26,nn]; } // LD IYh,n
/ "LD"i _ "IYL"i _ "," _ q:TableIYq { return [0xFD,0x68+q]; } // LD IYl,q
/ "LD"i _ "IYL"i _ "," _ nn:Int8 { return [0xFD,0x2E,nn]; } // LD IYl,n
/ "LD"i _ "BC"i _ "," _ "(" _ nn:Int16 _ ")" { return [0xED,0x4B,nn[0],nn[1]]; } // LD BC,(nn)
/ "LD"i _ "DE"i _ "," _ "(" _ nn:Int16 _ ")" { return [0xED,0x5B,nn[0],nn[1]]; } // LD DE,(nn)
/ "LD"i _ "HL"i _ "," _ "(" _ nn:Int16 _ ")" { return [0x2A,nn[0],nn[1]]; } // LD HL,(nn)
/ "LD"i _ "IX"i _ "," _ "(" _ nn:Int16 _ ")" { return [0xDD,0x2A,nn[0],nn[1]]; } // LD IX,(nn)
/ "LD"i _ "IY"i _ "," _ "(" _ nn:Int16 _ ")" { return [0xFD,0x2A,nn[0],nn[1]]; } // LD IY,(nn)
/ "LD"i _ "IX"i _ "," _ nn:Int16 { return [0xDD,0x21,nn[0],nn[1]]; } // LD IX,nn
/ "LD"i _ "DE"i _ "," _ nn:Int16 { return [0x11,nn[0],nn[1]]; } // LD DE,nn
/ "LD"i _ "BC"i _ "," _ nn:Int16 { return [0x01,nn[0],nn[1]]; } // LD BC,nn
/ "LD"i _ "HL"i _ "," _ nn:Int16 { return [0x21,nn[0],nn[1]]; } // LD HL,nn
/ "LD"i _ "IY"i _ "," _ nn:Int16 { return [0xFD,0x21,nn[0],nn[1]]; } // LD IY,nn
/ "LD"i _ "A"i _ "," _ "(BC)"i { return [0x0A]; } // LD A,(BC)
/ "LD"i _ "A"i _ "," _ "(DE)"i { return [0x1A]; } // LD A,(DE)
/ "LD"i _ "A"i _ "," _ "(HL)"i { return [0x7E]; } // LD A,(HL)
/ "LD"i _ "A"i _ "," _ "(" _ "IX"i _ oo:Offset8 _ ")" { return [0xDD,0x7E,oo]; } // LD A,(IX+o)
/ "LD"i _ "A"i _ "," _ "(" _ "IY"i _ oo:Offset8 _ ")" { return [0xFD,0x7E,oo]; } // LD A,(IY+o)
/ "LD"i _ "A"i _ "," _ "(" _ nn:Int16 _ ")" { return [0x3A,nn[0],nn[1]]; } // LD A,(nn)
/ "LD"i _ "A"i _ "," _ r:TableR { return [0x78+r]; } // LD A,r
/ "LD"i _ "A"i _ "," _ p:TableIXp { return [0xDD,0x78+p]; } // LD A,IXp
/ "LD"i _ "A"i _ "," _ q:TableIYq { return [0xFD,0x78+q]; } // LD A,IYq
/ "LD"i _ "A"i _ "," _ "I"i { return [0xED,0x57]; } // LD A,I
/ "LD"i _ "A"i _ "," _ "R"i { return [0xED,0x5F]; } // LD A,R
/ "LD"i _ "A"i _ "," _ nn:Int8 { return [0x3E,nn]; } // LD A,n
/ "LD"i _ "B"i _ "," _ "(HL)"i { return [0x46]; } // LD B,(HL)
/ "LD"i _ "B"i _ "," _ "(" _ "IX"i _ oo:Offset8 _ ")" { return [0xDD,0x46,oo]; } // LD B,(IX+o)
/ "LD"i _ "B"i _ "," _ "(" _ "IY"i _ oo:Offset8 _ ")" { return [0xFD,0x46,oo]; } // LD B,(IY+o)
/ "LD"i _ "B"i _ "," _ r:TableR { return [0x40+r]; } // LD B,r
/ "LD"i _ "B"i _ "," _ p:TableIXp { return [0xDD,0x40+p]; } // LD B,IXp
/ "LD"i _ "B"i _ "," _ q:TableIYq { return [0xFD,0x40+q]; } // LD B,IYq
/ "LD"i _ "B"i _ "," _ nn:Int8 { return [0x06,nn]; } // LD B,n
/ "LD"i _ "C"i _ "," _ "(HL)"i { return [0x4E]; } // LD C,(HL)
/ "LD"i _ "C"i _ "," _ "(" _ "IX"i _ oo:Offset8 _ ")" { return [0xDD,0x4E,oo]; } // LD C,(IX+o)
/ "LD"i _ "C"i _ "," _ "(" _ "IY"i _ oo:Offset8 _ ")" { return [0xFD,0x4E,oo]; } // LD C,(IY+o)
/ "LD"i _ "C"i _ "," _ r:TableR { return [0x48+r]; } // LD C,r
/ "LD"i _ "C"i _ "," _ p:TableIXp { return [0xDD,0x48+p]; } // LD C,IXp
/ "LD"i _ "C"i _ "," _ q:TableIYq { return [0xFD,0x48+q]; } // LD C,IYq
/ "LD"i _ "C"i _ "," _ nn:Int8 { return [0x0E,nn]; } // LD C,n
/ "LD"i _ "D"i _ "," _ "(HL)"i { return [0x56]; } // LD D,(HL)
/ "LD"i _ "D"i _ "," _ "(" _ "IX"i _ oo:Offset8 _ ")" { return [0xDD,0x56,oo]; } // LD D,(IX+o)
/ "LD"i _ "D"i _ "," _ "(" _ "IY"i _ oo:Offset8 _ ")" { return [0xFD,0x56,oo]; } // LD D,(IY+o)
/ "LD"i _ "D"i _ "," _ r:TableR { return [0x50+r]; } // LD D,r
/ "LD"i _ "D"i _ "," _ p:TableIXp { return [0xDD,0x50+p]; } // LD D,IXp
/ "LD"i _ "D"i _ "," _ q:TableIYq { return [0xFD,0x50+q]; } // LD D,IYq
/ "LD"i _ "D"i _ "," _ nn:Int8 { return [0x16,nn]; } // LD D,n
/ "LD"i _ "E"i _ "," _ "(HL)"i { return [0x5E]; } // LD E,(HL)
/ "LD"i _ "E"i _ "," _ "(" _ "IX"i _ oo:Offset8 _ ")" { return [0xDD,0x5E,oo]; } // LD E,(IX+o)
/ "LD"i _ "E"i _ "," _ "(" _ "IY"i _ oo:Offset8 _ ")" { return [0xFD,0x5E,oo]; } // LD E,(IY+o)
/ "LD"i _ "E"i _ "," _ r:TableR { return [0x58+r]; } // LD E,r
/ "LD"i _ "E"i _ "," _ p:TableIXp { return [0xDD,0x58+p]; } // LD E,IXp
/ "LD"i _ "E"i _ "," _ q:TableIYq { return [0xFD,0x58+q]; } // LD E,IYq
/ "LD"i _ "E"i _ "," _ nn:Int8 { return [0x1E,nn]; } // LD E,n
/ "LD"i _ "H"i _ "," _ "(HL)"i { return [0x66]; } // LD H,(HL)
/ "LD"i _ "H"i _ "," _ "(" _ "IX"i _ oo:Offset8 _ ")" { return [0xDD,0x66,oo]; } // LD H,(IX+o)
/ "LD"i _ "H"i _ "," _ "(" _ "IY"i _ oo:Offset8 _ ")" { return [0xFD,0x66,oo]; } // LD H,(IY+o)
/ "LD"i _ "H"i _ "," _ r:TableR { return [0x60+r]; } // LD H,r
/ "LD"i _ "H"i _ "," _ nn:Int8 { return [0x26,nn]; } // LD H,n
/ "LD"i _ "I"i _ "," _ "A"i { return [0xED,0x47]; } // LD I,A
/ "LD"i _ "L"i _ "," _ "(HL)"i { return [0x6E]; } // LD L,(HL)
/ "LD"i _ "L"i _ "," _ "(" _ "IX"i _ oo:Offset8 _ ")" { return [0xDD,0x6E,oo]; } // LD L,(IX+o)
/ "LD"i _ "L"i _ "," _ "(" _ "IY"i _ oo:Offset8 _ ")" { return [0xFD,0x6E,oo]; } // LD L,(IY+o)
/ "LD"i _ "L"i _ "," _ r:TableR { return [0x68+r]; } // LD L,r
/ "LD"i _ "L"i _ "," _ nn:Int8 { return [0x2E,nn]; } // LD L,n
/ "LD"i _ "R"i _ "," _ "A"i { return [0xED,0x4F]; } // LD R,A
/ "LD"i _ "SP"i _ "," _ "(" _ nn:Int16 _ ")" { return [0xED,0x7B,nn[0],nn[1]]; } // LD SP,(nn)
/ "LD"i _ "SP"i _ "," _ "HL"i { return [0xF9]; } // LD SP,HL
/ "LD"i _ "SP"i _ "," _ "IX"i { return [0xDD,0xF9]; } // LD SP,IX
/ "LD"i _ "SP"i _ "," _ "IY"i { return [0xFD,0xF9]; } // LD SP,IY
/ "LD"i _ "SP"i _ "," _ nn:Int16 { return [0x31,nn[0],nn[1]]; } // LD SP,nn
/ "LDDR"i { return [0xED,0xB8]; } // LDDR
/ "LDD"i { return [0xED,0xA8]; } // LDD
/ "LDIR"i { return [0xED,0xB0]; } // LDIR
/ "LDI"i { return [0xED,0xA0]; } // LDI
/ "MULUB"i _ "A"i _ "," _ r:TableR { return [0xED,0xC1+0x8*r]; } // MULUB A,r
/ "MULUW"i _ "HL"i _ "," _ "BC"i { return [0xED,0xC3]; } // MULUW HL,BC
/ "MULUW"i _ "HL"i _ "," _ "SP"i { return [0xED,0xF3]; } // MULUW HL,SP
/ "NEG"i { return [0xED,0x44]; } // NEG
/ "NOP"i { return [0x00]; } // NOP
/ "OR"i _ "(HL)"i { return [0xB6]; } // OR (HL)
/ "OR"i _ "(" _ "IX"i _ oo:Offset8 _ ")" { return [0xDD,0xB6,oo]; } // OR (IX+o)
/ "OR"i _ "(" _ "IY"i _ oo:Offset8 _ ")" { return [0xFD,0xB6,oo]; } // OR (IY+o)
/ "OR"i _ r:TableR { return [0xB0+r]; } // OR r
/ "OR"i _ p:TableIXp { return [0xDD,0xB0+p]; } // OR IXp
/ "OR"i _ q:TableIYq { return [0xFD,0xB0+q]; } // OR IYq
/ "OR"i _ nn:Int8 { return [0xF6,nn]; } // OR n
/ "OTDR"i { return [0xED,0xBB]; } // OTDR
/ "OTIR"i { return [0xED,0xB3]; } // OTIR
/ "OUTD"i { return [0xED,0xAB]; } // OUTD
/ "OUTI"i { return [0xED,0xA3]; } // OUTI
/ "OUT"i _ "(C)"i _ "," _ "A"i { return [0xED,0x79]; } // OUT (C),A
/ "OUT"i _ "(C)"i _ "," _ "B"i { return [0xED,0x41]; } // OUT (C),B
/ "OUT"i _ "(C)"i _ "," _ "C"i { return [0xED,0x49]; } // OUT (C),C
/ "OUT"i _ "(C)"i _ "," _ "D"i { return [0xED,0x51]; } // OUT (C),D
/ "OUT"i _ "(C)"i _ "," _ "E"i { return [0xED,0x59]; } // OUT (C),E
/ "OUT"i _ "(C)"i _ "," _ "H"i { return [0xED,0x61]; } // OUT (C),H
/ "OUT"i _ "(C)"i _ "," _ "L"i { return [0xED,0x69]; } // OUT (C),L
/ "OUT"i _ "(" _ nn:Int8 _ ")" _ "," _ "A"i { return [0xD3,nn]; } // OUT (n),A
/ "POP"i _ "AF"i { return [0xF1]; } // POP AF
/ "POP"i _ "BC"i { return [0xC1]; } // POP BC
/ "POP"i _ "DE"i { return [0xD1]; } // POP DE
/ "POP"i _ "HL"i { return [0xE1]; } // POP HL
/ "POP"i _ "IX"i { return [0xDD,0xE1]; } // POP IX
/ "POP"i _ "IY"i { return [0xFD,0xE1]; } // POP IY
/ "PUSH"i _ "AF"i { return [0xF5]; } // PUSH AF
/ "PUSH"i _ "BC"i { return [0xC5]; } // PUSH BC
/ "PUSH"i _ "DE"i { return [0xD5]; } // PUSH DE
/ "PUSH"i _ "HL"i { return [0xE5]; } // PUSH HL
/ "PUSH"i _ "IX"i { return [0xDD,0xE5]; } // PUSH IX
/ "PUSH"i _ "IY"i { return [0xFD,0xE5]; } // PUSH IY
/ "RES"i _ b:Int3 _ "," _ "(HL)"i { return [0xCB,0x86+0x8*b]; } // RES b,(HL)
/ "RES"i _ b:Int3 _ "," _ "(" _ "IX"i _ oo:Offset8 _ ")" { return [0xDD,0xCB,oo,0x86+0x8*b]; } // RES b,(IX+o)
/ "RES"i _ b:Int3 _ "," _ "(" _ "IY"i _ oo:Offset8 _ ")" { return [0xFD,0xCB,oo,0x86+0x8*b]; } // RES b,(IY+o)
/ "RES"i _ b:Int3 _ "," _ r:TableR { return [0xCB,0x80+0x8*b+r]; } // RES b,r
/ "RET"i _ "C"i { return [0xD8]; } // RET C
/ "RET"i _ "M"i { return [0xF8]; } // RET M
/ "RET"i _ "NC"i { return [0xD0]; } // RET NC
/ "RET"i _ "NZ"i { return [0xC0]; } // RET NZ
/ "RET"i _ "P"i { return [0xF0]; } // RET P
/ "RET"i _ "PE"i { return [0xE8]; } // RET PE
/ "RET"i _ "PO"i { return [0xE0]; } // RET PO
/ "RET"i _ "Z"i { return [0xC8]; } // RET Z
/ "RET"i { return [0xC9]; } // RET
/ "RETI"i { return [0xED,0x4D]; } // RETI
/ "RETN"i { return [0xED,0x45]; } // RETN
/ "RLCA"i { return [0x07]; } // RLCA
/ "RLA"i { return [0x17]; } // RLA
/ "RLD"i { return [0xED,0x6F]; } // RLD
/ "RLC"i _ "(HL)"i { return [0xCB,0x06]; } // RLC (HL)
/ "RLC"i _ "(" _ "IX"i _ oo:Offset8 _ ")" { return [0xDD,0xCB,oo,0x06]; } // RLC (IX+o)
/ "RLC"i _ "(" _ "IY"i _ oo:Offset8 _ ")" { return [0xFD,0xCB,oo,0x06]; } // RLC (IY+o)
/ "RLC"i _ r:TableR { return [0xCB,0x00+r]; } // RLC r
/ "RL"i _ "(HL)"i { return [0xCB,0x16]; } // RL (HL)
/ "RL"i _ "(" _ "IX"i _ oo:Offset8 _ ")" { return [0xDD,0xCB,oo,0x16]; } // RL (IX+o)
/ "RL"i _ "(" _ "IY"i _ oo:Offset8 _ ")" { return [0xFD,0xCB,oo,0x16]; } // RL (IY+o)
/ "RL"i _ r:TableR { return [0xCB,0x10+r]; } // RL r
/ "RRCA"i { return [0x0F]; } // RRCA
/ "RRA"i { return [0x1F]; } // RRA
/ "RRC"i _ "(HL)"i { return [0xCB,0x0E]; } // RRC (HL)
/ "RRC"i _ "(" _ "IX"i _ oo:Offset8 _ ")" { return [0xDD,0xCB,oo,0x0E]; } // RRC (IX+o)
/ "RRC"i _ "(" _ "IY"i _ oo:Offset8 _ ")" { return [0xFD,0xCB,oo,0x0E]; } // RRC (IY+o)
/ "RRC"i _ r:TableR { return [0xCB,0x08+r]; } // RRC r
/ "RRD"i { return [0xED,0x67]; } // RRD
/ "RR"i _ "(HL)"i { return [0xCB,0x1E]; } // RR (HL)
/ "RR"i _ "(" _ "IX"i _ oo:Offset8 _ ")" { return [0xDD,0xCB,oo,0x1E]; } // RR (IX+o)
/ "RR"i _ "(" _ "IY"i _ oo:Offset8 _ ")" { return [0xFD,0xCB,oo,0x1E]; } // RR (IY+o)
/ "RR"i _ r:TableR { return [0xCB,0x18+r]; } // RR r
/ "RST"i _ "0"i { return [0xC7]; } // RST 0
/ "RST"i _ "8H"i { return [0xCF]; } // RST 8H
/ "RST"i _ "10H"i { return [0xD7]; } // RST 10H
/ "RST"i _ "18H"i { return [0xDF]; } // RST 18H
/ "RST"i _ "20H"i { return [0xE7]; } // RST 20H
/ "RST"i _ "28H"i { return [0xEF]; } // RST 28H
/ "RST"i _ "30H"i { return [0xF7]; } // RST 30H
/ "RST"i _ "38H"i { return [0xFF]; } // RST 38H
/ "SBC"i _ "A"i _ "," _ "(HL)"i { return [0x9E]; } // SBC A,(HL)
/ "SBC"i _ "A"i _ "," _ "(" _ "IX"i _ oo:Offset8 _ ")" { return [0xDD,0x9E,oo]; } // SBC A,(IX+o)
/ "SBC"i _ "A"i _ "," _ "(" _ "IY"i _ oo:Offset8 _ ")" { return [0xFD,0x9E,oo]; } // SBC A,(IY+o)
/ "SBC"i _ "A"i _ "," _ r:TableR { return [0x98+r]; } // SBC A,r
/ "SBC"i _ "A"i _ "," _ p:TableIXp { return [0xDD,0x98+p]; } // SBC A,IXp
/ "SBC"i _ "A"i _ "," _ q:TableIYq { return [0xFD,0x98+q]; } // SBC A,IYq
/ "SBC"i _ "A"i _ "," _ nn:Int8 { return [0xDE,nn]; } // SBC A,n
/ "SBC"i _ "HL"i _ "," _ "BC"i { return [0xED,0x42]; } // SBC HL,BC
/ "SBC"i _ "HL"i _ "," _ "DE"i { return [0xED,0x52]; } // SBC HL,DE
/ "SBC"i _ "HL"i _ "," _ "HL"i { return [0xED,0x62]; } // SBC HL,HL
/ "SBC"i _ "HL"i _ "," _ "SP"i { return [0xED,0x72]; } // SBC HL,SP
/ "SCF"i { return [0x37]; } // SCF
/ "SET"i _ b:Int3 _ "," _ "(HL)"i { return [0xCB,0xC6+0x8*b]; } // SET b,(HL)
/ "SET"i _ b:Int3 _ "," _ "(" _ "IX"i _ oo:Offset8 _ ")" { return [0xDD,0xCB,oo,0xC6+0x8*b]; } // SET b,(IX+o)
/ "SET"i _ b:Int3 _ "," _ "(" _ "IY"i _ oo:Offset8 _ ")" { return [0xFD,0xCB,oo,0xC6+0x8*b]; } // SET b,(IY+o)
/ "SET"i _ b:Int3 _ "," _ r:TableR { return [0xCB,0xC0+0x8*b+r]; } // SET b,r
/ "SLA"i _ "(HL)"i { return [0xCB,0x26]; } // SLA (HL)
/ "SLA"i _ "(" _ "IX"i _ oo:Offset8 _ ")" { return [0xDD,0xCB,oo,0x26]; } // SLA (IX+o)
/ "SLA"i _ "(" _ "IY"i _ oo:Offset8 _ ")" { return [0xFD,0xCB,oo,0x26]; } // SLA (IY+o)
/ "SLA"i _ r:TableR { return [0xCB,0x20+r]; } // SLA r
/ "SRA"i _ "(HL)"i { return [0xCB,0x2E]; } // SRA (HL)
/ "SRA"i _ "(" _ "IX"i _ oo:Offset8 _ ")" { return [0xDD,0xCB,oo,0x2E]; } // SRA (IX+o)
/ "SRA"i _ "(" _ "IY"i _ oo:Offset8 _ ")" { return [0xFD,0xCB,oo,0x2E]; } // SRA (IY+o)
/ "SRA"i _ r:TableR { return [0xCB,0x28+r]; } // SRA r
/ "SRL"i _ "(HL)"i { return [0xCB,0x3E]; } // SRL (HL)
/ "SRL"i _ "(" _ "IX"i _ oo:Offset8 _ ")" { return [0xDD,0xCB,oo,0x3E]; } // SRL (IX+o)
/ "SRL"i _ "(" _ "IY"i _ oo:Offset8 _ ")" { return [0xFD,0xCB,oo,0x3E]; } // SRL (IY+o)
/ "SRL"i _ r:TableR { return [0xCB,0x38+r]; } // SRL r
/ "SUB"i _ "(HL)"i { return [0x96]; } // SUB (HL)
/ "SUB"i _ "(" _ "IX"i _ oo:Offset8 _ ")" { return [0xDD,0x96,oo]; } // SUB (IX+o)
/ "SUB"i _ "(" _ "IY"i _ oo:Offset8 _ ")" { return [0xFD,0x96,oo]; } // SUB (IY+o)
/ "SUB"i _ r:TableR { return [0x90+r]; } // SUB r
/ "SUB"i _ p:TableIXp { return [0xDD,0x90+p]; } // SUB IXp
/ "SUB"i _ q:TableIYq { return [0xFD,0x90+q]; } // SUB IYq
/ "SUB"i _ nn:Int8 { return [0xD6,nn]; } // SUB n
/ "XOR"i _ "(HL)"i { return [0xAE]; } // XOR (HL)
/ "XOR"i _ "(" _ "IX"i _ oo:Offset8 _ ")" { return [0xDD,0xAE,oo]; } // XOR (IX+o)
/ "XOR"i _ "(" _ "IY"i _ oo:Offset8 _ ")" { return [0xFD,0xAE,oo]; } // XOR (IY+o)
/ "XOR"i _ r:TableR { return [0xA8+r]; } // XOR r
/ "XOR"i _ p:TableIXp { return [0xDD,0xA8+p]; } // XOR IXp
/ "XOR"i _ q:TableIYq { return [0xFD,0xA8+q]; } // XOR IYq
/ "XOR"i _ nn:Int8 { return [0xEE,nn]; } // XOR n