OpenCores
URL https://opencores.org/ocsvn/thor/thor/trunk

Subversion Repositories thor

[/] [thor/] [trunk/] [software/] [emuThor/] [source/] [clsDisassem.cpp] - Blame information for rev 35

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 robfinch
#include "stdafx.h"
2
#include "insn.h"
3
#include "clsDisassem.h"
4
 
5
extern clsSystem system1;
6
 
7
std::string clsDisassem::SprName(int rg)
8
{
9
        char buf[100];
10
 
11
        buf[0] = '\0';
12
        if (rg < 16)
13
                sprintf(buf, "p%d", rg);
14
        else if (rg < 32)
15
                sprintf(buf, "c%d", rg-16);
16 32 robfinch
        else if (rg < 64) {
17 30 robfinch
                switch(rg) {
18
                case 32:        sprintf(buf, "zs"); break;
19
                case 33:        sprintf(buf, "ds"); break;
20
                case 34:        sprintf(buf, "es"); break;
21
                case 35:        sprintf(buf, "fs"); break;
22
                case 36:        sprintf(buf, "gs"); break;
23
                case 37:        sprintf(buf, "hs"); break;
24
                case 38:        sprintf(buf, "ss"); break;
25
                case 39:        sprintf(buf, "cs"); break;
26
                case 40:        sprintf(buf, "zs.lmt"); break;
27
                case 41:        sprintf(buf, "ds.lmt"); break;
28
                case 42:        sprintf(buf, "es.lmt"); break;
29
                case 43:        sprintf(buf, "fs.lmt"); break;
30
                case 44:        sprintf(buf, "gs.lmt"); break;
31
                case 45:        sprintf(buf, "hs.lmt"); break;
32
                case 46:        sprintf(buf, "ss.lmt"); break;
33
                case 47:        sprintf(buf, "cs.lmt"); break;
34 32 robfinch
                case 50:        sprintf(buf, "tick"); break;
35
                case 51:        sprintf(buf, "lc"); break;
36
                case 52:        sprintf(buf, "pregs"); break;
37
                case 60:        sprintf(buf, "bir"); break;
38
                default:        sprintf(buf, "???"); break;
39 30 robfinch
                }
40
        }
41
        return std::string(buf);
42
}
43
 
44
std::string clsDisassem::PredCond(int cnd)
45
{
46
        switch(cnd) {
47
        case PF: return "PF  ";
48
        case PT: return "PT  ";
49
        case PEQ: return "PEQ ";
50
        case PNE: return "PNE ";
51
        case PLE: return "PLE ";
52
        case PGT: return "PGT ";
53
        case PGE: return "PGE ";
54
        case PLT: return "PLT ";
55
        case PLEU: return "PLEU";
56
        case PGTU: return "PGTU";
57
        case PGEU: return "PGEU";
58
        case PLTU: return "PLTU";
59
        default: return "????";
60
        }
61
}
62
 
63 32 robfinch
int clsDisassem::DefaultSeg(int rg)
64
{
65
        switch(rg) {
66
        case 27:
67
        case 28:
68
        case 29:
69
        case 30:
70
        case 31:        return 6;
71
        default:        return 1;
72
        }
73
}
74
 
75
std::string clsDisassem::SegName(int sg)
76
{
77
        switch(sg) {
78
        case 0:  return "zs";
79
        case 1: return "ds";
80
        case 2: return "es";
81
        case 3: return "fs";
82
        case 4: return "gs";
83
        case 5: return "hs";
84
        case 6: return "ss";
85
        case 7: return "cs";
86
        default: return "<err>";
87
        }
88
}
89
 
90
std::string clsDisassem::TLBRegName(int rg)
91
{
92
        switch(rg) {
93
        case 0:  return "Wired";
94
        case 1: return "Index";
95
        case 2: return "Random";
96
        case 3: return "PageSize";
97
        case 4: return "VirtPage";
98
        case 5: return "PhysPage";
99
        case 6: return "ASID";
100
        case 7: return "DMA";
101
        case 8: return "IMA";
102
        case 9: return "PTA";
103
        case 10: return "PTC";
104
        default: return "???";
105
        }
106
}
107
 
108 30 robfinch
// Compute d[Rn] address info
109
std::string clsDisassem::dRn(int b1, int b2, int b3, int *Ra, int *Sg, __int64 *disp)
110
{
111
        char buf[100];
112
 
113
        if (!Ra || !disp || !Sg)
114
                return "<error>";
115
        *Ra = b1 & 0x3f;
116
        *Sg = (b3 >> 5) & 7;
117
        *disp = ((b2 >> 4) & 0xF) | ((b3 & 0x1f) << 4);
118
        if (*disp & 0x100)
119
                *disp |= 0xFFFFFFFFFFFFFE00LL;
120
        if (imm_prefix) {
121
                *disp &= 0xFF;
122
                *disp |= imm;
123
        }
124 32 robfinch
        if (*Sg != DefaultSeg(*Ra))
125
                sprintf(buf, "%s:$%I64X[r%d]", SegName(*Sg).c_str(), *disp, *Ra);
126
        else
127
                sprintf(buf, "$%I64X[r%d]", *disp, *Ra);
128 30 robfinch
        return std::string(buf);
129
}
130
 
131 32 robfinch
// Compute d[Rn] address info
132
std::string clsDisassem::ndx(int b1, int b2, int b3, int *Ra, int *Rb, int *Rt, int *Sg, int *Sc)
133
{
134
        char buf[100];
135
 
136
        if (!Ra || !Rb || !Rt || !Sg)
137
                return "<error>";
138
        *Ra = b1 & 0x3f;
139
        *Rb = (b1 >> 6) | ((b2 & 0x0f) << 2);
140
        *Rt = ((b2 & 0xF0) >> 4) | ((b3 & 3) << 4);
141
        *Sg = (b3 >> 5) & 7;
142
        *Sc = (b3 >> 2) & 3;
143
        if (*Sg != DefaultSeg(*Ra))
144
                sprintf(buf, "%s:[r%d+r%d", SegName(*Sg).c_str(), *Ra, *Rb);
145
        else
146
                sprintf(buf, "[r%d+r%d", *Ra, *Rb);
147
        if (*Sc != 1)
148
                sprintf(&buf[strlen(buf)], "*%d]", (1 << *Sc));
149
        else
150
                sprintf(&buf[strlen(buf)], "]");
151
        return std::string(buf);
152
}
153
 
154
std::string clsDisassem::mem(std::string mne, int ad, int *nb)
155
{
156
        int b1, b2, b3;
157
        int Ra,Rt,Sg;
158
        __int64 disp;
159
        std::string str;
160
        char buf[100];
161
 
162
        buf[0] = '\0';
163
        b1 = ReadByte(ad);
164
        ad++;
165
        b2 = ReadByte(ad);
166
        ad++;
167
        b3 = ReadByte(ad);
168
        ad++;
169
        Rt = ((b2 & 0xF) << 2) | (( b1 >> 6) & 3);
170
        str = dRn(b1,b2,b3,&Ra,&Sg,&disp);
171
        sprintf(&buf[strlen(buf)]," %s r%d,%s", mne.c_str(), Rt, str.c_str());
172
        if (nb) *nb = 5;
173
        imm_prefix = false;
174
        return std::string(buf);
175
}
176
 
177
std::string clsDisassem::memndx(std::string mne, int ad, int *nb)
178
{
179
        int b1, b2, b3;
180
        int Ra,Rb,Rt,Sg,Sc;
181
        __int64 disp;
182
        std::string str;
183
        char buf[100];
184
 
185
        buf[0] = '\0';
186
        b1 = ReadByte(ad);
187
        ad++;
188
        b2 = ReadByte(ad);
189
        ad++;
190
        b3 = ReadByte(ad);
191
        ad++;
192
        str = ndx(b1,b2,b3,&Ra,&Rb,&Rt,&Sg,&Sc);
193
        sprintf(&buf[strlen(buf)]," %s r%d,%s", mne.c_str(), Rt, str.c_str());
194
        if (nb) *nb = 5;
195
        imm_prefix = false;
196
        return std::string(buf);
197
}
198
 
199 30 robfinch
std::string clsDisassem::Disassem(int ad, int *nb)
200
{
201
        int byt;
202
        int opcode, func;
203
        int n;
204 35 robfinch
        __int64 val, disp, amt;
205 30 robfinch
        int rv;
206
        int b1, b2, b3, b4;
207 32 robfinch
        int Ra,Rb,Rc,Rt,Sprn,Sg,Sc,Sz;
208
        int Cr,Ct,Tn;
209 30 robfinch
        int Pn;
210
        char buf[100];
211
        std::string str;
212
 
213
        buf[0] = '\0';
214
        byt = system1.ReadByte(ad);
215
        ad++;
216
        if (byt==0x00) {
217
                if (nb) *nb = 1;
218
                return std::string("        BRK");
219
        }
220
        if (byt==0x10) {
221
                if (nb) *nb = 1;
222
                return std::string("        NOP");
223
        }
224
        if (byt==0x20) {
225
                val = system1.ReadByte(ad);
226
                ad++;
227
                if (val & 0x80LL)
228
                        val |= 0xFFFFFFFFFFFFFF00LL;
229
                sprintf(buf, "        IMM %02LLX",val);
230
                if (nb) *nb = 2;
231
                imm = val << 8;
232
                imm_prefix = true;
233
                return std::string(buf);
234
        }
235
        if (byt==0x30) {
236
                val = system1.ReadByte(ad);
237
                ad++;
238
                val += (system1.ReadByte(ad) << 8);
239
                ad++;
240
                if (val & 0x8000LL)
241
                        val |= 0xFFFFFFFFFFFF0000LL;
242
                sprintf(buf, "        IMM %04LLX",val);
243
                if (nb) *nb = 3;
244
                imm = val << 8;
245
                imm_prefix = true;
246
                return std::string(buf);
247
        }
248
        if (byt==0x40) {
249
                val = system1.ReadByte(ad);
250
                ad++;
251
                val += (system1.ReadByte(ad) << 8);
252
                ad++;
253
                val += (system1.ReadByte(ad) << 16);
254
                ad++;
255
                if (val & 0x800000LL)
256
                        val |= 0xFFFFFFFFFF000000LL;
257
                sprintf(buf, "        IMM %06LLX",val);
258
                imm = val << 8;
259
                if (nb) *nb = 4;
260
                imm_prefix = true;
261
                return std::string(buf);
262
        }
263
        if (byt==0x50) {
264
                val = system1.ReadByte(ad);
265
                ad++;
266
                val += (system1.ReadByte(ad) << 8);
267
                ad++;
268
                val += (system1.ReadByte(ad) << 16);
269
                ad++;
270
                val += (system1.ReadByte(ad) << 24);
271
                ad++;
272
                if (val & 0x80000000LL)
273
                        val |= 0xFFFFFFFF00000000LL;
274
                sprintf(buf, "        IMM %08LLX",val);
275
                if (nb) *nb = 5;
276
                imm = val << 8;
277
                imm_prefix = true;
278
                return std::string(buf);
279
        }
280
        if (byt==0x60) {
281
                val = system1.ReadByte(ad);
282
                ad++;
283
                val += (system1.ReadByte(ad) << 8);
284
                ad++;
285
                val += (system1.ReadByte(ad) << 16);
286
                ad++;
287
                val += (system1.ReadByte(ad) << 24);
288
                ad++;
289
                val += (system1.ReadByte(ad) << 32);
290
                ad++;
291
                if (val & 0x8000000000LL)
292
                        val |= 0xFFFFFF0000000000LL;
293
                sprintf(buf, "        IMM %010LLX",val);
294
                if (nb) *nb = 6;
295
                imm = val << 8;
296
                imm_prefix = true;
297
                return std::string(buf);
298
        }
299
        if (byt==0x70) {
300
                val = system1.ReadByte(ad);
301
                ad++;
302
                val += (system1.ReadByte(ad) << 8);
303
                ad++;
304
                val += (system1.ReadByte(ad) << 16);
305
                ad++;
306
                val += (system1.ReadByte(ad) << 24);
307
                ad++;
308
                val += (system1.ReadByte(ad) << 32);
309
                ad++;
310
                val += (system1.ReadByte(ad) << 40);
311
                ad++;
312
                if (val & 0x800000000000LL)
313
                        val |= 0xFFFF000000000000LL;
314
                sprintf(buf, "        IMM %012LLX",val);
315
                if (nb) *nb = 7;
316
                imm = val << 8;
317
                imm_prefix = true;
318
                return std::string(buf);
319
        }
320
        if (byt==0x80) {
321
                val = system1.ReadByte(ad);
322
                ad++;
323
                val += (system1.ReadByte(ad) << 8);
324
                ad++;
325
                val += (system1.ReadByte(ad) << 16);
326
                ad++;
327
                val += (system1.ReadByte(ad) << 24);
328
                ad++;
329
                val += (system1.ReadByte(ad) << 32);
330
                ad++;
331
                val += (system1.ReadByte(ad) << 40);
332
                ad++;
333
                val += (system1.ReadByte(ad) << 48);
334
                ad++;
335
                if (val & 0x80000000000000LL)
336
                        val |= 0xFF00000000000000LL;
337
                sprintf(buf, "        IMM %014LLX",val);
338
                if (nb) *nb = 8;
339
                imm = val << 8;
340
                imm_prefix = true;
341
                return std::string(buf);
342
        }
343
        if (byt != 0x01)
344
                sprintf(buf, "p%d.%s ", (byt & 0xF0) >> 4, PredCond(byt & 0xF).c_str());
345
        opcode = system1.ReadByte(ad);
346
        ad++;
347
        if ((opcode & 0xF0)==0x00) {
348
                b1 = system1.ReadByte(ad);
349
                ad++;
350
                Ra = b1 & 0x3f;
351
                Pn = opcode & 0x0f;
352
                sprintf(&buf[strlen(buf)], "TST p%d,r%d", Pn, Ra);
353
                if (nb) *nb = 3;
354
                imm_prefix = false;
355
                return std::string(buf);
356
        }
357 32 robfinch
        if ((opcode & 0xF0)==0x10) {
358
                b1 = system1.ReadByte(ad);
359
                ad++;
360
                b2 = system1.ReadByte(ad);
361
                ad++;
362
                Ra = b1 & 0x3f;
363
                Rb = ((b2 << 2) | (b1 >> 6)) & 0x3f;
364
                Pn = opcode & 0x0f;
365
                switch(b2 >> 4) {
366
                case 0:  sprintf(&buf[strlen(buf)], " CMP p%d,r%d,r%d", Pn, Ra, Rb); break;
367
                case 1: sprintf(&buf[strlen(buf)], " FCMP.S p%d,r%d,r%d", Pn, Ra, Rb); break;
368
                case 2: sprintf(&buf[strlen(buf)], " FCMP.D p%d,r%d,r%d", Pn, Ra, Rb); break;
369
                }
370
                if (nb) *nb = 4;
371
                imm_prefix = false;
372
                return std::string(buf);
373
        }
374 30 robfinch
        if ((opcode & 0xF0)==0x20) {
375
                b1 = system1.ReadByte(ad);
376
                ad++;
377
                b2 = system1.ReadByte(ad);
378
                ad++;
379
                Ra = b1 & 0x3f;
380
                Pn = opcode & 0x0f;
381
                val = (b2 << 2) | (b1 >> 6);
382
                if (imm_prefix)
383
                        val = imm | (val & 0xFF);
384
                else {
385
                        if (val & 0x200)
386
                                val |= 0xFFFFFFFFFFFFFE00LL;
387
                }
388
                sprintf(&buf[strlen(buf)], " CMPI p%d,r%d,#$%LLX", Pn, Ra, val);
389
                if (nb) *nb = 4;
390
                imm_prefix = false;
391
                return std::string(buf);
392
        }
393
        if ((opcode & 0xF0)==0x30) {
394
                b1 = system1.ReadByte(ad);
395
                ad++;
396 35 robfinch
                disp = b1 | ((opcode & 0xF) << 8);
397 30 robfinch
                if (disp & 0x800)
398
                        disp |= 0xFFFFFFFFFFFFF000LL;
399 32 robfinch
                sprintf(&buf[strlen(buf)], " BR $%LLX", disp + ad);
400 30 robfinch
                if (nb) *nb = 3;
401
                imm_prefix = false;
402
                return std::string(buf);
403
        }
404
 
405
        switch(opcode) {
406
 
407 32 robfinch
        case _2ADDUI:
408
                b1 = system1.ReadByte(ad);
409
                ad++;
410
                b2 = system1.ReadByte(ad);
411
                ad++;
412
                b3 = system1.ReadByte(ad);
413
                ad++;
414
                Ra = b1 & 0x3f;
415
                Rt = ((b2 & 0xf) << 2) | (b1 >> 6);
416
                val = (b3 << 4) | (b2 >> 4);
417
                sprintf(&buf[strlen(buf)], " _2ADDUI r%d,r%d,#$%I64X", Rt, Ra, val);
418
                if (nb) *nb = 5;
419
                imm_prefix = false;
420
                return std::string(buf);
421
 
422
        case _4ADDUI:
423
                b1 = system1.ReadByte(ad);
424
                ad++;
425
                b2 = system1.ReadByte(ad);
426
                ad++;
427
                b3 = system1.ReadByte(ad);
428
                ad++;
429
                Ra = b1 & 0x3f;
430
                Rt = ((b2 & 0xf) << 2) | (b1 >> 6);
431
                val = (b3 << 4) | (b2 >> 4);
432
                sprintf(&buf[strlen(buf)], " _4ADDUI r%d,r%d,#$%I64X", Rt, Ra, val);
433
                if (nb) *nb = 5;
434
                imm_prefix = false;
435
                return std::string(buf);
436
 
437
        case _8ADDUI:
438
                b1 = system1.ReadByte(ad);
439
                ad++;
440
                b2 = system1.ReadByte(ad);
441
                ad++;
442
                b3 = system1.ReadByte(ad);
443
                ad++;
444
                Ra = b1 & 0x3f;
445
                Rt = ((b2 & 0xf) << 2) | (b1 >> 6);
446
                val = (b3 << 4) | (b2 >> 4);
447
                sprintf(&buf[strlen(buf)], " _8ADDUI r%d,r%d,#$%I64X", Rt, Ra, val);
448
                if (nb) *nb = 5;
449
                imm_prefix = false;
450
                return std::string(buf);
451
 
452
        case _16ADDUI:
453
                b1 = system1.ReadByte(ad);
454
                ad++;
455
                b2 = system1.ReadByte(ad);
456
                ad++;
457
                b3 = system1.ReadByte(ad);
458
                ad++;
459
                Ra = b1 & 0x3f;
460
                Rt = ((b2 & 0xf) << 2) | (b1 >> 6);
461
                val = (b3 << 4) | (b2 >> 4);
462
                sprintf(&buf[strlen(buf)], " _16ADDUI r%d,r%d,#$%I64X", Rt, Ra, val);
463
                if (nb) *nb = 5;
464
                imm_prefix = false;
465
                return std::string(buf);
466
 
467 30 robfinch
        case ADDUI:
468
                b1 = system1.ReadByte(ad);
469
                ad++;
470
                b2 = system1.ReadByte(ad);
471
                ad++;
472
                b3 = system1.ReadByte(ad);
473
                ad++;
474
                Ra = b1 & 0x3f;
475
                Rt = ((b2 & 0xf) << 2) | (b1 >> 6);
476
                val = (b3 << 4) | (b2 >> 4);
477 32 robfinch
                sprintf(&buf[strlen(buf)], " ADDUI r%d,r%d,#$%I64X", Rt, Ra, val);
478 30 robfinch
                if (nb) *nb = 5;
479
                imm_prefix = false;
480
                return std::string(buf);
481
 
482
        case ADDUIS:
483
                b1 = system1.ReadByte(ad);
484
                ad++;
485
                b2 = system1.ReadByte(ad);
486
                ad++;
487
                Ra = b1 & 0x3f;
488
                Rt = Ra;
489
                val = (b2 << 2) | (b1 >> 6);
490 32 robfinch
                sprintf(&buf[strlen(buf)], " ADDUI r%d,r%d,#$%I64X", Rt, Ra, val);
491 30 robfinch
                if (nb) *nb = 4;
492
                imm_prefix = false;
493
                return std::string(buf);
494
 
495 32 robfinch
        case ANDI:
496
                b1 = system1.ReadByte(ad);
497
                ad++;
498
                b2 = system1.ReadByte(ad);
499
                ad++;
500
                b3 = system1.ReadByte(ad);
501
                ad++;
502
                Ra = b1 & 0x3f;
503
                Rt = ((b2 & 0xf) << 2) | (b1 >> 6);
504
                val = (b3 << 4) | (b2 >> 4);
505
                sprintf(&buf[strlen(buf)], " ANDI r%d,r%d,#$%I64X", Rt, Ra, val);
506
                if (nb) *nb = 5;
507
                imm_prefix = false;
508
                return std::string(buf);
509
 
510
        case BITI:
511
                b1 = system1.ReadByte(ad);
512
                ad++;
513
                b2 = system1.ReadByte(ad);
514
                ad++;
515
                b3 = system1.ReadByte(ad);
516
                ad++;
517
                Ra = b1 & 0x3f;
518
                Pn = ((b2 & 0x3) << 2) | (b1 >> 6);
519
                val = (b3 << 4) | (b2 >> 4);
520
                sprintf(&buf[strlen(buf)], " BITI p%d,r%d,#$%I64X", Pn, Ra, val);
521
                if (nb) *nb = 5;
522
                imm_prefix = false;
523
                return std::string(buf);
524
 
525
        case CLI:
526
                sprintf(&buf[strlen(buf)], " CLI");
527
                if (nb) *nb = 2;
528
                imm_prefix = false;
529
                return std::string(buf);
530
 
531
        case DIVI:
532
                b1 = system1.ReadByte(ad);
533
                ad++;
534
                b2 = system1.ReadByte(ad);
535
                ad++;
536
                b3 = system1.ReadByte(ad);
537
                ad++;
538
                Ra = b1 & 0x3f;
539
                Rt = ((b2 & 0xf) << 2) | (b1 >> 6);
540
                val = (b3 << 4) | (b2 >> 4);
541
                sprintf(&buf[strlen(buf)], " DIVI r%d,r%d,#$%I64X", Rt, Ra, val);
542
                if (nb) *nb = 5;
543
                imm_prefix = false;
544
                return std::string(buf);
545
 
546
        case DIVUI:
547
                b1 = system1.ReadByte(ad);
548
                ad++;
549
                b2 = system1.ReadByte(ad);
550
                ad++;
551
                b3 = system1.ReadByte(ad);
552
                ad++;
553
                Ra = b1 & 0x3f;
554
                Rt = ((b2 & 0xf) << 2) | (b1 >> 6);
555
                val = (b3 << 4) | (b2 >> 4);
556
                sprintf(&buf[strlen(buf)], " DIVUI r%d,r%d,#$%I64X", Rt, Ra, val);
557
                if (nb) *nb = 5;
558
                imm_prefix = false;
559
                return std::string(buf);
560
 
561
        case EORI:
562
                b1 = system1.ReadByte(ad);
563
                ad++;
564
                b2 = system1.ReadByte(ad);
565
                ad++;
566
                b3 = system1.ReadByte(ad);
567
                ad++;
568
                Ra = b1 & 0x3f;
569
                Rt = ((b2 & 0xf) << 2) | (b1 >> 6);
570
                val = (b3 << 4) | (b2 >> 4);
571
                sprintf(&buf[strlen(buf)], " EORI r%d,r%d,#$%I64X", Rt, Ra, val);
572
                if (nb) *nb = 5;
573
                imm_prefix = false;
574
                return std::string(buf);
575
 
576 35 robfinch
        case INC:
577
                b1 = system1.ReadByte(ad);
578
                ad++;
579
                b2 = system1.ReadByte(ad);
580
                ad++;
581
                b3 = system1.ReadByte(ad);
582
                ad++;
583
                b4 = system1.ReadByte(ad);
584
                ad++;
585
                Ra = b1 & 0x3f;
586
                Sz = (b1 >> 6) | ((b2 & 1) << 2);
587
                disp = (b2 >> 4) | ((b3 & 31) << 4);
588
                if (disp & 0x100)
589
                        disp |= 0xFFFFFFFFFFFFFF00LL;
590
                Sg = b3 >> 5;
591
                amt = b4;
592
                if (amt & 0x80)
593
                        amt |= 0xFFFFFFFFFFFFFF00LL;
594
                sprintf(&buf[strlen(buf)], " INC.%c %s:$%I64X[r%d],#%I64d",
595
                        Sz==0 ? 'B' : Sz==1 ? 'C' : Sz==2 ? 'H' : 'W',
596
                        SegName(Sg), disp, Ra, amt);
597
                if (nb) *nb = 6;
598
                imm_prefix = false;
599
                return std::string(buf);
600
 
601 30 robfinch
        case JSR:
602
                b1 = system1.ReadByte(ad);
603
                ad++;
604
                b2 = system1.ReadByte(ad);
605
                ad++;
606
                b3 = system1.ReadByte(ad);
607
                ad++;
608
                b4 = system1.ReadByte(ad);
609
                ad++;
610
                Cr = b1 >> 4;
611
                Ct = b1 & 0xF;
612
                if (imm_prefix)
613
                        disp = imm | b2;
614
                else {
615
                        disp = (b4 << 16) | (b3 << 8) | b2;
616
                        if (disp & 0x800000LL)
617
                                disp |= 0xFFFFFFFFFF000000LL;
618
                }
619
                if (nb) *nb = 6;
620
                imm_prefix = false;
621 32 robfinch
                sprintf(&buf[strlen(buf)], " JSR c%d,$%I64X[c%d]", Ct, disp, Cr);
622
                if (Cr==15)
623
                        sprintf(&buf[strlen(buf)], "  ($%I64X)", ad-6 + disp);
624 30 robfinch
                return std::string(buf);
625
 
626 32 robfinch
        case JSRI:
627
                b1 = system1.ReadByte(ad);
628
                ad++;
629
                b2 = system1.ReadByte(ad);
630
                ad++;
631
                b3 = system1.ReadByte(ad);
632
                ad++;
633
                Ra = b1 & 0x3f;
634
                Ct = (b1 >> 6) | (b2 << 2) & 0xc0;
635
                Sz = (b2 >> 2) & 3;
636
                Sg = b3 >> 5;
637
                disp = ((b3 & 0x1f) << 4) | (b2 >> 4);
638
                if (disp & 0x800LL)
639
                        disp |= 0xFFFFFFFFFFFFFE00LL;
640
                if (imm_prefix) {
641
                        disp &= 0xFFLL;
642
                        disp = imm | disp;
643
                }
644
                if (nb) *nb = 5;
645
                imm_prefix = false;
646
                switch(Sz) {
647
                case 1: sprintf(&buf[strlen(buf)], " JCI c%d,%s:$%I64X[r%d]", Ct, SegName(Sg).c_str(), disp, Ra); break;
648
                case 2: sprintf(&buf[strlen(buf)], " JHI c%d,%s:$%I64X[r%d]", Ct, SegName(Sg).c_str(), disp, Ra); break;
649
                case 3: sprintf(&buf[strlen(buf)], " JWI c%d,%s:$%I64X[r%d]", Ct, SegName(Sg).c_str(), disp, Ra); break;
650
                }
651
                return std::string(buf);
652
 
653 30 robfinch
        case JSRS:
654
                b1 = system1.ReadByte(ad);
655
                ad++;
656
                b2 = system1.ReadByte(ad);
657
                ad++;
658
                b3 = system1.ReadByte(ad);
659
                ad++;
660
                Cr = b1 >> 4;
661
                Ct = b1 & 0xF;
662
                if (imm_prefix)
663
                        disp = imm | b2;
664
                else {
665
                        disp = (b3 << 8) | b2;
666
                        if (disp & 0x8000LL)
667
                                disp |= 0xFFFFFFFFFFFF0000LL;
668
                }
669
                if (nb) *nb = 5;
670
                imm_prefix = false;
671
                sprintf(&buf[strlen(buf)], " JSR c%d,$%LLX", Ct, disp);
672
                if (Cr==15)
673 32 robfinch
                        sprintf(&buf[strlen(buf)], "[c%d]  ($%LLX)", Cr, ad-5 + disp);
674 30 robfinch
                else
675
                        sprintf(&buf[strlen(buf)], "[c%d]", Cr);
676
                return std::string(buf);
677
 
678 32 robfinch
        case JSRR:
679
                b1 = system1.ReadByte(ad);
680
                ad++;
681
                Cr = b1 >> 4;
682
                Ct = b1 & 0xF;
683
                if (nb) *nb = 3;
684
                imm_prefix = false;
685
                sprintf(&buf[strlen(buf)], " JSR c%d,[c%d]", Ct, Cr);
686
                return std::string(buf);
687
 
688 30 robfinch
        case LDI:
689
                b1 = system1.ReadByte(ad);
690
                ad++;
691
                b2 = system1.ReadByte(ad);
692
                ad++;
693
                Rt = b1 & 0x3f;
694
                val = (b2 << 2) | (b1 >> 6);
695
                if (imm_prefix)
696
                        val = imm | (val & 0xFF);
697
                else {
698
                        if (val & 0x200)
699
                                val |= 0xFFFFFFFFFFFFFE00LL;
700
                }
701
                sprintf(&buf[strlen(buf)], " LDI r%d,#$%08LLX", Rt, val);
702
                if (nb) *nb = 4;
703
                imm_prefix = false;
704
                return std::string(buf);
705
 
706
        case LDIS:
707
                b1 = system1.ReadByte(ad);
708
                ad++;
709
                b2 = system1.ReadByte(ad);
710
                ad++;
711
                Sprn = b1 & 0x3f;
712
                val = (b2 << 2) | (b1 >> 6);
713
                if (imm_prefix)
714
                        val = imm | (val & 0xFF);
715
                else {
716
                        if (val & 0x200)
717
                                val |= 0xFFFFFFFFFFFFFE00LL;
718
                }
719
                sprintf(&buf[strlen(buf)], " LDIS %s,#$%08LLX", SprName(Sprn).c_str(), val);
720
                if (nb) *nb = 4;
721
                imm_prefix = false;
722
                return std::string(buf);
723
 
724 32 robfinch
        case LB:        return mem("LB", ad, nb);
725
        case LBX:       return memndx("LBX", ad, nb);
726
        case LBUX:      return memndx("LBUX", ad, nb);
727
        case LVB:       return mem("LVB", ad, nb);
728
        case LBU:       return mem("LBU", ad, nb);
729
        case LC:        return mem("LC", ad, nb);
730
        case LCX:       return memndx("LCX", ad, nb);
731
        case LCUX:      return memndx("LCUX", ad, nb);
732
        case LVC:       return mem("LVC", ad, nb);
733
        case LCU:       return mem("LCU", ad, nb);
734
        case LH:        return mem("LH", ad, nb);
735
        case LHX:       return memndx("LHX", ad, nb);
736
        case LHUX:      return memndx("LHUX", ad, nb);
737
        case LVH:       return mem("LVH", ad, nb);
738
        case LHU:       return mem("LHU", ad, nb);
739
        case LW:        return mem("LW", ad, nb);
740
        case LWX:       return memndx("LWX", ad, nb);
741
        case LVW:       return mem("LVW", ad, nb);
742
        case LVWAR:     return mem("LVWAR", ad, nb);
743 30 robfinch
 
744
        case LLA:
745
                b1 = ReadByte(ad);
746
                ad++;
747
                b2 = ReadByte(ad);
748
                ad++;
749
                b3 = ReadByte(ad);
750
                ad++;
751
                Rt = ((b2 & 0xF) << 2) | (( b1 >> 6) & 3);
752
                str = dRn(b1,b2,b3,&Ra,&Sg,&disp);
753
                sprintf(&buf[strlen(buf)]," LLA r%d,%s", Rt, str.c_str());
754
                if (nb) *nb = 5;
755
                imm_prefix = false;
756
                return std::string(buf);
757
 
758
        case LOGIC:
759
                b1 = system1.ReadByte(ad);
760
                ad++;
761
                b2 = system1.ReadByte(ad);
762
                ad++;
763
                b3 = system1.ReadByte(ad);
764
                ad++;
765
                Ra = b1 & 0x3f;
766
                Rb = ((b2 & 0x0f) << 2) | (b1 >> 6);
767
                Rt = ((b3 & 3) << 4) | (b2 >> 4);
768
                func = b3 >> 2;
769
                switch(func) {
770 32 robfinch
                case AND:       sprintf(&buf[strlen(buf)], " AND r%d,r%d,r%d", Rt, Ra, Rb); break;
771
                case OR:        sprintf(&buf[strlen(buf)], " OR r%d,r%d,r%d", Rt, Ra, Rb); break;
772
                case EOR:       sprintf(&buf[strlen(buf)], " EOR r%d,r%d,r%d", Rt, Ra, Rb); break;
773
                case NAND:      sprintf(&buf[strlen(buf)], " NAND r%d,r%d,r%d", Rt, Ra, Rb); break;
774
                case NOR:       sprintf(&buf[strlen(buf)], " NOR r%d,r%d,r%d", Rt, Ra, Rb); break;
775
                case ENOR:      sprintf(&buf[strlen(buf)], " ENOR r%d,r%d,r%d", Rt, Ra, Rb); break;
776 30 robfinch
                }
777
                if (nb) *nb = 5;
778
                imm_prefix = false;
779
                return std::string(buf);
780
 
781
        case LOOP:
782
                disp = system1.ReadByte(ad);
783
                ad++;
784
                if (disp & 0x80LL)
785
                        disp |= 0xFFFFFFFFFFFFFF00LL;
786
                sprintf(&buf[strlen(buf)], " LOOP $%LLX", disp + ad);
787
                if (nb) *nb = 3;
788
                imm_prefix = false;
789
                return std::string(buf);
790
 
791 32 robfinch
        case LWS:
792
                b1 = ReadByte(ad);
793
                ad++;
794
                b2 = ReadByte(ad);
795
                ad++;
796
                b3 = ReadByte(ad);
797
                ad++;
798
                Rb = ((b2 & 0xF) << 2) | (( b1 >> 6) & 3);
799
                str = dRn(b1,b2,b3,&Ra,&Sg,&disp);
800
                sprintf(&buf[strlen(buf)]," LWS %s,%s", SprName(Rb).c_str(), str.c_str());
801
                if (nb) *nb = 5;
802
                imm_prefix = false;
803
                return std::string(buf);
804
 
805
        case MEMSB:
806
                sprintf(&buf[strlen(buf)], " MEMSB");
807
                if (nb) *nb = 2;
808
                imm_prefix = false;
809
                return std::string(buf);
810
 
811
        case MEMDB:
812
                sprintf(&buf[strlen(buf)], " MEMDB");
813
                if (nb) *nb = 2;
814
                imm_prefix = false;
815
                return std::string(buf);
816
 
817 30 robfinch
        case MFSPR:
818
                b1 = system1.ReadByte(ad);
819
                ad++;
820
                b2 = system1.ReadByte(ad);
821
                ad++;
822
                Sprn = b1 & 0x3f;
823
                Rt = ((b2 & 0x0f) << 2) | (b1 >> 6);
824
                sprintf(&buf[strlen(buf)], " MFSPR r%d,%s", Rt, SprName(Sprn).c_str());
825
                if (nb) *nb = 4;
826
                imm_prefix = false;
827
                return std::string(buf);
828
 
829 32 robfinch
        case MODI:
830
                b1 = system1.ReadByte(ad);
831
                ad++;
832
                b2 = system1.ReadByte(ad);
833
                ad++;
834
                b3 = system1.ReadByte(ad);
835
                ad++;
836
                Ra = b1 & 0x3f;
837
                Rt = ((b2 & 0xf) << 2) | (b1 >> 6);
838
                val = (b3 << 4) | (b2 >> 4);
839
                sprintf(&buf[strlen(buf)], " MODI r%d,r%d,#$%I64X", Rt, Ra, val);
840
                if (nb) *nb = 5;
841
                imm_prefix = false;
842
                return std::string(buf);
843
 
844
        case MODUI:
845
                b1 = system1.ReadByte(ad);
846
                ad++;
847
                b2 = system1.ReadByte(ad);
848
                ad++;
849
                b3 = system1.ReadByte(ad);
850
                ad++;
851
                Ra = b1 & 0x3f;
852
                Rt = ((b2 & 0xf) << 2) | (b1 >> 6);
853
                val = (b3 << 4) | (b2 >> 4);
854
                sprintf(&buf[strlen(buf)], " MODUI r%d,r%d,#$%I64X", Rt, Ra, val);
855
                if (nb) *nb = 5;
856
                imm_prefix = false;
857
                return std::string(buf);
858
 
859
        case GRPA7:
860 30 robfinch
                b1 = ReadByte(ad);
861
                ad++;
862
                b2 = ReadByte(ad);
863
                ad++;
864
                Ra = b1 & 0x3f;
865
                Rt = ((b2 & 0xF) << 2) | (b1 >> 6);
866 32 robfinch
                switch(b2>>4) {
867
                case MOV:       sprintf(&buf[strlen(buf)]," MOV r%d,r%d", Rt, Ra); break;
868
                case SXB:       sprintf(&buf[strlen(buf)]," SXB r%d,r%d", Rt, Ra); break;
869
                case SXC:       sprintf(&buf[strlen(buf)]," SXC r%d,r%d", Rt, Ra); break;
870
                case SXH:       sprintf(&buf[strlen(buf)]," SXH r%d,r%d", Rt, Ra); break;
871
                case ZXB:       sprintf(&buf[strlen(buf)]," ZXB r%d,r%d", Rt, Ra); break;
872
                case ZXC:       sprintf(&buf[strlen(buf)]," ZXC r%d,r%d", Rt, Ra); break;
873
                case ZXH:       sprintf(&buf[strlen(buf)]," ZXH r%d,r%d", Rt, Ra); break;
874
                }
875 30 robfinch
                if (nb) *nb = 4;
876
                imm_prefix = false;
877
                return std::string(buf);
878
 
879
        case MTSPR:
880
                b1 = system1.ReadByte(ad);
881
                ad++;
882
                b2 = system1.ReadByte(ad);
883
                ad++;
884
                Ra = b1 & 0x3f;
885
                Sprn = ((b2 & 0x0f) << 2) | (b1 >> 6);
886
                sprintf(&buf[strlen(buf)], " MTSPR %s,r%d", SprName(Sprn).c_str(), Ra);
887
                if (nb) *nb = 4;
888
                imm_prefix = false;
889
                return std::string(buf);
890
 
891 32 robfinch
        case MULI:
892
                b1 = system1.ReadByte(ad);
893
                ad++;
894
                b2 = system1.ReadByte(ad);
895
                ad++;
896
                b3 = system1.ReadByte(ad);
897
                ad++;
898
                Ra = b1 & 0x3f;
899
                Rt = ((b2 & 0xf) << 2) | (b1 >> 6);
900
                val = (b3 << 4) | (b2 >> 4);
901
                sprintf(&buf[strlen(buf)], " MULI r%d,r%d,#$%I64X", Rt, Ra, val);
902
                if (nb) *nb = 5;
903
                imm_prefix = false;
904
                return std::string(buf);
905
 
906
        case MULUI:
907
                b1 = system1.ReadByte(ad);
908
                ad++;
909
                b2 = system1.ReadByte(ad);
910
                ad++;
911
                b3 = system1.ReadByte(ad);
912
                ad++;
913
                Ra = b1 & 0x3f;
914
                Rt = ((b2 & 0xf) << 2) | (b1 >> 6);
915
                val = (b3 << 4) | (b2 >> 4);
916
                sprintf(&buf[strlen(buf)], " MULUI r%d,r%d,#$%I64X", Rt, Ra, val);
917
                if (nb) *nb = 5;
918
                imm_prefix = false;
919
                return std::string(buf);
920
 
921
        case ORI:
922
                b1 = system1.ReadByte(ad);
923
                ad++;
924
                b2 = system1.ReadByte(ad);
925
                ad++;
926
                b3 = system1.ReadByte(ad);
927
                ad++;
928
                Ra = b1 & 0x3f;
929
                Rt = ((b2 & 0xf) << 2) | (b1 >> 6);
930
                val = (b3 << 4) | (b2 >> 4);
931
                sprintf(&buf[strlen(buf)], " ORI r%d,r%d,#$%I64X", Rt, Ra, val);
932
                if (nb) *nb = 5;
933
                imm_prefix = false;
934
                return std::string(buf);
935
 
936 30 robfinch
        case RR:
937
                b1 = system1.ReadByte(ad);
938
                ad++;
939
                b2 = system1.ReadByte(ad);
940
                ad++;
941
                b3 = system1.ReadByte(ad);
942
                ad++;
943
                Ra = b1 & 0x3f;
944
                Rb = ((b2 & 0x0f) << 2) | (b1 >> 6);
945
                Rt = ((b3 & 3) << 4) | (b2 >> 4);
946
                func = b3 >> 2;
947
                switch(func) {
948 32 robfinch
                case ADD:
949
                        sprintf(&buf[strlen(buf)], " ADD r%d,r%d,r%d", Rt, Ra, Rb);
950
                        break;
951
                case ADDU:
952
                        sprintf(&buf[strlen(buf)], " ADDU r%d,r%d,r%d", Rt, Ra, Rb);
953
                        break;
954
                case DIV:
955
                        sprintf(&buf[strlen(buf)], " DIV r%d,r%d,r%d", Rt, Ra, Rb);
956
                        break;
957
                case DIVU:
958
                        sprintf(&buf[strlen(buf)], " DIVU r%d,r%d,r%d", Rt, Ra, Rb);
959
                        break;
960
                case MUL:
961
                        sprintf(&buf[strlen(buf)], " MUL r%d,r%d,r%d", Rt, Ra, Rb);
962
                        break;
963
                case MULU:
964
                        sprintf(&buf[strlen(buf)], " MULU r%d,r%d,r%d", Rt, Ra, Rb);
965
                        break;
966 30 robfinch
                case _2ADDU:
967
                        sprintf(&buf[strlen(buf)], " _2ADDU r%d,r%d,r%d", Rt, Ra, Rb);
968
                        break;
969
                case _4ADDU:
970
                        sprintf(&buf[strlen(buf)], " _4ADDU r%d,r%d,r%d", Rt, Ra, Rb);
971
                        break;
972
                case _8ADDU:
973
                        sprintf(&buf[strlen(buf)], " _8ADDU r%d,r%d,r%d", Rt, Ra, Rb);
974
                        break;
975
                case _16ADDU:
976
                        sprintf(&buf[strlen(buf)], " _16ADDU r%d,r%d,r%d", Rt, Ra, Rb);
977
                        break;
978 32 robfinch
                case MOD:
979
                        sprintf(&buf[strlen(buf)], " MOD r%d,r%d,r%d", Rt, Ra, Rb);
980
                        break;
981
                case MODU:
982
                        sprintf(&buf[strlen(buf)], " MODU r%d,r%d,r%d", Rt, Ra, Rb);
983
                        break;
984
                case SUB:
985
                        sprintf(&buf[strlen(buf)], " SUB r%d,r%d,r%d", Rt, Ra, Rb);
986
                        break;
987
                case SUBU:
988
                        sprintf(&buf[strlen(buf)], " SUBU r%d,r%d,r%d", Rt, Ra, Rb);
989
                        break;
990 30 robfinch
                }
991
                if (nb) *nb = 5;
992
                imm_prefix = false;
993
                return std::string(buf);
994
 
995 32 robfinch
        case RTD:
996
                sprintf(&buf[strlen(buf)], " RTD");
997
                if (nb) *nb = 2;
998
                imm_prefix = false;
999
                return std::string(buf);
1000
 
1001
        case RTE:
1002
                sprintf(&buf[strlen(buf)], " RTE");
1003
                if (nb) *nb = 2;
1004
                imm_prefix = false;
1005
                return std::string(buf);
1006
 
1007
        case RTI:
1008
                sprintf(&buf[strlen(buf)], " RTI");
1009
                if (nb) *nb = 2;
1010
                imm_prefix = false;
1011
                return std::string(buf);
1012
 
1013 30 robfinch
        case RTS:
1014
                b1 = system1.ReadByte(ad);
1015
                ad++;
1016
                Cr = b1 >> 4;
1017
                sprintf(&buf[strlen(buf)], " RTS $%X[c%d]", b1 & 0xF, Cr);
1018
                if (nb) *nb = 3;
1019
                imm_prefix = false;
1020
                return std::string(buf);
1021
 
1022
        case RTSQ:
1023
                sprintf(&buf[strlen(buf)], " RTS");
1024
                if (nb) *nb = 2;
1025
                imm_prefix = false;
1026
                return std::string(buf);
1027
 
1028
        case SB:
1029
                b1 = ReadByte(ad);
1030
                ad++;
1031
                b2 = ReadByte(ad);
1032
                ad++;
1033
                b3 = ReadByte(ad);
1034
                ad++;
1035
                Rb = ((b2 & 0xF) << 2) | (( b1 >> 6) & 3);
1036
                str = dRn(b1,b2,b3,&Ra,&Sg,&disp);
1037
                sprintf(&buf[strlen(buf)]," SB r%d,%s", Rb, str.c_str());
1038
                if (nb) *nb = 5;
1039
                imm_prefix = false;
1040
                return std::string(buf);
1041
 
1042 32 robfinch
        case SBX:       return memndx("SBX", ad, nb);
1043
        case SCX:       return memndx("SCX", ad, nb);
1044
        case SHX:       return memndx("SHX", ad, nb);
1045
        case SWX:       return memndx("SWX", ad, nb);
1046
 
1047 30 robfinch
        case SC:
1048
                b1 = ReadByte(ad);
1049
                ad++;
1050
                b2 = ReadByte(ad);
1051
                ad++;
1052
                b3 = ReadByte(ad);
1053
                ad++;
1054
                Rb = ((b2 & 0xF) << 2) | (( b1 >> 6) & 3);
1055
                str = dRn(b1,b2,b3,&Ra,&Sg,&disp);
1056
                sprintf(&buf[strlen(buf)]," SC r%d,%s", Rb, str.c_str());
1057
                if (nb) *nb = 5;
1058
                imm_prefix = false;
1059
                return std::string(buf);
1060
 
1061
        case SH:
1062
                b1 = ReadByte(ad);
1063
                ad++;
1064
                b2 = ReadByte(ad);
1065
                ad++;
1066
                b3 = ReadByte(ad);
1067
                ad++;
1068
                Rb = ((b2 & 0xF) << 2) | (( b1 >> 6) & 3);
1069
                str = dRn(b1,b2,b3,&Ra,&Sg,&disp);
1070
                sprintf(&buf[strlen(buf)]," SH r%d,%s", Rb, str.c_str());
1071
                if (nb) *nb = 5;
1072
                imm_prefix = false;
1073
                return std::string(buf);
1074
 
1075
        case SHIFT:
1076
                b1 = system1.ReadByte(ad);
1077
                ad++;
1078
                b2 = system1.ReadByte(ad);
1079
                ad++;
1080
                b3 = system1.ReadByte(ad);
1081
                ad++;
1082
                Ra = b1 & 0x3f;
1083
                Rb = ((b2 & 0x0f) << 2) | (b1 >> 6);
1084
                Rt = ((b3 & 3) << 4) | (b2 >> 4);
1085
                func = b3 >> 2;
1086
                switch(func) {
1087
                case SHL:
1088
                        sprintf(&buf[strlen(buf)], " SHL r%d,r%d,r%d", Rt, Ra, Rb);
1089
                        break;
1090 32 robfinch
                case SHR:
1091
                        sprintf(&buf[strlen(buf)], " SHR r%d,r%d,r%d", Rt, Ra, Rb);
1092
                        break;
1093
                case SHLU:
1094
                        sprintf(&buf[strlen(buf)], " SHLU r%d,r%d,r%d", Rt, Ra, Rb);
1095
                        break;
1096
                case SHRU:
1097
                        sprintf(&buf[strlen(buf)], " SHRU r%d,r%d,r%d", Rt, Ra, Rb);
1098
                        break;
1099 30 robfinch
                case SHLI:
1100
                        sprintf(&buf[strlen(buf)], " SHLI r%d,r%d,#$%X", Rt, Ra, Rb);
1101
                        break;
1102 32 robfinch
                case SHRI:
1103
                        sprintf(&buf[strlen(buf)], " SHRI r%d,r%d,#$%X", Rt, Ra, Rb);
1104
                        break;
1105
                case SHLUI:
1106
                        sprintf(&buf[strlen(buf)], " SHLUI r%d,r%d,#$%X", Rt, Ra, Rb);
1107
                        break;
1108
                case SHRUI:
1109
                        sprintf(&buf[strlen(buf)], " SHRUI r%d,r%d,#$%X", Rt, Ra, Rb);
1110
                        break;
1111
                case ROL:
1112
                        sprintf(&buf[strlen(buf)], " ROL r%d,r%d,r%d", Rt, Ra, Rb);
1113
                        break;
1114
                case ROR:
1115
                        sprintf(&buf[strlen(buf)], " ROR r%d,r%d,r%d", Rt, Ra, Rb);
1116
                        break;
1117
                case ROLI:
1118
                        sprintf(&buf[strlen(buf)], " ROLI r%d,r%d,#$%X", Rt, Ra, Rb);
1119
                        break;
1120
                case RORI:
1121
                        sprintf(&buf[strlen(buf)], " RORI r%d,r%d,#$%X", Rt, Ra, Rb);
1122
                        break;
1123 30 robfinch
                }
1124
                if (nb) *nb = 5;
1125
                imm_prefix = false;
1126
                return std::string(buf);
1127
 
1128
        case STP:
1129
                b1 = ReadByte(ad);
1130
                ad++;
1131
                b2 = ReadByte(ad);
1132
                ad++;
1133
                sprintf(&buf[strlen(buf)]," STP #$%04X", (int)((b2<<8)|b1));
1134
                if (nb) *nb = 4;
1135
                imm_prefix = false;
1136
                return std::string(buf);
1137
 
1138 32 robfinch
        case STSET:
1139
                b1 = ReadByte(ad);
1140
                ad++;
1141
                b2 = ReadByte(ad);
1142
                ad++;
1143
                b3 = ReadByte(ad);
1144
                ad++;
1145
                Ra = b1 & 0x3f;
1146
                Rb = ((b2 & 0xF) << 2) | (( b1 >> 6) & 3);
1147
                Sg = b3 >> 5;
1148
                switch((b3 >> 2) & 7) {
1149
                case 0: sprintf(&buf[strlen(buf)]," STSET.BI r%d,%s:[r%d]", Rb, SegName(Sg).c_str(), Ra);
1150
                case 1: sprintf(&buf[strlen(buf)]," STSET.CI r%d,%s:[r%d]", Rb, SegName(Sg).c_str(), Ra);
1151
                case 2: sprintf(&buf[strlen(buf)]," STSET.HI r%d,%s:[r%d]", Rb, SegName(Sg).c_str(), Ra);
1152
                case 3: sprintf(&buf[strlen(buf)]," STSET.WI r%d,%s:[r%d]", Rb, SegName(Sg).c_str(), Ra);
1153
                case 4: sprintf(&buf[strlen(buf)]," STSET.BD r%d,%s:[r%d]", Rb, SegName(Sg).c_str(), Ra);
1154
                case 5: sprintf(&buf[strlen(buf)]," STSET.CD r%d,%s:[r%d]", Rb, SegName(Sg).c_str(), Ra);
1155
                case 6: sprintf(&buf[strlen(buf)]," STSET.HD r%d,%s:[r%d]", Rb, SegName(Sg).c_str(), Ra);
1156
                case 7: sprintf(&buf[strlen(buf)]," STSET.WD r%d,%s:[r%d]", Rb, SegName(Sg).c_str(), Ra);
1157
                }
1158
                if (nb) *nb = 5;
1159
                imm_prefix = false;
1160
                return std::string(buf);
1161
 
1162
        case SUBUI:
1163
                b1 = system1.ReadByte(ad);
1164
                ad++;
1165
                b2 = system1.ReadByte(ad);
1166
                ad++;
1167
                b3 = system1.ReadByte(ad);
1168
                ad++;
1169
                Ra = b1 & 0x3f;
1170
                Rt = ((b2 & 0xf) << 2) | (b1 >> 6);
1171
                val = (b3 << 4) | (b2 >> 4);
1172
                sprintf(&buf[strlen(buf)], " SUBUI r%d,r%d,#$%I64X", Rt, Ra, val);
1173
                if (nb) *nb = 5;
1174
                imm_prefix = false;
1175
                return std::string(buf);
1176
 
1177 30 robfinch
        case SW:
1178
                b1 = ReadByte(ad);
1179
                ad++;
1180
                b2 = ReadByte(ad);
1181
                ad++;
1182
                b3 = ReadByte(ad);
1183
                ad++;
1184
                Rb = ((b2 & 0xF) << 2) | (( b1 >> 6) & 3);
1185
                str = dRn(b1,b2,b3,&Ra,&Sg,&disp);
1186
                sprintf(&buf[strlen(buf)]," SW r%d,%s", Rb, str.c_str());
1187
                if (nb) *nb = 5;
1188
                imm_prefix = false;
1189
                return std::string(buf);
1190
 
1191 32 robfinch
        case SWCR:
1192
                b1 = ReadByte(ad);
1193
                ad++;
1194
                b2 = ReadByte(ad);
1195
                ad++;
1196
                b3 = ReadByte(ad);
1197
                ad++;
1198
                Rb = ((b2 & 0xF) << 2) | (( b1 >> 6) & 3);
1199
                str = dRn(b1,b2,b3,&Ra,&Sg,&disp);
1200
                sprintf(&buf[strlen(buf)]," SWCR r%d,%s", Rb, str.c_str());
1201
                if (nb) *nb = 5;
1202
                imm_prefix = false;
1203
                return std::string(buf);
1204
 
1205
        case SWS:
1206
                b1 = ReadByte(ad);
1207
                ad++;
1208
                b2 = ReadByte(ad);
1209
                ad++;
1210
                b3 = ReadByte(ad);
1211
                ad++;
1212
                Rb = ((b2 & 0xF) << 2) | (( b1 >> 6) & 3);
1213
                str = dRn(b1,b2,b3,&Ra,&Sg,&disp);
1214
                sprintf(&buf[strlen(buf)]," SWS %s,%s", SprName(Rb).c_str(), str.c_str());
1215
                if (nb) *nb = 5;
1216
                imm_prefix = false;
1217
                return std::string(buf);
1218
 
1219
        case SYNC:
1220
                sprintf(&buf[strlen(buf)], " SYNC");
1221
                if (nb) *nb = 2;
1222
                imm_prefix = false;
1223
                return std::string(buf);
1224
 
1225
        case SYS:
1226
                b1 = ReadByte(ad);
1227
                ad++;
1228
                b2 = ReadByte(ad);
1229
                ad++;
1230
                Cr = b1 >> 4;
1231
                Ct = b1 & 0xF;
1232
                sprintf(&buf[strlen(buf)], " SYS c%d,c%d,#%X", Ct, Cr, b2);
1233
                if (nb) *nb = 4;
1234
                imm_prefix = false;
1235
                return std::string(buf);
1236
 
1237
        case TLB:
1238
                b1 = ReadByte(ad);
1239
                ad++;
1240
                b2 = ReadByte(ad);
1241
                ad++;
1242
                Tn = b1 >> 4;
1243
                Rt = b2 & 0x3f;
1244
                Ra = Rt;
1245
                str = "TLB";
1246
                switch(b1 & 0xF) {
1247
                case 0:
1248
                        str += "NOP";
1249
                        sprintf(&buf[strlen(buf)]," %s", str.c_str());
1250
                        break;
1251
                case 1:
1252
                        str += "PB";
1253
                        sprintf(&buf[strlen(buf)]," %s r%d", str.c_str(), Ra);
1254
                        break;
1255
                case 2:
1256
                        str += "RD";
1257
                        sprintf(&buf[strlen(buf)]," %s r%d,%s", str.c_str(), Rt, TLBRegName(Tn));
1258
                        break;
1259
                case 3:
1260
                        str += "WR";
1261
                        sprintf(&buf[strlen(buf)]," %s %s,r%d", str.c_str(), TLBRegName(Tn), Rt);
1262
                        break;
1263
                case 4:
1264
                        str += "WI";
1265
                        sprintf(&buf[strlen(buf)]," %s %s,r%d", str.c_str(), TLBRegName(Tn), Rt);
1266
                        break;
1267
                case 5:
1268
                        str += "EN";
1269
                        sprintf(&buf[strlen(buf)]," %s", str.c_str());
1270
                        break;
1271
                case 6:
1272
                        str += "DIS";
1273
                        sprintf(&buf[strlen(buf)]," %s", str.c_str());
1274
                        break;
1275
                default:
1276
                        str += "???";
1277
                        sprintf(&buf[strlen(buf)]," %s", str.c_str());
1278
                        break;
1279
                }
1280
                if (nb) *nb = 4;
1281
                imm_prefix = false;
1282
                return std::string(buf);
1283
 
1284 30 robfinch
        }
1285
        *nb = 1;
1286
        return std::string("");
1287
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.