1 using System;
2 using System.Collections;
3
4 namespace cmsx.machine
5 {
6 public const byte TRAP = 0x00u;
7 public const byte FCMP = 0x01u;
8 public const byte FUN = 0x02u;
9 public const byte FEQL = 0x03u;
10 public const byte FADD = 0x04u;
11 public const byte FIX = 0x05u;
12 public const byte FSUB = 0x06u;
13 public const byte FIXU = 0x07u;
14
15 public const byte FLOT = 0x08u;
16 public const byte FLOTI = 0x09u;
17 public const byte FLOTU = 0x0Au;
18 public const byte FLOTUI = 0x0Bu;
19 public const byte SFLOT = 0x0Cu;
20 public const byte SFLOTI = 0x0Du;
21 public const byte SFLOTU = 0x0Eu;
22 public const byte SFLOTUI = 0x0Fu;
23
24 public const byte FMUL = 0x10u;
25 public const byte FCMPE = 0x11u;
26 public const byte FUNE = 0x12u;
27 public const byte FEQLE = 0x13u;
28 public const byte FDIV = 0x14u;
29 public const byte FSQRT = 0x15u;
30 public const byte FREM = 0x16u;
31 public const byte FINT = 0x17u;
32
33 public const byte MUL = 0x18u;
34 public const byte MULI = 0x19u;
35 public const byte MULU = 0x1Au;
36 public const byte MULUI = 0x1Bu;
37 public const byte DIV = 0x1Cu;
38 public const byte DIVI = 0x1Du;
39 public const byte DIVU = 0x1Eu;
40 public const byte DIVUI = 0x1Fu;
41
42 public const byte ADD = 0x20u;
43 public const byte ADDI = 0x21u;
44 public const byte ADDU = 0x22u;
45 public const byte ADDUI = 0x23u;
46 public const byte SUB = 0x24u;
47 public const byte SUBI = 0x25u;
48 public const byte SUBU = 0x26u;
49 public const byte SUBUI = 0x27u;
50
51 public const byte I2ADDU = 0x28u;
52 public const byte I2ADDUI = 0x29u;
53 public const byte I4ADDU = 0x2Au;
54 public const byte I4ADDUI = 0x2Bu;
55 public const byte I8ADDU = 0x2Cu;
56 public const byte I8ADDUI = 0x2Du;
57 public const byte I16ADDU = 0x2Eu;
58 public const byte I16ADDUI = 0x2Fu;
59
60 public const byte CMP = 0x30u;
61 public const byte CMPI = 0x31u;
62 public const byte CMPU = 0x32u;
63 public const byte CMPUI = 0x33u;
64 public const byte NEG = 0x34u;
65 public const byte NEGI = 0x35u;
66 public const byte NEGU = 0x36u;
67 public const byte NEGUI = 0x37u;
68
69 public const byte SL = 0x38u;
70 public const byte SLI = 0x39u;
71 public const byte SLU = 0x3Au;
72 public const byte SLUI = 0x3Bu;
73 public const byte SR = 0x03Cu;
74 public const byte SRI = 0x3Du;
75 public const byte SRU = 0x3Eu;
76 public const byte SRUI = 0x3Fu;
77
78 public const byte BN = 0x40u;
79 public const byte BNB = 0x41u;
80 public const byte BZ = 0x42u;
81 public const byte BZB = 0x43u;
82 public const byte BP = 0x44u;
83 public const byte BPB = 0x45u;
84 public const byte BOD = 0x46u;
85 public const byte BODB = 0x47u;
86
87 public const byte BNN = 0x48u;
88 public const byte BNNB = 0x49u;
89 public const byte BNZ = 0x4Au;
90 public const byte BNZB = 0x4Bu;
91 public const byte BNP = 0x4Cu;
92 public const byte BNPB = 0x4Du;
93 public const byte BEV = 0x4Eu;
94 public const byte BEVB = 0x4Fu;
95
96 public const byte PBN = 0x50u;
97 public const byte PBNB = 0x51u;
98 public const byte PBZ = 0x52u;
99 public const byte PBZB = 0x53u;
100 public const byte PBP = 0x54u;
101 public const byte PBPB = 0x55u;
102 public const byte PBOD = 0x56u;
103 public const byte PBODB = 0x57u;
104
105 public const byte PBNN = 0x58u;
106 public const byte PBNNB = 0x59u;
107 public const byte PBNZ = 0x5Au;
108 public const byte PBNZB = 0x5Bu;
109 public const byte PBNP = 0x5Cu;
110 public const byte PBNPB = 0x5Du;
111 public const byte PBEV = 0x5Eu;
112 public const byte PBEVB = 0x5Fu;
113
114 public const byte CSN = 0x60u;
115 public const byte CSNI = 0x61u;
116 public const byte CSZ = 0x62u;
117 public const byte CSZI = 0x63u;
118 public const byte CSP = 0x64u;
119 public const byte CSPI = 0x65u;
120 public const byte CSOD = 0x66u;
121 public const byte CSODI = 0x67u;
122
123 public const byte CSNN = 0x68u;
124 public const byte CSNNI = 0x69u;
125 public const byte CSNZ = 0x6Au;
126 public const byte CSNZI = 0x6Bu;
127 public const byte CSNP = 0x6Cu;
128 public const byte CSNPI = 0x6Du;
129 public const byte CSEV = 0x6Eu;
130 public const byte CSEVI = 0x6Fu;
131
132 public const byte ZSN = 0x70u;
133 public const byte ZSNI = 0x71u;
134 public const byte ZSZ = 0x72u;
135 public const byte ZSZI = 0x73u;
136 public const byte ZSP = 0x74u;
137 public const byte ZSPI = 0x75u;
138 public const byte ZSOD = 0x76u;
139 public const byte ZSODI = 0x77u;
140
141 public const byte ZSNN = 0x78u;
142 public const byte ZSNNI = 0x79u;
143 public const byte ZSNZ = 0x7Au;
144 public const byte ZSNZI = 0x7Bu;
145 public const byte ZSNP = 0x7Cu;
146 public const byte ZSNPI = 0x7Du;
147 public const byte ZSEV = 0x7Eu;
148 public const byte ZSEVI = 0x7Fu;
149
150 public const byte LDB = 0x80u;
151 public const byte LDBI = 0x81u;
152 public const byte LDBU = 0x82u;
153 public const byte LDBUI = 0x83u;
154 public const byte LDW = 0x84u;
155 public const byte LDWI = 0x85u;
156 public const byte LDWU = 0x86u;
157 public const byte LDWUI = 0x87u;
158
159 public const byte LDT = 0x88u;
160 public const byte LDTI = 0x89u;
161 public const byte LDTU = 0x8Au;
162 public const byte LDTUI = 0x8Bu;
163 public const byte LDO = 0x8Cu;
164 public const byte LDOI = 0x8Du;
165 public const byte LDOU = 0x8Eu;
166 public const byte LDOUI = 0x8Fu;
167
168 public const byte LDSF = 0x90u;
169 public const byte LDSFI = 0x91u;
170 public const byte LDHT = 0x92u;
171 public const byte LDHTI = 0x93u;
172 public const byte CSWAP = 0x94u;
173 public const byte CSWAPI = 0x95u;
174 public const byte LDUNC = 0x96u;
175 public const byte LDUNCI = 0x97u;
176
177 public const byte LDVTS = 0x98u;
178 public const byte LDVTSI = 0x99u;
179 public const byte PRELD = 0x9Au;
180 public const byte PRELDI = 0x9Bu;
181 public const byte PREGO = 0x9Cu;
182 public const byte PREGOI = 0x9Du;
183 public const byte GO = 0x9Eu;
184 public const byte GOI = 0x9Fu;
185
186 public const byte STB = 0xA0u;
187 public const byte STBI = 0xA1u;
188 public const byte STBU = 0xA2u;
189 public const byte STBUI = 0xA3u;
190 public const byte STW = 0xA4u;
191 public const byte STWI = 0xA5u;
192 public const byte STWU = 0xA6u;
193 public const byte STWUI = 0xA7u;
194
195 public const byte STT = 0xA8u;
196 public const byte STTI = 0xA9u;
197 public const byte STTU = 0xAAu;
198 public const byte STTUI = 0xABu;
199 public const byte STO = 0xACu;
200 public const byte STOI = 0xADu;
201 public const byte STOU = 0xAEu;
202 public const byte STOUI = 0xAFu;
203
204 public const byte STSF = 0xB0u;
205 public const byte STSFI = 0xB1u;
206 public const byte STHT = 0xB2u;
207 public const byte STHTI = 0xB3u;
208 public const byte STCO = 0xB4u;
209 public const byte STCOI = 0xB5u;
210 public const byte STUNC = 0xB6u;
211 public const byte STUNCI = 0xB7u;
212
213 public const byte SYNCD = 0xB8u;
214 public const byte SYNCDI = 0xB9u;
215 public const byte PREST = 0xBAu;
216 public const byte PRESTI = 0xBBu;
217 public const byte SYNCID = 0xBCu;
218 public const byte SYNCIDI = 0xBDu;
219 public const byte CALL = 0xBEu;
220 public const byte CALLI = 0xBFu;
221
222 public const byte OR = 0xC0u;
223 public const byte ORI = 0xC1u;
224 public const byte ORN = 0xC2u;
225 public const byte ORNI = 0xC3u;
226 public const byte NOR = 0xC4u;
227 public const byte NORI = 0xC5u;
228 public const byte XOR = 0xC6u;
229 public const byte XORI = 0xC7u;
230
231 public const byte AND = 0xC8u;
232 public const byte ANDI = 0xC9u;
233 public const byte ANDN = 0xCAu;
234 public const byte ANDNI = 0xCBu;
235 public const byte NAND = 0xCCu;
236 public const byte NANDI = 0xCDu;
237 public const byte NXOR = 0xCEu;
238 public const byte NXORI = 0xCFu;
239
240 public const byte BDIF = 0xD0;
241 public const byte BDIFI = 0xD1u;
242 public const byte WDIF = 0xD2u;
243 public const byte WDIFI = 0xD3u;
244 public const byte TDIF = 0xD4u;
245 public const byte TDIFI = 0xD5u;
246 public const byte ODIF = 0xD6u;
247 public const byte ODIFI = 0xD7u;
248
249 public const byte MUX = 0xD8u;
250 public const byte MUXI = 0xD9u;
251 public const byte SADD = 0xDAu;
252 public const byte SADDI = 0xDBu;
253 public const byte MOR = 0xDCu;
254 public const byte MORI = 0xDDu;
255 public const byte MXOR = 0xDEu;
256 public const byte MXORI = 0xDFu;
257
258 public const byte SETH = 0xE0u;
259 public const byte SETMH = 0xE1u;
260 public const byte SETML = 0xE2u;
261 public const byte SETL = 0xE3u;
262 public const byte INCH = 0xE4u;
263 public const byte INCMH = 0xE5u;
264 public const byte INCML = 0xE6u;
265 public const byte INCL = 0xE7u;
266
267 public const byte ORH = 0xE8u;
268 public const byte ORMH = 0xE9u;
269 public const byte ORML = 0xEAu;
270 public const byte ORL = 0xEBu;
271 public const byte ANDNH = 0xECu;
272 public const byte ANDNMH = 0xEDu;
273 public const byte ANDNML = 0xEEu;
274 public const byte ANDNL = 0xEFu;
275
276 public const byte JMP = 0xF0u;
277 public const byte JMPB = 0xF1u;
278 public const byte PUSHJ = 0xF2u;
279 public const byte PUSHJB = 0xF3u;
280 public const byte GETA = 0xF4u;
281 public const byte GETAB = 0xF5u;
282 public const byte PUT = 0xF6u;
283 public const byte PUTI = 0xF7u;
284
285 public const byte RET = 0xF8u;
286 public const byte RESUME = 0xF9u;
287 public const byte SAVE = 0xFAu;
288 public const byte UNSAVE = 0xFBu;
289 public const byte SYNC = 0xFCu;
290 public const byte SWYM = 0xFDu;
291 public const byte GET = 0xFEu;
292 public const byte TRIP = 0xFFu;
293
294 public class OpCodeMap
295 {
296 static OpCodeMap() : instance(new OpCodeMap())
297 {
298 }
299 public static nothrow OpCodeMap& Instance()
300 {
301 return *instance;
302 }
303 private OpCodeMap() : maxOpCodeNameLength(0)
304 {
305 codes["TRAP"] = TRAP;
306 codes["FCMP"] = FCMP;
307 codes["FUN"] = FUN;
308 codes["FEQL"] = FEQL;
309 codes["FADD"] = FADD;
310 codes["FIX"] = FIX;
311 codes["FSUB"] = FSUB;
312 codes["FIXU"] = FIXU;
313
314 codes["FLOT"] = FLOT;
315 codes["FLOTI"] = FLOTI;
316 codes["FLOTU"] = FLOTU;
317 codes["FLOTUI"] = FLOTUI;
318 codes["SFLOT"] = SFLOT;
319 codes["SFLOTI"] = SFLOTI;
320 codes["SFLOTU"] = SFLOTU;
321 codes["SFLOTUI"] = SFLOTUI;
322
323 codes["FMUL"] = FMUL;
324 codes["FCMPE"] = FCMPE;
325 codes["FUNE"] = FUNE;
326 codes["FEQLE"] = FEQLE;
327 codes["FDIV"] = FDIV;
328 codes["FSQRT"] = FSQRT;
329 codes["FREM"] = FREM;
330 codes["FINT"] = FINT;
331
332 codes["MUL"] = MUL;
333 codes["MULI"] = MULI;
334 codes["MULU"] = MULU;
335 codes["MULUI"] = MULUI;
336 codes["DIV"] = DIV;
337 codes["DIVI"] = DIVI;
338 codes["DIVU"] = DIVU;
339 codes["DIVUI"] = DIVUI;
340
341 codes["ADD"] = ADD;
342 codes["ADDI"] = ADDI;
343 codes["ADDU"] = ADDU;
344 codes["ADDUI"] = ADDUI;
345 codes["SUB"] = SUB;
346 codes["SUBI"] = SUBI;
347 codes["SUBU"] = SUBU;
348 codes["SUBUI"] = SUBUI;
349
350 codes["2ADDU"] = I2ADDU;
351 codes["2ADDUI"] = I2ADDUI;
352 codes["4ADDU"] = I4ADDU;
353 codes["4ADDUI"] = I4ADDUI;
354 codes["8ADDU"] = I8ADDU;
355 codes["8ADDUI"] = I8ADDUI;
356 codes["16ADDU"] = I16ADDU;
357 codes["16ADDUI"] = I16ADDUI;
358
359 codes["CMP"] = CMP;
360 codes["CMPI"] = CMPI;
361 codes["CMPU"] = CMPU;
362 codes["CMPUI"] = CMPUI;
363 codes["NEG"] = NEG;
364 codes["NEGI"] = NEGI;
365 codes["NEGU"] = NEGU;
366 codes["NEGUI"] = NEGUI;
367
368 codes["SL"] = SL;
369 codes["SLI"] = SLI;
370 codes["SLU"] = SLU;
371 codes["SLUI"] = SLUI;
372 codes["SR"] = SR;
373 codes["SRI"] = SRI;
374 codes["SRU"] = SRU;
375 codes["SRUI"] = SRUI;
376
377 codes["BN"] = BN;
378 codes["BNB"] = BNB;
379 codes["BZ"] = BZ;
380 codes["BZB"] = BZB;
381 codes["BP"] = BP;
382 codes["BPB"] = BPB;
383 codes["BOD"] = BOD;
384 codes["BODB"] = BODB;
385
386 codes["BNN"] = BNN;
387 codes["BNNB"] = BNNB;
388 codes["BNZ"] = BNZ;
389 codes["BNZB"] = BNZB;
390 codes["BNP"] = BNP;
391 codes["BNPB"] = BNPB;
392 codes["BEV"] = BEV;
393 codes["BEVB"] = BEVB;
394
395 codes["PBN"] = PBN;
396 codes["PBNB"] = PBNB;
397 codes["PBZ"] = PBZ;
398 codes["PBZB"] = PBZB;
399 codes["PBP"] = PBP;
400 codes["PBPB"] = PBPB;
401 codes["PBOD"] = PBOD;
402 codes["PBODB"] = PBODB;
403
404 codes["PBNN"] = PBNN;
405 codes["PBNNB"] = PBNNB;
406 codes["PBNZ"] = PBNZ;
407 codes["PBNZB"] = PBNZB;
408 codes["PBNP"] = PBNP;
409 codes["PBNPB"] = PBNPB;
410 codes["PBEV"] = PBEV;
411 codes["PBEVB"] = PBEVB;
412
413 codes["CSN"] = CSN;
414 codes["CSNI"] = CSNI;
415 codes["CSZ"] = CSZ;
416 codes["CSZI"] = CSZI;
417 codes["CSP"] = CSP;
418 codes["CSPI"] = CSPI;
419 codes["CSOD"] = CSOD;
420 codes["CSODI"] = CSODI;
421
422 codes["CSNN"] = CSNN;
423 codes["CSNNI"] = CSNNI;
424 codes["CSNZ"] = CSNZ;
425 codes["CSNZI"] = CSNZI;
426 codes["CSNP"] = CSNP;
427 codes["CSNPI"] = CSNPI;
428 codes["CSEV"] = CSEV;
429 codes["CSEVI"] = CSEVI;
430
431 codes["ZSN"] = ZSN;
432 codes["ZSNI"] = ZSNI;
433 codes["ZSZ"] = ZSZ;
434 codes["ZSZI"] = ZSZI;
435 codes["ZSP"] = ZSP;
436 codes["ZSPI"] = ZSPI;
437 codes["ZSOD"] = ZSOD;
438 codes["ZSODI"] = ZSODI;
439
440 codes["ZSNN"] = ZSNN;
441 codes["ZSNNI"] = ZSNNI;
442 codes["ZSNZ"] = ZSNZ;
443 codes["ZSNZI"] = ZSNZI;
444 codes["ZSNP"] = ZSNP;
445 codes["ZSNPI"] = ZSNPI;
446 codes["ZSEV"] = ZSEV;
447 codes["ZSEVI"] = ZSEVI;
448
449 codes["LDB"] = LDB;
450 codes["LDBI"] = LDBI;
451 codes["LDBU"] = LDBU;
452 codes["LDBUI"] = LDBUI;
453 codes["LDW"] = LDW;
454 codes["LDWI"] = LDWI;
455 codes["LDWU"] = LDWU;
456 codes["LDWUI"] = LDWUI;
457
458 codes["LDT"] = LDT;
459 codes["LDTI"] = LDTI;
460 codes["LDTU"] = LDTU;
461 codes["LDTUI"] = LDTUI;
462 codes["LDO"] = LDO;
463 codes["LDOI"] = LDOI;
464 codes["LDOU"] = LDOU;
465 codes["LDOUI"] = LDOUI;
466
467 codes["LDSF"] = LDSF;
468 codes["LDSFI"] = LDSFI;
469 codes["LDHT"] = LDHT;
470 codes["LDHTI"] = LDHTI;
471 codes["CSWAP"] = CSWAP;
472 codes["CSWAPI"] = CSWAPI;
473 codes["LDUNC"] = LDUNC;
474 codes["LDUNCI"] = LDUNCI;
475
476 codes["LDVTS"] = LDVTS;
477 codes["LDVTSI"] = LDVTSI;
478 codes["PRELD"] = PRELD;
479 codes["PRELDI"] = PRELDI;
480 codes["PREGO"] = PREGO;
481 codes["PREGOI"] = PREGOI;
482 codes["GO"] = GO;
483 codes["GOI"] = GOI;
484
485 codes["STB"] = STB;
486 codes["STBI"] = STBI;
487 codes["STBU"] = STBU;
488 codes["STBUI"] = STBUI;
489 codes["STW"] = STW;
490 codes["STWI"] = STWI;
491 codes["STWU"] = STWU;
492 codes["STWUI"] = STWUI;
493
494 codes["STT"] = STT;
495 codes["STTI"] = STTI;
496 codes["STTU"] = STTU;
497 codes["STTUI"] = STTUI;
498 codes["STO"] = STO;
499 codes["STOI"] = STOI;
500 codes["STOU"] = STOU;
501 codes["STOUI"] = STOUI;
502
503 codes["STSF"] = STSF;
504 codes["STSFI"] = STSFI;
505 codes["STHT"] = STHT;
506 codes["STHTI"] = STHTI;
507 codes["STCO"] = STCO;
508 codes["STCOI"] = STCOI;
509 codes["STUNC"] = STUNC;
510 codes["STUNCI"] = STUNCI;
511
512 codes["SYNCD"] = SYNCD;
513 codes["SYNCDI"] = SYNCDI;
514 codes["PREST"] = PREST;
515 codes["PRESTI"] = PRESTI;
516 codes["SYNCID"] = SYNCID;
517 codes["SYNCIDI"] = SYNCIDI;
518 codes["CALL"] = CALL;
519 codes["CALLI"] = CALLI;
520
521 codes["OR"] = OR;
522 codes["ORI"] = ORI;
523 codes["ORN"] = ORN;
524 codes["ORNI"] = ORNI;
525 codes["NOR"] = NOR;
526 codes["NORI"] = NORI;
527 codes["XOR"] = XOR;
528 codes["XORI"] = XORI;
529
530 codes["AND"] = AND;
531 codes["ANDI"] = ANDI;
532 codes["ANDN"] = ANDN;
533 codes["ANDNI"] = ANDNI;
534 codes["NAND"] = NAND;
535 codes["NANDI"] = NANDI;
536 codes["NXOR"] = NXOR;
537 codes["NXORI"] = NXORI;
538
539 codes["BDIF"] = BDIF;
540 codes["BDIFI"] = BDIFI;
541 codes["WDIF"] = WDIF;
542 codes["WDIFI"] = WDIFI;
543 codes["TDIF"] = TDIF;
544 codes["TDIFI"] = TDIFI;
545 codes["ODIF"] = ODIF;
546 codes["ODIFI"] = ODIFI;
547
548 codes["MUX"] = MUX;
549 codes["MUXI"] = MUXI;
550 codes["SADD"] = SADD;
551 codes["SADDI"] = SADDI;
552 codes["MOR"] = MOR;
553 codes["MORI"] = MORI;
554 codes["MXOR"] = MXOR;
555 codes["MXORI"] = MXORI;
556
557 codes["SETH"] = SETH;
558 codes["SETMH"] = SETMH;
559 codes["SETML"] = SETML;
560 codes["SETL"] = SETL;
561 codes["INCH"] = INCH;
562 codes["INCMH"] = INCMH;
563 codes["INCML"] = INCML;
564 codes["INCL"] = INCL;
565
566 codes["ORH"] = ORH;
567 codes["ORMH"] = ORMH;
568 codes["ORML"] = ORML;
569 codes["ORL"] = ORL;
570 codes["ANDNH"] = ANDNH;
571 codes["ANDNMH"] = ANDNMH;
572 codes["ANDNML"] = ANDNML;
573 codes["ANDNL"] = ANDNL;
574
575 codes["JMP"] = JMP;
576 codes["JMPB"] = JMPB;
577 codes["PUSHJ"] = PUSHJ;
578 codes["PUSHJB"] = PUSHJB;
579 codes["GETA"] = GETA;
580 codes["GETAB"] = GETAB;
581 codes["PUT"] = PUT;
582 codes["PUTI"] = PUTI;
583
584 codes["RET"] = RET;
585 codes["RESUME"] = RESUME;
586 codes["SAVE"] = SAVE;
587 codes["UNSAVE"] = UNSAVE;
588 codes["SYNC"] = SYNC;
589 codes["SWYM"] = SWYM;
590 codes["GET"] = GET;
591 codes["TRIP"] = TRIP;
592
593 names[TRAP] = "TRAP";
594 names[FCMP] = "FCMP";
595 names[FUN] = "FUN";
596 names[FEQL] = "FEQL";
597 names[FADD] = "FADD";
598 names[FIX] = "FIX";
599 names[FSUB] = "FSUB";
600 names[FIXU] = "FIXU";
601
602 names[FLOT] = "FLOT";
603 names[FLOTI] = "FLOTI";
604 names[FLOTU] = "FLOTU";
605 names[FLOTUI] = "FLOTUI";
606 names[SFLOT] = "SFLOT";
607 names[SFLOTI] = "SFLOTI";
608 names[SFLOTU] = "SFLOTU";
609 names[SFLOTUI] = "SFLOTUI";
610
611 names[FMUL] = "FMUL";
612 names[FCMPE] = "FCMPE";
613 names[FUNE] = "FUNE";
614 names[FEQLE] = "FEQLE";
615 names[FDIV] = "FDIV";
616 names[FSQRT] = "FSQRT";
617 names[FREM] = "FREM";
618 names[FINT] = "FINT";
619
620 names[MUL] = "MUL";
621 names[MULI] = "MULI";
622 names[MULU] = "MULU";
623 names[MULUI] = "MULUI";
624 names[DIV] = "DIV";
625 names[DIVI] = "DIVI";
626 names[DIVU] = "DIVU";
627 names[DIVUI] = "DIVUI";
628
629 names[ADD] = "ADD";
630 names[ADDI] = "ADDI";
631 names[ADDU] = "ADDU";
632 names[ADDUI] = "ADDUI";
633 names[SUB] = "SUB";
634 names[SUBI] = "SUBI";
635 names[SUBU] = "SUBU";
636 names[SUBUI] = "SUBUI";
637
638 names[I2ADDU] = "2ADDU";
639 names[I2ADDUI] = "2ADDUI";
640 names[I4ADDU] = "4ADDU";
641 names[I4ADDUI] = "4ADDUI";
642 names[I8ADDU] = "8ADDU";
643 names[I8ADDUI] = "8ADDUI";
644 names[I16ADDU] = "16ADDU";
645 names[I16ADDUI] = "16ADDUI";
646
647 names[CMP] = "CMP";
648 names[CMPI] = "CMPI";
649 names[CMPU] = "CMPU";
650 names[CMPUI] = "CMPUI";
651 names[NEG] = "NEG";
652 names[NEGI] = "NEGI";
653 names[NEGU] = "NEGU";
654 names[NEGUI] = "NEGUI";
655
656 names[SL] = "SL";
657 names[SLI] = "SLI";
658 names[SLU] = "SLU";
659 names[SLUI] = "SLUI";
660 names[SR] = "SR";
661 names[SRI] = "SRI";
662 names[SRU] = "SRU";
663 names[SRUI] = "SRUI";
664
665 names[BN] = "BN";
666 names[BNB] = "BNB";
667 names[BZ] = "BZ";
668 names[BZB] = "BZB";
669 names[BP] = "BP";
670 names[BPB] = "BPB";
671 names[BOD] = "BOD";
672 names[BODB] = "BODB";
673
674 names[BNN] = "BNN";
675 names[BNNB] = "BNNB";
676 names[BNZ] = "BNZ";
677 names[BNZB] = "BNZB";
678 names[BNP] = "BNP";
679 names[BNPB] = "BNPB";
680 names[BEV] = "BEV";
681 names[BEVB] = "BEVB";
682
683 names[PBN] = "PBN";
684 names[PBNB] = "PBNB";
685 names[PBZ] = "PBZ";
686 names[PBZB] = "PBZB";
687 names[PBP] = "PBP";
688 names[PBPB] = "PBPB";
689 names[PBOD] = "PBOD";
690 names[PBODB] = "PBODB";
691
692 names[PBNN] = "PBNN";
693 names[PBNNB] = "PBNNB";
694 names[PBNZ] = "PBNZ";
695 names[PBNZB] = "PBNZB";
696 names[PBNP] = "PBNP";
697 names[PBNPB] = "PBNPB";
698 names[PBEV] = "PBEV";
699 names[PBEVB] = "PBEVB";
700
701 names[CSN] = "CSN";
702 names[CSNI] = "CSNI";
703 names[CSZ] = "CSZ";
704 names[CSZI] = "CSZI";
705 names[CSP] = "CSP";
706 names[CSPI] = "CSPI";
707 names[CSOD] = "CSOD";
708 names[CSODI] = "CSODI";
709
710 names[CSNN] = "CSNN";
711 names[CSNNI] = "CSNNI";
712 names[CSNZ] = "CSNZ";
713 names[CSNZI] = "CSNZI";
714 names[CSNP] = "CSNP";
715 names[CSNPI] = "CSNPI";
716 names[CSEV] = "CSEV";
717 names[CSEVI] = "CSEVI";
718
719 names[ZSN] = "ZSN";
720 names[ZSNI] = "ZSNI";
721 names[ZSZ] = "ZSZ";
722 names[ZSZI] = "ZSZI";
723 names[ZSP] = "ZSP";
724 names[ZSPI] = "ZSPI";
725 names[ZSOD] = "ZSOD";
726 names[ZSODI] = "ZSODI";
727
728 names[ZSNN] = "ZSNN";
729 names[ZSNNI] = "ZSNNI";
730 names[ZSNZ] = "ZSNZ";
731 names[ZSNZI] = "ZSNZI";
732 names[ZSNP] = "ZSNP";
733 names[ZSNPI] = "ZSNPI";
734 names[ZSEV] = "ZSEV";
735 names[ZSEVI] = "ZSEVI";
736
737 names[LDB] = "LDB";
738 names[LDBI] = "LDBI";
739 names[LDBU] = "LDBU";
740 names[LDBUI] = "LDBUI";
741 names[LDW] = "LDW";
742 names[LDWI] = "LDWI";
743 names[LDWU] = "LDWU";
744 names[LDWUI] = "LDWUI";
745
746 names[LDT] = "LDT";
747 names[LDTI] = "LDTI";
748 names[LDTU] = "LDTU";
749 names[LDTUI] = "LDTUI";
750 names[LDO] = "LDO";
751 names[LDOI] = "LDOI";
752 names[LDOU] = "LDOU";
753 names[LDOUI] = "LDOUI";
754
755 names[LDSF] = "LDSF";
756 names[LDSFI] = "LDSFI";
757 names[LDHT] = "LDHT";
758 names[LDHTI] = "LDHTI";
759 names[CSWAP] = "CSWAP";
760 names[CSWAPI] = "CSWAPI";
761 names[LDUNC] = "LDUNC";
762 names[LDUNCI] = "LDUNCI";
763
764 names[LDVTS] = "LDVTS";
765 names[LDVTSI] = "LDVTSI";
766 names[PRELD] = "PRELD";
767 names[PRELDI] = "PRELDI";
768 names[PREGO] = "PREGO";
769 names[PREGOI] = "PREGOI";
770 names[GO] = "GO";
771 names[GOI] = "GOI";
772
773 names[STB] = "STB";
774 names[STBI] = "STBI";
775 names[STBU] = "STBU";
776 names[STBUI] = "STBUI";
777 names[STW] = "STW";
778 names[STWI] = "STWI";
779 names[STWU] = "STWU";
780 names[STWUI] = "STWUI";
781
782 names[STT] = "STT";
783 names[STTI] = "STTI";
784 names[STTU] = "STTU";
785 names[STTUI] = "STTUI";
786 names[STO] = "STO";
787 names[STOI] = "STOI";
788 names[STOU] = "STOU";
789 names[STOUI] = "STOUI";
790
791 names[STSF] = "STSF";
792 names[STSFI] = "STSFI";
793 names[STHT] = "STHT";
794 names[STHTI] = "STHTI";
795 names[STCO] = "STCO";
796 names[STCOI] = "STCOI";
797 names[STUNC] = "STUNC";
798 names[STUNCI] = "STUNCI";
799
800 names[SYNCD] = "SYNCD";
801 names[SYNCDI] = "SYNCDI";
802 names[PREST] = "PREST";
803 names[PRESTI] = "PRESTI";
804 names[SYNCID] = "SYNCID";
805 names[SYNCIDI] = "SYNCIDI";
806 names[CALL] = "CALL";
807 names[CALLI] = "CALLI";
808
809 names[OR] = "OR";
810 names[ORI] = "ORI";
811 names[ORN] = "ORN";
812 names[ORNI] = "ORNI";
813 names[NOR] = "NOR";
814 names[NORI] = "NORI";
815 names[XOR] = "XOR";
816 names[XORI] = "XORI";
817
818 names[AND] = "AND";
819 names[ANDI] = "ANDI";
820 names[ANDN] = "ANDN";
821 names[ANDNI] = "ANDNI";
822 names[NAND] = "NAND";
823 names[NANDI] = "NANDI";
824 names[NXOR] = "NXOR";
825 names[NXORI] = "NXORI";
826
827 names[BDIF] = "BDIF";
828 names[BDIFI] = "BDIFI";
829 names[WDIF] = "WDIF";
830 names[WDIFI] = "WDIFI";
831 names[TDIF] = "TDIF";
832 names[TDIFI] = "TDIFI";
833 names[ODIF] = "ODIF";
834 names[ODIFI] = "ODIFI";
835
836 names[MUX] = "MUX";
837 names[MUXI] = "MUXI";
838 names[SADD] = "SADD";
839 names[SADDI] = "SADDI";
840 names[MOR] = "MOR";
841 names[MORI] = "MORI";
842 names[MXOR] = "MXOR";
843 names[MXORI] = "MXORI";
844
845 names[SETH] = "SETH";
846 names[SETMH] = "SETMH";
847 names[SETML] = "SETML";
848 names[SETL] = "SETL";
849 names[INCH] = "INCH";
850 names[INCMH] = "INCMH";
851 names[INCML] = "INCML";
852 names[INCL] = "INCL";
853
854 names[ORH] = "ORH";
855 names[ORMH] = "ORMH";
856 names[ORML] = "ORML";
857 names[ORL] = "ORL";
858 names[ANDNH] = "ANDNH";
859 names[ANDNMH] = "ANDNMH";
860 names[ANDNML] = "ANDNML";
861 names[ANDNL] = "ANDNL";
862
863 names[JMP] = "JMP";
864 names[JMPB] = "JMPB";
865 names[PUSHJ] = "PUSHJ";
866 names[PUSHJB] = "PUSHJB";
867 names[GETA] = "GETA";
868 names[GETAB] = "GETAB";
869 names[PUT] = "PUT";
870 names[PUTI] = "PUTI";
871
872 names[RET] = "RET";
873 names[RESUME] = "RESUME";
874 names[SAVE] = "SAVE";
875 names[UNSAVE] = "UNSAVE";
876 names[SYNC] = "SYNC";
877 names[SWYM] = "SWYM";
878 names[GET] = "GET";
879 names[TRIP] = "TRIP";
880 int n = cast<int>(names.Length());
881 for (int i = 0; i < n; ++i;)
882 {
883 int nameLength = cast<int>(names[i].Length());
884 if (nameLength > maxOpCodeNameLength)
885 {
886 maxOpCodeNameLength = nameLength;
887 }
888 }
889 }
890 public nothrow const string& GetName(byte opCode) const
891 {
892 return names[opCode];
893 }
894 public nothrow int GetCode(const string& name) const
895 {
896 HashMap<string, byte>.ConstIterator i = codes.CFind(name);
897 if (i != codes.CEnd())
898 {
899 return i->second;
900 }
901 return -1;
902 }
903 public nothrow int MaxOpCodeNameLength() const
904 {
905 return maxOpCodeNameLength;
906 }
907 private static UniquePtr<OpCodeMap> instance;
908 private HashMap<string, byte> codes;
909 private string[256] names;
910 private int maxOpCodeNameLength;
911 }
912
913 public nothrow const string& GetOpCodeName(byte opCode)
914 {
915 return OpCodeMap.Instance().GetName(opCode);
916 }
917
918 public nothrow int GetOpCode(const string& opCodeName)
919 {
920 return OpCodeMap.Instance().GetCode(opCodeName);
921 }
922 }