-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisasm.c
More file actions
1026 lines (828 loc) · 26.1 KB
/
disasm.c
File metadata and controls
1026 lines (828 loc) · 26.1 KB
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
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
void Print_CRI(char** CRInsts, int ThisCRI, uint32_t crbD, uint32_t crbA, uint32_t crbB)
{
printf("%s\t %d, %d, %d\n", CRInsts[ThisCRI], crbD, crbA, crbB);
return;
}
void Print7C_Form1(char** SevC_Insts, int Inst, uint32_t Rc, uint32_t rB, uint32_t rA, uint32_t rS)
{
printf("%s%s%d, r%d, r%d\n", SevC_Insts[Inst], Rc == 1? ".\t r" : "\t r", rA, rS, rB);
return;
}
void Print7C_IndexedLS(char* IndexedLS, int Float, int B31, uint32_t rS, uint32_t rA, uint32_t rB)
{
if (B31 == 0) {
printf("%sx\t %c%d, r%d, r%d\n", IndexedLS, Float == 1? 'f' : 'r', rS, rA, rB);
} else printf("(unk)\n");
return;
}
void Print7C_Math(char* Inst, char** MathModes, int Mode, uint32_t rD, uint32_t rA, uint32_t rB)
{
printf("%s%s\t r%d, r%d, r%d\n", Inst, MathModes[Mode], rD, rA, rB);
return;
}
void Print7C_DCache(char** CacheInsts, int This_Inst, uint32_t rA, uint32_t rB, int B6_5, int B31)
{
if (B6_5 == 0 && B31 == 0) {
printf("dcb");
printf("%s\t r%d, r%d\n", CacheInsts[This_Inst], rA, rB);
} else printf("(unk)\n");
return;
}
void Print_FCMP(char FCType, uint8_t crfD, uint32_t frA, uint32_t frB, uint8_t B9, uint8_t B31)
{
if (B9 == 0 && B31 == 0) {
printf("fcmp%c\t cr%d, f%d, f%d\n", FCType, crfD, frA, frB);
} else printf("(unk)\n");
return;
}
void Parse_MSPR(char Direction, uint32_t Split, uint32_t rD)
{
switch(Split)
{
case 1:
printf("m%cxer\t r%d", Direction, rD);
break;
case 8:
printf("m%clr\t r%d", Direction, rD);
break;
case 9:
printf("m%cctr\t r%d", Direction, rD);
break;
case 19:
printf("m%cdar\t r%d", Direction, rD);
break;
default:
printf("m%cspr\t r%d, ", Direction, rD);
if (Split >= 1020 && Split <= 1022) {
printf("THRM%d", Split - 1020);
} else if (Split >= 912 && Split <= 919) {
printf("GQR%d", Split - 912);
} else if (Split >= 272 && Split <= 275) {
printf("SPRG%d", Split - 272);
} else printf("%d", Split);
break;
}
printf("\n");
return;
}
void Print_FCat1(char* FCat1, uint32_t frD, uint32_t frA, uint32_t frB, uint32_t B21_5, int Rc)
{
if (B21_5 == 0) {
printf("%s%s%d, f%d, f%d\n", FCat1, Rc == 1? ".\t f" : "\t f", frD, frA, frB);
} else printf("(unk)\n");
return;
}
void Print_PS0(uint32_t B6_5, uint32_t B11_5, uint8_t W, uint32_t I, uint32_t D, char* Inst)
{
printf("ps%s\t f%d%s%X (r%d), %d, %d\n", Inst, B6_5, D >= 0x800? ", -0x" : ", 0x", D >= 0x800? 0x1000 - D : D, B11_5, W, I);
return;
}
void Print_PS1(char* Inst, uint32_t D, uint32_t A, uint8_t B, uint32_t C, uint32_t Rc)
{
printf("ps_%s%c f%d, f%d, f%d, f%d\n", Inst, Rc == 1? '.' : '\0', D, A, C, B);
return;
}
void DisASM(uint32_t Inst, uint32_t Inj_Addr)
{
static char *LDST[] = {
"lwz","lwzu","lbz","lbzu","stw","stwu","stb","stbu","lhz","lhzu",
"lha","lhau","sth","sthu","lmw","stmw","lfs","lfsu","lfd","lfdu",
"stfs","stfsu","stfd","stfdu"
},
*Bitwise_6[] = { "ori","oris","xori","xoris","andi.","andis." },
*Types[] = { "\0","l","a","la" },
*Basic_Imms[] = { "ic","ic.","i","is" },
*MathModes[] = { "\0",".","o","o." },
*CMS[] = { "pl","p" },
*SevC_Insts[] = {
"slw","and","andc","eqv","eciwx","xor","orc","ecowx","or",
"nand","srw","sraw","nor"
},
*CRInsts[] = {
"crnor","crandc","crxor","crnand","crand","creqv",
"crorc","cror"
},
*IndexedLS[] = {
"lwar","lsw","lwbr","stsw","stwbr","lhbr","sthbr","stfiw"
},
*FCat1[] = { "fdiv","fsub","fadd","fdivs","fsubs","fadds" },
*CondSet1[] = { "ge","le","ne","ns" },
*CondSet2[] = { "lt","gt","eq","so" },
*DCache_Insts[] = { "st","f","tst","t","i","z","z_l" };
char GPR = 'r',
FPR = 'f';
// Valor global reutilizável
uint32_t FLG = 0;
// Valor do Opcode
uint8_t OP = Inst >> 26,
// Especificar um campo dos registradores CR/FPSCR como destino
crfD = (Inst << 6) >> 29,
// Formato: BX_Y (X = slot inicial, Y = número de bits)
/* Esse campo: BO (configura Branches condicionais)
crbD (especifica bit dos CR/FPSCR a ser usado como destino do resultado)
frD (especifica FPR (Floating Point Register) de destino)
frS (especifica FPR de fonte)
rD (especifica GPR (General Purpose Register) de destino)
rS (especifica GPR de fonte)
TO (para instruções Trap; sob quais condições executá-las) */
B6_5 = (Inst << 6) >> 27;
// "Mask" de campo usada para identificar campos do FPSCR (Floating-point Status and Control Register) que serão atualizados pela instrução mtfsf
uint32_t FM = (Inst << 7) >> 24;
/* "Immediate field specifying a 24-bit signed two's complement integer that is concatenated on the right with 0b00 and sign-extended to 32 bits"
"Campo imediato que especifica um inteiro complementar de dois bits assinado de 24 bits que é concatenado à direita com 0b00 e estendido por sinal para 32 bits"
Isso aqui nem faz sentido, então pode estar errado */
uint32_t LI = (Inst << 8) >> 8;
// Campo usado por instruções de comparação
uint8_t B9 = (Inst << 9) >> 31;
// Não está descrito no manual do Usuário, “Deve ser definido como 0 para a arquitetura de subconjunto de 32 bits”, de acordo com o site da IBM
uint32_t L = (Inst << 10) >> 31,
// Especifica um dos campos do CR/FPSCR como uma fonte
crfS = (Inst << 12) >> 29,
/* Este campo:
BI (configura Branches condicionais)
crbA (especifica bit do CR usado como fonte)
frA (usado para especificar FPR de origem)
rA (usado para especificar GPR como origem ou destino) */
B11_5 = (Inst << 11) >> 27;
// SPR (registradores especiais), TBL/TBU (time base upper/lower, medidores de tempo)
uint32_t Split = ((Inst << 11) >> 27) | (((Inst << 16) >> 27) << 5);
// Especifica um dos 16 "segment registers"
uint8_t SR = (Inst << 13) >> 28;
// Especifica os campos do CR que serão atualizados pela instrução mtcrf
uint32_t CRM = (Inst << 13) >> 24,
// Campo transferido para um dos campos do FPSCR
IMM = (Inst << 16) >> 28,
/* Este campo:
crbB (usado para especificar o bit do CR para uso como origem)
frB (especifica o FPR de origem)
NB (especifica o número de bytes a serem movidos em um load/store de string)
rB (especifica o GPR de origem)
SH (especifica o valor do shift (deslocamento) */
B16_5 = (Inst << 16) >> 27;
/* Este campo:
SIMM (signed int de 16 bits) e UIMM (unsigned int de 16 bits)
Inteiro complementar de dois sinais que é estendido para 32 bits */
int32_t B16_16 = (Inst << 16) >> 16,
LIS_B16_16 = B16_16;
// Um dos campos das Paired Singles
uint8_t W = (Inst << 16) >> 31;
// "I field 1" (especifica o registador GQR (quantização) usado por load/store com as Paired Singles)
uint8_t B17_3 = (Inst << 17) >> 29;
// "Extended opcode field 1" (campo de opcode estendido)
uint32_t XO1 = (Inst << 21) >> 22,
// Offset das Paired Singles
D = (Inst << 20) >> 20;
// frC (FPR Origem) e MB (Mask de instruções de rotation)
uint8_t B21_5 = (Inst << 21) >> 27,
// Pra instruções de aritmética da categoria 0x7C
OE = (Inst << 21) >> 31;
// "Extended opcode field 2"
uint32_t XO2 = (Inst << 22) >> 23,
// Terminação da mask (para instruções de rotate left)
B26_5 = (Inst << 26) >> 27;
// Bit que especifica endereços absolutos pra branches
uint8_t AA = (Inst << 30) >> 31,
// LK pra branches, Rc (record bit) pra algumas outras instruções
B31 = (Inst << 31) >> 31;
// Definição do tipo de Branch
uint32_t BLK = 0;
if (AA == 1 && B31 == 1) { BLK = 3; }
if (AA == 1 && B31 == 0) { BLK = 2; }
if (AA == 0 && B31 == 1) { BLK = 1; }
// Instruções conhecidas como ilegais
if (OP == 1 || OP == 2 || OP == 5 || OP == 6 || OP == 9 || OP == 22 || OP == 30 || OP == 58 || OP == 62) {
printf("opcode ilegal\n");
return;
}
if (OP == 3) {
printf("twi %d, r%d%s%d\n", B6_5, B11_5, B16_16 >= 0x8000? ", -" : ", \0", B16_16 >= 0x8000? (0x10000 - B16_16) : B16_16);
return;
}
if (OP == 4) {
if (B6_5 == 0 && XO1 == 1014 && B31 == 0) {
Print7C_DCache(DCache_Insts, 6, B11_5, B16_5, B6_5, B31);
return;
}
switch(B26_5) {
case 10:
Print_PS1("sum0", B6_5, B11_5, B16_5, B21_5, B31);
return;
case 11:
Print_PS1("sum1", B6_5, B11_5, B16_5, B21_5, B31);
return;
case 12:
if (B16_5 == 0) {
printf("ps_muls0%c\t f%d, f%d, f%d\n", B31 == 1? '.' : '\0', B6_5, B11_5, B21_5);
return;
}
case 13:
if (B16_5 == 0) {
printf("ps_muls1%c\t f%d, f%d, f%d\n", B31 == 1? '.' : '\0', B6_5, B11_5, B21_5);
return;
}
case 14:
Print_PS1("madds0", B6_5, B11_5, B16_5, B21_5, B31);
return;
case 15:
Print_PS1("madds1", B6_5, B11_5, B16_5, B21_5, B31);
return;
case 20:
if (B21_5 == 0) {
printf("ps_sub%c\t f%d, f%d, f%d\n", B31 == 1? '.' : '\0', B6_5, B11_5, B16_5);
return;
}
case 21:
if (B21_5 == 0) {
printf("ps_add%c\t f%d, f%d, f%d\n", B31 == 1? '.' : '\0', B6_5, B11_5, B16_5);
return;
case 23:
Print_PS1("sel", B6_5, B11_5, B16_5, B21_5, B31);
return;
case 25:
if (B16_5 == 0) {
printf("ps_mul%c\t f%d, f%d, f%d\n", B31 == 1? '.' : '\0', B6_5, B11_5, B21_5);
return;
}
case 28:
Print_PS1("msub", B6_5, B11_5, B16_5, B21_5, B31);
return;
case 29:
Print_PS1("madd", B6_5, B11_5, B16_5, B21_5, B31);
return;
case 30:
Print_PS1("nmsub", B6_5, B11_5, B16_5, B21_5, B31);
return;
case 31:
Print_PS1("nmadd", B6_5, B11_5, B16_5, B21_5, B31);
return;
}
}
switch(XO1) {
case 624:
printf("ps_merge11%c\t f%d, f%d, f%d\n", B31 == 1? '.' : '\0', B6_5, B11_5, B16_5);
return;
case 592:
printf("ps_merge10%c\t f%d, f%d, f%d\n", B31 == 1? '.' : '\0', B6_5, B11_5, B16_5);
return;
case 560:
printf("ps_merge01%c\t f%d, f%d, f%d\n", B31 == 1? '.' : '\0', B6_5, B11_5, B16_5);
return;
case 528:
printf("ps_merge00%c\t f%d, f%d, f%d\n", B31 == 1? '.' : '\0', B6_5, B11_5, B16_5);
return;
case 264:
if (B11_5 == 0) {
printf("ps_abs%c\t f%d, f%d\n", B31 == 1? '.' : '\0', B6_5, B16_5);
return;
}
case 136:
if (B11_5 == 0) {
printf("ps_nabs%c\t f%d, f%d\n", B31 == 1? '.' : '\0', B6_5, B16_5);
return;
}
case 72:
if (B11_5 == 0) {
printf("ps_mr%c\t f%d, f%d\n", B31 == 1? '.' : '\0', B6_5, B16_5);
return;
}
case 40:
if (B11_5 == 0) {
printf("ps_neg%c\t f%d, f%d\n", B31 == 1? '.' : '\0', B6_5, B16_5);
return;
}
}
}
if (OP == 7) {
printf("mulli\t r%d, r%d%s0x%X\n", B6_5, B11_5, B16_16 >= 0x8000? ", -" : ", \0", B16_16 >= 0x8000? (0x10000 - B16_16) : B16_16);
return;
}
if (OP == 8) {
printf("subfic\t r%d, r%d%s%d\n", B6_5, B11_5, B16_16 >= 0x8000? ", -" : ", \0", B16_16 >= 0x8000? (0x10000 - B16_16) : B16_16);
return;
}
// cmpi/cmpli
if (OP == 10 || OP == 11) {
if (B16_16 >= 0x8000 && OP == 11) { FLG = 0x10000 - B16_16; } else FLG = B16_16;
if (B9 == 0) {
printf("cm%s%ci\t cr%d, r%d%s0x%X\n", CMS[OP - 10], L == 1? 'd' : 'w', crfD, B11_5, B16_16 >= 0x8000 && OP == 11? ", -" : ", \0", FLG);
return;
}
}
if (Inst == 0x44000002) { printf("sc\n");
return;
}
//Adicionar/subtrair immediate
if (OP >= 12 && OP <= 15) {
// B16_16 = Immediate, B6_5 = Destino, B11_5 = Origem
char *This_Imm[] = { "sub", "add" };
int ImmID = OP - 12;
if (B16_16 >= 0x8000) { B16_16 = 0x10000 - B16_16;
} else FLG = 1;
if (OP == 14 && B11_5 == 0) { printf("li\t r%d%s%d\n", B6_5, FLG == 0? ", -" : ", \0", B16_16);
} else if (OP == 15 && B11_5 == 0) { printf("lis\t r%d, 0x%04X\n", B6_5, LIS_B16_16);
} else printf("%s%s\t r%d, r%d, 0x%X\n", This_Imm[FLG], Basic_Imms[ImmID], B6_5, B11_5, B16_16);
return;
}
// Branches condicionais (incompleto)
if (OP == 16) {
uint32_t Target = B16_16 >= 0x8000? (Inj_Addr - (0x10000 - B16_16)) : (Inj_Addr + B16_16);
// Pra tipos absolutos
if (BLK >= 2) { Target = B16_16 >= 0x8000? (0xFFFF0000 + B16_16) : B16_16; }
uint32_t Cond = B11_5 - (4 * (B11_5 / 4));
if (B6_5 == 4 || B6_5 == 12) {
if (B11_5 / 4 == 0) {
printf("b%s%s\t 0x%X\n", B6_5 == 4? CondSet1[Cond] : CondSet2[Cond], Types[BLK], Target - BLK);
} else printf("b%s%s\t cr%d ->0x%X\n", B6_5 == 4? CondSet1[Cond] : CondSet2[Cond], Types[BLK], B11_5 / 4, Target - BLK);
return;
}
printf("bc%s\t %d, %d ->0x%X\n", Types[BLK], B6_5, B11_5, Target - BLK);
return;
}
// Branches não condicionais
if (OP == 18) {
// B31 = LK, LI = Endereço
// Usando isso aqui pra identificar a direção de retorno por enquanto, mas pode ser diferente (não descrito na tabela 12.1.2/12.2 do manual do chip 750CL)
int BW = (Inst << 5) >> 30;
uint32_t Relative_Addr;
if (BW == 0) { Relative_Addr = Inj_Addr + (LI - BLK);
} else Relative_Addr = Inj_Addr - ((0x1000000 - LI) + BLK);
printf("b%s\t 0x%X\n", Types[BLK], BLK <= 1? Relative_Addr : BW == 1? (LI - BLK) + 0xFF000000 : (LI - BLK));
return;
}
if (Inst == 0x4C000064) { printf("rfi\n");
return;
}
if (Inst == 0x4C00012C) { printf("isync\n");
return;
}
// solução temporária
if (Inst == 0x4E800020) { printf("blr\n\n");
return;
}
// solução temporária
if (Inst == 0x4E800021) { printf("blrl\n");
return;
}
// solução temporária
if (Inst == 0x4E800420) { printf("bctr\n\n");
return;
}
// solução temporária
if (Inst == 0x4E800421) { printf("bctrl\n\n");
return;
}
if (OP == 19 && B31 == 0) {
switch(XO1) {
case 33:
Print_CRI(CRInsts, 0, B6_5, B11_5, B16_5);
return;
case 129:
Print_CRI(CRInsts, 1, B6_5, B11_5, B16_5);
return;
case 193:
if (B11_5 == B16_5) {
printf("crclr\t %d, %d\n", B6_5, B11_5);
return;
} else Print_CRI(CRInsts, 2, B6_5, B11_5, B16_5);
return;
case 225:
Print_CRI(CRInsts, 3, B6_5, B11_5, B16_5);
return;
case 257:
Print_CRI(CRInsts, 4, B6_5, B11_5, B16_5);
return;
case 289:
Print_CRI(CRInsts, 5, B6_5, B11_5, B16_5);
return;
case 417:
Print_CRI(CRInsts, 6, B6_5, B11_5, B16_5);
return;
case 449:
Print_CRI(CRInsts, 7, B6_5, B11_5, B16_5);
return;
}
}
if (OP == 20 || OP == 21)
{
char *RLWInsts[] = { "rlwimi", "rlwinm" };
printf("%s%s%d, r%d, %d, %d, %d\n", RLWInsts[OP - 20], B31 == 1? ".\t r" : "\t r", B11_5, B6_5, B16_5, B21_5, B26_5);
return;
}
// 6 operações lógicas
if (OP >= 24 && OP <= 29) {
// B11_5 = Destino, B6_5 = Origem, B16_16 = Immediate
int BT_ID = OP - 24;
if (Inst == 0x60000000) { printf("nop\n"); }
else printf("%s\t r%d, r%d, 0x%X\n", Bitwise_6[BT_ID], B11_5, B6_5, B16_16);
return;
}
if (Inst == 0x7C00046C) { printf("tlbsync\n");
return;
}
if (Inst == 0x7C0004AC) { printf("sync\n");
return;
}
if (Inst == 0x7C0006AC) { printf("eieio\n");
return;
}
// De fato a categoria 0x7C inteira
if (OP == 31) {
// Determinar o modo matemático para instruções que usam OE
if (OE == 0 && B31 == 1) { FLG = 1; }
if (OE == 1 && B31 == 0) { FLG = 2; }
if (OE == 1 && B31 == 1) { FLG = 3; }
switch(XO2)
{
case 8:
Print7C_Math("subc", MathModes, FLG, B6_5, B16_5, B11_5);
return;
case 10:
Print7C_Math("addc", MathModes, FLG, B6_5, B16_5, B11_5);
return;
case 11:
if (OE == 0) {
Print7C_Math("mulhwu", MathModes, FLG, B6_5, B11_5, B16_5);
return;
} break;
case 40:
Print7C_Math("sub", MathModes, FLG, B6_5, B11_5, B16_5);
return;
case 75:
// Não usa OE?
if (OE == 0) {
Print7C_Math("mulhw", MathModes, FLG, B6_5, B11_5, B16_5);
return;
} break;
case 104:
if (B16_5 == 0) {
printf("neg%s\t r%d, r%d\n", MathModes[FLG], B6_5, B11_5);
return;
}
case 136:
Print7C_Math("subfe", MathModes, FLG, B6_5, B11_5, B16_5);
return;
case 138:
Print7C_Math("adde", MathModes, FLG, B6_5, B11_5, B16_5);
return;
case 235:
Print7C_Math("mulhw", MathModes, FLG, B6_5, B11_5, B16_5);
return;
case 266:
Print7C_Math("add", MathModes, FLG, B6_5, B11_5, B16_5);
return;
case 459:
Print7C_Math("divwu", MathModes, FLG, B6_5, B11_5, B16_5);
return;
case 491:
Print7C_Math("divw", MathModes, FLG, B6_5, B11_5, B16_5);
return;
}
switch(XO1)
{
// dcbz
case 1014:
Print7C_DCache(DCache_Insts, 5, B11_5, B16_5, B6_5, B31);
return;
case 954:
if (B16_5 == 0) {
printf("extsb%c\t r%d, r%d\n", B31 == 1? '.' : '\0', B11_5, B6_5);
return;
} break;
case 922:
if (B16_5 == 0) {
printf("extsh%c\t r%d, r%d\n", B31 == 1? '.' : '\0', B11_5, B6_5);
return;
} break;
// sthbrx
case 918:
Print7C_IndexedLS(IndexedLS[6], 0, B31, B6_5, B11_5, B16_5);
return;
case 824:
printf("srawi%c\t r%d, r%d, %d\n", B31 == 1? '.' : ' ', B6_5, B11_5, B16_5);
return;
// sraw
case 792:
Print7C_Form1(SevC_Insts, 11, B31, B16_5, B11_5, B6_5);
return;
// lhbrx
case 790:
Print7C_IndexedLS(IndexedLS[5], 0, B31, B6_5, B11_5, B16_5);
return;
// stfsux
case 695:
Print7C_IndexedLS(LDST[21], 1, B31, B6_5, B11_5, B16_5);
return;
// stfsx
case 663:
Print7C_IndexedLS(LDST[20], 1, B31, B6_5, B11_5, B16_5);
return;
// stwbrx
case 662:
Print7C_IndexedLS(IndexedLS[4], 0, B31, B6_5, B11_5, B16_5);
return;
// stswx
case 661:
Print7C_IndexedLS(IndexedLS[3], 0, B31, B6_5, B11_5, B16_5);
return;
// lfdux
case 631:
Print7C_IndexedLS(LDST[19], 1, B31, B6_5, B11_5, B16_5);
return;
// lfdx
case 599:
Print7C_IndexedLS(LDST[18], 1, B31, B6_5, B11_5, B16_5);
return;
case 597:
if (B31 == 0) {
printf("lswi\t r%d, r%d, %d\n", B6_5, B11_5, B16_5);
return;
} break;
// lfsux
case 567:
Print7C_IndexedLS(LDST[17], 1, B31, B6_5, B11_5, B16_5);
return;
// srw
case 536:
Print7C_Form1(SevC_Insts, 10, B31, B16_5, B11_5, B6_5);
return;
// lfsx
case 535:
Print7C_IndexedLS(LDST[16], 1, B31, B6_5, B11_5, B16_5);
return;
// lwbrx
case 534:
Print7C_IndexedLS(IndexedLS[2], 0, B31, B6_5, B11_5, B16_5);
return;
// nand
case 476:
Print7C_Form1(SevC_Insts, 9, B31, B16_5, B11_5, B6_5);
return;
// dcbi
case 470:
Print7C_DCache(DCache_Insts, 4, B11_5, B16_5, B6_5, B31);
return;
// mtspr
case 467:
if (B31 == 0) { Parse_MSPR('t', Split, B6_5);
return;
} break;
// or + mr
case 444:
if (B6_5 == B16_5) {
printf("mr%s%d, r%d\n", B31 == 1? ".\t r" : "\t r", B11_5, B6_5);
} else Print7C_Form1(SevC_Insts, 8, B31, B16_5, B11_5, B6_5);
return;
// sthux
case 439:
Print7C_IndexedLS(LDST[13], 0, B31, B6_5, B11_5, B16_5);
return;
// ecowx
case 438:
if (B31 == 0) {
Print7C_Form1(SevC_Insts, 7, B31, B16_5, B6_5, B11_5);
return;
} break;
// orc
case 412:
Print7C_Form1(SevC_Insts, 6, B31, B16_5, B11_5, B6_5);
return;
// sthx
case 407:
Print7C_IndexedLS(LDST[12], 0, B31, B6_5, B11_5, B16_5);
return;
// lhaux
case 375:
Print7C_IndexedLS(LDST[11], 0, B31, B6_5, B11_5, B16_5);
return;
case 371:
if (B31 == 0) {
if (Split == 268 || Split == 269) {
printf("mftb%c\t r%d\n", Split == 268? 'l' : 'u', B6_5);
return;
}
} break;
// lhax
case 343:
Print7C_IndexedLS(LDST[10], 0, B31, B6_5, B11_5, B16_5);
return;
// mfspr
case 339:
if (B31 == 0) { Parse_MSPR('f', Split, B6_5);
return;
} break;
// xor
case 316:
Print7C_Form1(SevC_Insts, 5, B31, B16_5, B11_5, B6_5);
return;
// lhzux
case 311:
Print7C_IndexedLS(LDST[9], 0, B31, B6_5, B11_5, B16_5);
return;
// eciwx
case 310:
if (B31 == 0) {
Print7C_Form1(SevC_Insts, 4, B31, B16_5, B6_5, B11_5);
return;
} break;
// tlbie
case 306:
if (B6_5 == 0 && B11_5 == 0 && B31 == 0) {
printf("tlbie\t r%d\n", B16_5);
return;
} break;
// eqv
case 284:
Print7C_Form1(SevC_Insts, 3, B31, B16_5, B11_5, B6_5);
return;
// lhzx
case 279:
Print7C_IndexedLS(LDST[8], 0, B31, B6_5, B11_5, B16_5);
return;
// dcbt
case 278:
Print7C_DCache(DCache_Insts, 3, B11_5, B16_5, B6_5, B31);
return;
// stbux
case 247:
Print7C_IndexedLS(LDST[7], 0, B31, B6_5, B11_5, B16_5);
return;
// dcbtst
case 246:
Print7C_DCache(DCache_Insts, 2, B11_5, B16_5, B6_5, B31);
return;
// mtsrin
case 242:
if (B11_5 == 0 && B31 == 0) { printf("mtsrin\t r%d, r%d\n", B6_5, B16_5);
return;
} break;
// stbx
case 215:
Print7C_IndexedLS(LDST[6], 0, B31, B6_5, B11_5, B16_5);
return;
// stwux
case 183:
Print7C_IndexedLS(LDST[5], 0, B31, B6_5, B11_5, B16_5);
return;
// stwx
case 151:
Print7C_IndexedLS(LDST[4], 0, B31, B6_5, B11_5, B16_5);
return;
// stwcx.
case 150:
if (B31 == 1) {
printf("stwcx.\t r%d, r%d, r%d\n", B6_5, B11_5, B16_5);
return;
} break;
// nor/not
case 124:
if (B6_5 == B16_5) {
printf("not%s%d, r%d\n", B31 == 1? ".\t r" : "\t r", B6_5, B16_5);
} else Print7C_Form1(SevC_Insts, 12, B31, B16_5, B11_5, B6_5);
return;
// lbzux
case 119:
Print7C_IndexedLS(LDST[3], 0, B31, B6_5, B11_5, B16_5);
return;
// lbzx
case 87:
Print7C_IndexedLS(LDST[2], 0, B31, B6_5, B11_5, B16_5);
return;
// dcbf
case 86:
Print7C_DCache(DCache_Insts, 1, B11_5, B16_5, B6_5, B31);
return;
// andc
case 60:
Print7C_Form1(SevC_Insts, 2, B31, B16_5, B11_5, B6_5);
return;
// lwzux
case 55:
Print7C_IndexedLS(LDST[1], 0, B31, B6_5, B11_5, B16_5);
return;
// dcbst
case 54:
Print7C_DCache(DCache_Insts, 0, B11_5, B16_5, B6_5, B31);
return;
case 32:
if (B9 == 0 && B31 == 0) { printf("cmpl%c\t cr%d, r%d, r%d\n", L == 1? 'd' : 'w', crfD, B11_5, B16_5);
return;
} break;
// and
case 28:
Print7C_Form1(SevC_Insts, 1, B31, B16_5, B11_5, B6_5);
return;
case 26:
if (B16_5 == 0) {
printf("cntlzw%c\t r%d, r%d\n", B31 == 1? '.' : '\0', B6_5, B11_5);
return;
} break;
// slw
case 24:
Print7C_Form1(SevC_Insts, 0, B31, B16_5, B11_5, B6_5);
return;
// lwzx
case 23:
Print7C_IndexedLS(LDST[0], 0, B31, B6_5, B11_5, B16_5);
return;
// lwarx
case 20:
Print7C_IndexedLS(IndexedLS[0], 0, B31, B6_5, B11_5, B16_5);
return;
case 0:
if (B9 == 0 && B31 == 0) { printf("cmp%c\t cr%d, r%d, r%d\n", L == 1? 'd' : 'w', crfD, B11_5, B16_5);
return;
} break;
}
}
// load & store
if (OP >= 32 && OP <= 55) {
// B6_5 = Destino, B16_16 = Offset, B11_5 = Origem
if (OP >= 48) { GPR = FPR; }
int LS_ID = OP - 32;
printf("%s\t %c%d, %sx%X (r%d)\n", LDST[LS_ID], GPR, B6_5, B16_16 >= 0x8000? "-0" : "0", B16_16 >= 0x8000? (0x10000 - B16_16) : B16_16, B11_5);
return;
}
if (OP == 56) {
Print_PS0(B6_5, B11_5, W, B17_3, D, "q_l");
return;
}
if (OP == 57) {
Print_PS0(B6_5, B11_5, W, B17_3, D, "q_lu");
return;
}
// Instruções aritméticas de floating point 1
if (OP == 59) {
switch(B26_5)
{
// fdivs
case 18:
Print_FCat1(FCat1[3], B6_5, B11_5, B16_5, B21_5, B31);
return;
// fsubs
case 20:
Print_FCat1(FCat1[4], B6_5, B11_5, B16_5, B21_5, B31);
return;
// fadds
case 21:
Print_FCat1(FCat1[5], B6_5, B11_5, B16_5, B21_5, B31);
return;
case 25:
if (B16_5 == 0) {
printf("fmuls%c\t f%d, f%d, f%d\n", B31 == 1? '.' : '\0', B6_5, B11_5, B21_5);
return;
}
}
}
if (OP == 60) {
Print_PS0(B6_5, B11_5, W, B17_3, D, "q_st");
return;
}
if (OP == 61) {
Print_PS0(B6_5, B11_5, W, B17_3, D, "q_stu");
return;
}
if (OP == 63) {
if (B21_5 == 0 && B26_5 == 20) {
printf("fsub%c\t f%d, f%d, f%d\n", B31 == 1? '.' : '\0', B6_5, B11_5, B16_5);
return;
}
if (B16_5 == 0 && B26_5 == 25) {
printf("fmul%c\t f%d, f%d, f%d\n", B31 == 1? '.' : '\0', B6_5, B11_5, B21_5);
return;
}
if (B11_5 == 0 && B21_5 == 0 && B26_5 == 26) {
printf("frsqrte%c\t f%d, f%d\n", B31 == 1? '.' : '\0', B6_5, B16_5);
return;
}
if (XO1 == 0) {
Print_FCMP('u', crfD, B11_5, B16_5, B9, B31);
return;
}
if (XO1 == 12 && B11_5 == 0) {
printf("frsp%c\t f%d, f%d\n", B31 == 1? '.' : '\0', B6_5, B16_5);
return;