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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
|
/*
* Renesas RX Disassembler
*
* Copyright (c) 2019 Yoshinori Sato <ysato@users.sourceforge.jp>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2 or later, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "qemu/osdep.h"
#include "disas/dis-asm.h"
#include "qemu/bitops.h"
#include "cpu.h"
typedef struct DisasContext {
disassemble_info *dis;
uint32_t addr;
uint32_t pc;
uint8_t len;
uint8_t bytes[8];
} DisasContext;
static uint32_t decode_load_bytes(DisasContext *ctx, uint32_t insn,
int i, int n)
{
uint32_t addr = ctx->addr;
g_assert(ctx->len == i);
g_assert(n <= ARRAY_SIZE(ctx->bytes));
while (++i <= n) {
ctx->dis->read_memory_func(addr++, &ctx->bytes[i - 1], 1, ctx->dis);
insn |= ctx->bytes[i - 1] << (32 - i * 8);
}
ctx->addr = addr;
ctx->len = n;
return insn;
}
static int32_t li(DisasContext *ctx, int sz)
{
uint32_t addr = ctx->addr;
uintptr_t len = ctx->len;
switch (sz) {
case 1:
g_assert(len + 1 <= ARRAY_SIZE(ctx->bytes));
ctx->addr += 1;
ctx->len += 1;
ctx->dis->read_memory_func(addr, ctx->bytes + len, 1, ctx->dis);
return (int8_t)ctx->bytes[len];
case 2:
g_assert(len + 2 <= ARRAY_SIZE(ctx->bytes));
ctx->addr += 2;
ctx->len += 2;
ctx->dis->read_memory_func(addr, ctx->bytes + len, 2, ctx->dis);
return ldsw_le_p(ctx->bytes + len);
case 3:
g_assert(len + 3 <= ARRAY_SIZE(ctx->bytes));
ctx->addr += 3;
ctx->len += 3;
ctx->dis->read_memory_func(addr, ctx->bytes + len, 3, ctx->dis);
return (int8_t)ctx->bytes[len + 2] << 16 | lduw_le_p(ctx->bytes + len);
case 0:
g_assert(len + 4 <= ARRAY_SIZE(ctx->bytes));
ctx->addr += 4;
ctx->len += 4;
ctx->dis->read_memory_func(addr, ctx->bytes + len, 4, ctx->dis);
return ldl_le_p(ctx->bytes + len);
default:
g_assert_not_reached();
}
}
static int bdsp_s(DisasContext *ctx, int d)
{
/*
* 0 -> 8
* 1 -> 9
* 2 -> 10
* 3 -> 3
* :
* 7 -> 7
*/
if (d < 3) {
d += 8;
}
return d;
}
/* Include the auto-generated decoder. */
#include "decode.c.inc"
static void dump_bytes(DisasContext *ctx)
{
int i, len = ctx->len;
for (i = 0; i < len; ++i) {
ctx->dis->fprintf_func(ctx->dis->stream, "%02x ", ctx->bytes[i]);
}
ctx->dis->fprintf_func(ctx->dis->stream, "%*c", (8 - i) * 3, '\t');
}
#define prt(...) \
do { \
dump_bytes(ctx); \
ctx->dis->fprintf_func(ctx->dis->stream, __VA_ARGS__); \
} while (0)
#define RX_MEMORY_BYTE 0
#define RX_MEMORY_WORD 1
#define RX_MEMORY_LONG 2
#define RX_IM_BYTE 0
#define RX_IM_WORD 1
#define RX_IM_LONG 2
#define RX_IM_UWORD 3
static const char size[] = {'b', 'w', 'l'};
static const char cond[][4] = {
"eq", "ne", "c", "nc", "gtu", "leu", "pz", "n",
"ge", "lt", "gt", "le", "o", "no", "ra", "f"
};
static const char psw[] = {
'c', 'z', 's', 'o', 0, 0, 0, 0,
'i', 'u', 0, 0, 0, 0, 0, 0,
};
static void rx_index_addr(DisasContext *ctx, char out[8], int ld, int mi)
{
uint32_t addr = ctx->addr;
uintptr_t len = ctx->len;
uint16_t dsp;
switch (ld) {
case 0:
/* No index; return empty string. */
out[0] = '\0';
return;
case 1:
g_assert(len + 1 <= ARRAY_SIZE(ctx->bytes));
ctx->addr += 1;
ctx->len += 1;
ctx->dis->read_memory_func(addr, ctx->bytes + len, 1, ctx->dis);
dsp = ctx->bytes[len];
break;
case 2:
g_assert(len + 2 <= ARRAY_SIZE(ctx->bytes));
ctx->addr += 2;
ctx->len += 2;
ctx->dis->read_memory_func(addr, ctx->bytes + len, 2, ctx->dis);
dsp = lduw_le_p(ctx->bytes + len);
break;
default:
g_assert_not_reached();
}
sprintf(out, "%u", dsp << (mi < 3 ? mi : 4 - mi));
}
static void prt_ldmi(DisasContext *ctx, const char *insn,
int ld, int mi, int rs, int rd)
{
static const char sizes[][4] = {".b", ".w", ".l", ".uw", ".ub"};
char dsp[8];
if (ld < 3) {
rx_index_addr(ctx, dsp, ld, mi);
prt("%s\t%s[r%d]%s, r%d", insn, dsp, rs, sizes[mi], rd);
} else {
prt("%s\tr%d, r%d", insn, rs, rd);
}
}
static void prt_ir(DisasContext *ctx, const char *insn, int imm, int rd)
{
if (imm < 0x100) {
prt("%s\t#%d, r%d", insn, imm, rd);
} else {
prt("%s\t#0x%08x, r%d", insn, imm, rd);
}
}
/* mov.[bwl] rs,dsp:[rd] */
static bool trans_MOV_rm(DisasContext *ctx, arg_MOV_rm *a)
{
if (a->dsp > 0) {
prt("mov.%c\tr%d,%d[r%d]",
size[a->sz], a->rs, a->dsp << a->sz, a->rd);
} else {
prt("mov.%c\tr%d,[r%d]",
size[a->sz], a->rs, a->rd);
}
return true;
}
/* mov.[bwl] dsp:[rs],rd */
static bool trans_MOV_mr(DisasContext *ctx, arg_MOV_mr *a)
{
if (a->dsp > 0) {
prt("mov.%c\t%d[r%d], r%d",
size[a->sz], a->dsp << a->sz, a->rs, a->rd);
} else {
prt("mov.%c\t[r%d], r%d",
size[a->sz], a->rs, a->rd);
}
return true;
}
/* mov.l #uimm4,rd */
/* mov.l #uimm8,rd */
/* mov.l #imm,rd */
static bool trans_MOV_ir(DisasContext *ctx, arg_MOV_ir *a)
{
prt_ir(ctx, "mov.l", a->imm, a->rd);
return true;
}
/* mov.[bwl] #uimm8,dsp:[rd] */
/* mov #imm, dsp:[rd] */
static bool trans_MOV_im(DisasContext *ctx, arg_MOV_im *a)
{
if (a->dsp > 0) {
prt("mov.%c\t#%d,%d[r%d]",
size[a->sz], a->imm, a->dsp << a->sz, a->rd);
} else {
prt("mov.%c\t#%d,[r%d]",
size[a->sz], a->imm, a->rd);
}
return true;
}
/* mov.[bwl] [ri,rb],rd */
static bool trans_MOV_ar(DisasContext *ctx, arg_MOV_ar *a)
{
prt("mov.%c\t[r%d,r%d], r%d", size[a->sz], a->ri, a->rb, a->rd);
return true;
}
/* mov.[bwl] rd,[ri,rb] */
static bool trans_MOV_ra(DisasContext *ctx, arg_MOV_ra *a)
{
prt("mov.%c\tr%d, [r%d, r%d]", size[a->sz], a->rs, a->ri, a->rb);
return true;
}
/* mov.[bwl] dsp:[rs],dsp:[rd] */
/* mov.[bwl] rs,dsp:[rd] */
/* mov.[bwl] dsp:[rs],rd */
/* mov.[bwl] rs,rd */
static bool trans_MOV_mm(DisasContext *ctx, arg_MOV_mm *a)
{
char dspd[8], dsps[8], szc = size[a->sz];
if (a->lds == 3 && a->ldd == 3) {
/* mov.[bwl] rs,rd */
prt("mov.%c\tr%d, r%d", szc, a->rs, a->rd);
} else if (a->lds == 3) {
rx_index_addr(ctx, dspd, a->ldd, a->sz);
prt("mov.%c\tr%d, %s[r%d]", szc, a->rs, dspd, a->rd);
} else if (a->ldd == 3) {
rx_index_addr(ctx, dsps, a->lds, a->sz);
prt("mov.%c\t%s[r%d], r%d", szc, dsps, a->rs, a->rd);
} else {
rx_index_addr(ctx, dsps, a->lds, a->sz);
rx_index_addr(ctx, dspd, a->ldd, a->sz);
prt("mov.%c\t%s[r%d], %s[r%d]", szc, dsps, a->rs, dspd, a->rd);
}
return true;
}
/* mov.[bwl] rs,[rd+] */
/* mov.[bwl] rs,[-rd] */
static bool trans_MOV_rp(DisasContext *ctx, arg_MOV_rp *a)
{
if (a->ad) {
prt("mov.%c\tr%d, [-r%d]", size[a->sz], a->rs, a->rd);
} else {
prt("mov.%c\tr%d, [r%d+]", size[a->sz], a->rs, a->rd);
}
return true;
}
/* mov.[bwl] [rd+],rs */
/* mov.[bwl] [-rd],rs */
static bool trans_MOV_pr(DisasContext *ctx, arg_MOV_pr *a)
{
if (a->ad) {
prt("mov.%c\t[-r%d], r%d", size[a->sz], a->rd, a->rs);
} else {
prt("mov.%c\t[r%d+], r%d", size[a->sz], a->rd, a->rs);
}
return true;
}
/* movu.[bw] dsp5:[rs],rd */
static bool trans_MOVU_mr(DisasContext *ctx, arg_MOVU_mr *a)
{
if (a->dsp > 0) {
prt("movu.%c\t%d[r%d], r%d", size[a->sz],
a->dsp << a->sz, a->rs, a->rd);
} else {
prt("movu.%c\t[r%d], r%d", size[a->sz], a->rs, a->rd);
}
return true;
}
/* movu.[bw] rs,rd */
static bool trans_MOVU_rr(DisasContext *ctx, arg_MOVU_rr *a)
{
prt("movu.%c\tr%d, r%d", size[a->sz], a->rs, a->rd);
return true;
}
/* movu.[bw] [ri,rb],rd */
static bool trans_MOVU_ar(DisasContext *ctx, arg_MOVU_ar *a)
{
prt("mov.%c\t[r%d,r%d], r%d", size[a->sz], a->ri, a->rb, a->rd);
return true;
}
/* movu.[bw] [rs+],rd */
/* movu.[bw] [-rs],rd */
static bool trans_MOVU_pr(DisasContext *ctx, arg_MOVU_pr *a)
{
if (a->ad) {
prt("movu.%c\t[-r%d], r%d", size[a->sz], a->rd, a->rs);
} else {
prt("movu.%c\t[r%d+], r%d", size[a->sz], a->rd, a->rs);
}
return true;
}
/* pop rd */
static bool trans_POP(DisasContext *ctx, arg_POP *a)
{
prt("pop\tr%d", a->rd);
return true;
}
/* popc rx */
static bool trans_POPC(DisasContext *ctx, arg_POPC *a)
{
prt("pop\tr%s", rx_crname(a->cr));
return true;
}
/* popm rd-rd2 */
static bool trans_POPM(DisasContext *ctx, arg_POPM *a)
{
prt("popm\tr%d-r%d", a->rd, a->rd2);
return true;
}
/* push rs */
static bool trans_PUSH_r(DisasContext *ctx, arg_PUSH_r *a)
{
prt("push\tr%d", a->rs);
return true;
}
/* push dsp[rs] */
static bool trans_PUSH_m(DisasContext *ctx, arg_PUSH_m *a)
{
char dsp[8];
rx_index_addr(ctx, dsp, a->ld, a->sz);
prt("push\t%s[r%d]", dsp, a->rs);
return true;
}
/* pushc rx */
static bool trans_PUSHC(DisasContext *ctx, arg_PUSHC *a)
{
prt("push\t%s", rx_crname(a->cr));
return true;
}
/* pushm rs-rs2*/
static bool trans_PUSHM(DisasContext *ctx, arg_PUSHM *a)
{
prt("pushm\tr%d-r%d", a->rs, a->rs2);
return true;
}
/* xchg rs,rd */
static bool trans_XCHG_rr(DisasContext *ctx, arg_XCHG_rr *a)
{
prt("xchg\tr%d, r%d", a->rs, a->rd);
return true;
}
/* xchg dsp[rs].<mi>,rd */
static bool trans_XCHG_mr(DisasContext *ctx, arg_XCHG_mr *a)
{
prt_ldmi(ctx, "xchg", a->ld, a->mi, a->rs, a->rd);
return true;
}
/* stz #imm,rd */
static bool trans_STZ(DisasContext *ctx, arg_STZ *a)
{
prt_ir(ctx, "stz", a->imm, a->rd);
return true;
}
/* stnz #imm,rd */
static bool trans_STNZ(DisasContext *ctx, arg_STNZ *a)
{
prt_ir(ctx, "stnz", a->imm, a->rd);
return true;
}
/* rtsd #imm */
static bool trans_RTSD_i(DisasContext *ctx, arg_RTSD_i *a)
{
prt("rtsd\t#%d", a->imm << 2);
return true;
}
/* rtsd #imm, rd-rd2 */
static bool trans_RTSD_irr(DisasContext *ctx, arg_RTSD_irr *a)
{
prt("rtsd\t#%d, r%d - r%d", a->imm << 2, a->rd, a->rd2);
return true;
}
/* and #uimm:4, rd */
/* and #imm, rd */
static bool trans_AND_ir(DisasContext *ctx, arg_AND_ir *a)
{
prt_ir(ctx, "and", a->imm, a->rd);
return true;
}
/* and dsp[rs], rd */
/* and rs,rd */
static bool trans_AND_mr(DisasContext *ctx, arg_AND_mr *a)
{
prt_ldmi(ctx, "and", a->ld, a->mi, a->rs, a->rd);
return true;
}
/* and rs,rs2,rd */
static bool trans_AND_rrr(DisasContext *ctx, arg_AND_rrr *a)
{
prt("and\tr%d,r%d, r%d", a->rs, a->rs2, a->rd);
return true;
}
/* or #uimm:4, rd */
/* or #imm, rd */
static bool trans_OR_ir(DisasContext *ctx, arg_OR_ir *a)
{
prt_ir(ctx, "or", a->imm, a->rd);
return true;
}
/* or dsp[rs], rd */
/* or rs,rd */
static bool trans_OR_mr(DisasContext *ctx, arg_OR_mr *a)
{
prt_ldmi(ctx, "or", a->ld, a->mi, a->rs, a->rd);
return true;
}
/* or rs,rs2,rd */
static bool trans_OR_rrr(DisasContext *ctx, arg_OR_rrr *a)
{
prt("or\tr%d, r%d, r%d", a->rs, a->rs2, a->rd);
return true;
}
/* xor #imm, rd */
static bool trans_XOR_ir(DisasContext *ctx, arg_XOR_ir *a)
{
prt_ir(ctx, "xor", a->imm, a->rd);
return true;
}
/* xor dsp[rs], rd */
/* xor rs,rd */
static bool trans_XOR_mr(DisasContext *ctx, arg_XOR_mr *a)
{
prt_ldmi(ctx, "xor", a->ld, a->mi, a->rs, a->rd);
return true;
}
/* tst #imm, rd */
static bool trans_TST_ir(DisasContext *ctx, arg_TST_ir *a)
{
prt_ir(ctx, "tst", a->imm, a->rd);
return true;
}
/* tst dsp[rs], rd */
/* tst rs, rd */
static bool trans_TST_mr(DisasContext *ctx, arg_TST_mr *a)
{
prt_ldmi(ctx, "tst", a->ld, a->mi, a->rs, a->rd);
return true;
}
/* not rd */
/* not rs, rd */
static bool trans_NOT_rr(DisasContext *ctx, arg_NOT_rr *a)
{
if (a->rs != a->rd) {
prt("not\tr%d, r%d", a->rs, a->rd);
} else {
prt("not\tr%d", a->rs);
}
return true;
}
/* neg rd */
/* neg rs, rd */
static bool trans_NEG_rr(DisasContext *ctx, arg_NEG_rr *a)
{
if (a->rs != a->rd) {
prt("neg\tr%d, r%d", a->rs, a->rd);
} else {
prt("neg\tr%d", a->rs);
}
return true;
}
/* adc #imm, rd */
static bool trans_ADC_ir(DisasContext *ctx, arg_ADC_ir *a)
{
prt_ir(ctx, "adc", a->imm, a->rd);
return true;
}
/* adc rs, rd */
static bool trans_ADC_rr(DisasContext *ctx, arg_ADC_rr *a)
{
prt("adc\tr%d, r%d", a->rs, a->rd);
return true;
}
/* adc dsp[rs], rd */
static bool trans_ADC_mr(DisasContext *ctx, arg_ADC_mr *a)
{
char dsp[8];
rx_index_addr(ctx, dsp, a->ld, 2);
prt("adc\t%s[r%d], r%d", dsp, a->rs, a->rd);
return true;
}
/* add #uimm4, rd */
/* add #imm, rs, rd */
static bool trans_ADD_irr(DisasContext *ctx, arg_ADD_irr *a)
{
if (a->imm < 0x10 && a->rs2 == a->rd) {
prt("add\t#%d, r%d", a->imm, a->rd);
} else {
prt("add\t#0x%08x, r%d, r%d", a->imm, a->rs2, a->rd);
}
return true;
}
/* add rs, rd */
/* add dsp[rs], rd */
static bool trans_ADD_mr(DisasContext *ctx, arg_ADD_mr *a)
{
prt_ldmi(ctx, "add", a->ld, a->mi, a->rs, a->rd);
return true;
}
/* add rs, rs2, rd */
static bool trans_ADD_rrr(DisasContext *ctx, arg_ADD_rrr *a)
{
prt("add\tr%d, r%d, r%d", a->rs, a->rs2, a->rd);
return true;
}
/* cmp #imm4, rd */
/* cmp #imm8, rd */
/* cmp #imm, rs2 */
static bool trans_CMP_ir(DisasContext *ctx, arg_CMP_ir *a)
{
prt_ir(ctx, "cmp", a->imm, a->rs2);
return true;
}
/* cmp rs, rs2 */
/* cmp dsp[rs], rs2 */
static bool trans_CMP_mr(DisasContext *ctx, arg_CMP_mr *a)
{
prt_ldmi(ctx, "cmp", a->ld, a->mi, a->rs, a->rd);
return true;
}
/* sub #imm4, rd */
static bool trans_SUB_ir(DisasContext *ctx, arg_SUB_ir *a)
{
prt("sub\t#%d, r%d", a->imm, a->rd);
return true;
}
/* sub rs, rd */
/* sub dsp[rs], rd */
static bool trans_SUB_mr(DisasContext *ctx, arg_SUB_mr *a)
{
prt_ldmi(ctx, "sub", a->ld, a->mi, a->rs, a->rd);
return true;
}
/* sub rs, rs2, rd */
static bool trans_SUB_rrr(DisasContext *ctx, arg_SUB_rrr *a)
{
prt("sub\tr%d, r%d, r%d", a->rs, a->rs2, a->rd);
return true;
}
/* sbb rs, rd */
static bool trans_SBB_rr(DisasContext *ctx, arg_SBB_rr *a)
{
prt("sbb\tr%d, r%d", a->rs, a->rd);
return true;
}
/* sbb dsp[rs], rd */
static bool trans_SBB_mr(DisasContext *ctx, arg_SBB_mr *a)
{
prt_ldmi(ctx, "sbb", a->ld, RX_IM_LONG, a->rs, a->rd);
return true;
}
/* abs rd */
/* abs rs, rd */
static bool trans_ABS_rr(DisasContext *ctx, arg_ABS_rr *a)
{
if (a->rs != a->rd) {
prt("abs\tr%d, r%d", a->rs, a->rd);
} else {
prt("abs\tr%d", a->rs);
}
return true;
}
/* max #imm, rd */
static bool trans_MAX_ir(DisasContext *ctx, arg_MAX_ir *a)
{
prt_ir(ctx, "max", a->imm, a->rd);
return true;
}
/* max rs, rd */
/* max dsp[rs], rd */
static bool trans_MAX_mr(DisasContext *ctx, arg_MAX_mr *a)
{
prt_ldmi(ctx, "max", a->ld, a->mi, a->rs, a->rd);
return true;
}
/* min #imm, rd */
static bool trans_MIN_ir(DisasContext *ctx, arg_MIN_ir *a)
{
prt_ir(ctx, "min", a->imm, a->rd);
return true;
}
/* min rs, rd */
/* min dsp[rs], rd */
static bool trans_MIN_mr(DisasContext *ctx, arg_MIN_mr *a)
{
prt_ldmi(ctx, "min", a->ld, a->mi, a->rs, a->rd);
return true;
}
/* mul #uimm4, rd */
/* mul #imm, rd */
static bool trans_MUL_ir(DisasContext *ctx, arg_MUL_ir *a)
{
prt_ir(ctx, "mul", a->imm, a->rd);
return true;
}
/* mul rs, rd */
/* mul dsp[rs], rd */
static bool trans_MUL_mr(DisasContext *ctx, arg_MUL_mr *a)
{
prt_ldmi(ctx, "mul", a->ld, a->mi, a->rs, a->rd);
return true;
}
/* mul rs, rs2, rd */
static bool trans_MUL_rrr(DisasContext *ctx, arg_MUL_rrr *a)
{
prt("mul\tr%d,r%d,r%d", a->rs, a->rs2, a->rd);
return true;
}
/* emul #imm, rd */
static bool trans_EMUL_ir(DisasContext *ctx, arg_EMUL_ir *a)
{
prt_ir(ctx, "emul", a->imm, a->rd);
return true;
}
/* emul rs, rd */
/* emul dsp[rs], rd */
static bool trans_EMUL_mr(DisasContext *ctx, arg_EMUL_mr *a)
{
prt_ldmi(ctx, "emul", a->ld, a->mi, a->rs, a->rd);
return true;
}
/* emulu #imm, rd */
static bool trans_EMULU_ir(DisasContext *ctx, arg_EMULU_ir *a)
{
prt_ir(ctx, "emulu", a->imm, a->rd);
return true;
}
/* emulu rs, rd */
/* emulu dsp[rs], rd */
static bool trans_EMULU_mr(DisasContext *ctx, arg_EMULU_mr *a)
{
prt_ldmi(ctx, "emulu", a->ld, a->mi, a->rs, a->rd);
return true;
}
/* div #imm, rd */
static bool trans_DIV_ir(DisasContext *ctx, arg_DIV_ir *a)
{
prt_ir(ctx, "div", a->imm, a->rd);
return true;
}
/* div rs, rd */
/* div dsp[rs], rd */
static bool trans_DIV_mr(DisasContext *ctx, arg_DIV_mr *a)
{
prt_ldmi(ctx, "div", a->ld, a->mi, a->rs, a->rd);
return true;
}
/* divu #imm, rd */
static bool trans_DIVU_ir(DisasContext *ctx, arg_DIVU_ir *a)
{
prt_ir(ctx, "divu", a->imm, a->rd);
return true;
}
/* divu rs, rd */
/* divu dsp[rs], rd */
static bool trans_DIVU_mr(DisasContext *ctx, arg_DIVU_mr *a)
{
prt_ldmi(ctx, "divu", a->ld, a->mi, a->rs, a->rd);
return true;
}
/* shll #imm:5, rd */
/* shll #imm:5, rs, rd */
static bool trans_SHLL_irr(DisasContext *ctx, arg_SHLL_irr *a)
{
if (a->rs2 != a->rd) {
prt("shll\t#%d, r%d, r%d", a->imm, a->rs2, a->rd);
} else {
prt("shll\t#%d, r%d", a->imm, a->rd);
}
return true;
}
/* shll rs, rd */
static bool trans_SHLL_rr(DisasContext *ctx, arg_SHLL_rr *a)
{
prt("shll\tr%d, r%d", a->rs, a->rd);
return true;
}
/* shar #imm:5, rd */
/* shar #imm:5, rs, rd */
static bool trans_SHAR_irr(DisasContext *ctx, arg_SHAR_irr *a)
{
if (a->rs2 != a->rd) {
prt("shar\t#%d, r%d, r%d", a->imm, a->rs2, a->rd);
} else {
prt("shar\t#%d, r%d", a->imm, a->rd);
}
return true;
}
/* shar rs, rd */
static bool trans_SHAR_rr(DisasContext *ctx, arg_SHAR_rr *a)
{
prt("shar\tr%d, r%d", a->rs, a->rd);
return true;
}
/* shlr #imm:5, rd */
/* shlr #imm:5, rs, rd */
static bool trans_SHLR_irr(DisasContext *ctx, arg_SHLR_irr *a)
{
if (a->rs2 != a->rd) {
prt("shlr\t#%d, r%d, r%d", a->imm, a->rs2, a->rd);
} else {
prt("shlr\t#%d, r%d", a->imm, a->rd);
}
return true;
}
/* shlr rs, rd */
static bool trans_SHLR_rr(DisasContext *ctx, arg_SHLR_rr *a)
{
prt("shlr\tr%d, r%d", a->rs, a->rd);
return true;
}
/* rolc rd */
static bool trans_ROLC(DisasContext *ctx, arg_ROLC *a)
{
prt("rorc\tr%d", a->rd);
return true;
}
/* rorc rd */
static bool trans_RORC(DisasContext *ctx, arg_RORC *a)
{
prt("rorc\tr%d", a->rd);
return true;
}
/* rotl #imm, rd */
static bool trans_ROTL_ir(DisasContext *ctx, arg_ROTL_ir *a)
{
prt("rotl\t#%d, r%d", a->imm, a->rd);
return true;
}
/* rotl rs, rd */
static bool trans_ROTL_rr(DisasContext *ctx, arg_ROTL_rr *a)
{
prt("rotl\tr%d, r%d", a->rs, a->rd);
return true;
}
/* rotr #imm, rd */
static bool trans_ROTR_ir(DisasContext *ctx, arg_ROTR_ir *a)
{
prt("rotr\t#%d, r%d", a->imm, a->rd);
return true;
}
/* rotr rs, rd */
static bool trans_ROTR_rr(DisasContext *ctx, arg_ROTR_rr *a)
{
prt("rotr\tr%d, r%d", a->rs, a->rd);
return true;
}
/* revl rs, rd */
static bool trans_REVL(DisasContext *ctx, arg_REVL *a)
{
prt("revl\tr%d, r%d", a->rs, a->rd);
return true;
}
/* revw rs, rd */
static bool trans_REVW(DisasContext *ctx, arg_REVW *a)
{
prt("revw\tr%d, r%d", a->rs, a->rd);
return true;
}
/* conditional branch helper */
static void rx_bcnd_main(DisasContext *ctx, int cd, int len, int dst)
{
static const char sz[] = {'s', 'b', 'w', 'a'};
prt("b%s.%c\t%08x", cond[cd], sz[len - 1], ctx->pc + dst);
}
/* beq dsp:3 / bne dsp:3 */
/* beq dsp:8 / bne dsp:8 */
/* bc dsp:8 / bnc dsp:8 */
/* bgtu dsp:8 / bleu dsp:8 */
/* bpz dsp:8 / bn dsp:8 */
/* bge dsp:8 / blt dsp:8 */
/* bgt dsp:8 / ble dsp:8 */
/* bo dsp:8 / bno dsp:8 */
/* beq dsp:16 / bne dsp:16 */
static bool trans_BCnd(DisasContext *ctx, arg_BCnd *a)
{
rx_bcnd_main(ctx, a->cd, a->sz, a->dsp);
return true;
}
/* bra dsp:3 */
/* bra dsp:8 */
/* bra dsp:16 */
/* bra dsp:24 */
static bool trans_BRA(DisasContext *ctx, arg_BRA *a)
{
rx_bcnd_main(ctx, 14, a->sz, a->dsp);
return true;
}
/* bra rs */
static bool trans_BRA_l(DisasContext *ctx, arg_BRA_l *a)
{
prt("bra.l\tr%d", a->rd);
return true;
}
/* jmp rs */
static bool trans_JMP(DisasContext *ctx, arg_JMP *a)
{
prt("jmp\tr%d", a->rs);
return true;
}
/* jsr rs */
static bool trans_JSR(DisasContext *ctx, arg_JSR *a)
{
prt("jsr\tr%d", a->rs);
return true;
}
/* bsr dsp:16 */
/* bsr dsp:24 */
static bool trans_BSR(DisasContext *ctx, arg_BSR *a)
{
static const char sz[] = {'w', 'a'};
prt("bsr.%c\t%08x", sz[a->sz - 3], ctx->pc + a->dsp);
return true;
}
/* bsr rs */
static bool trans_BSR_l(DisasContext *ctx, arg_BSR_l *a)
{
prt("bsr.l\tr%d", a->rd);
return true;
}
/* rts */
static bool trans_RTS(DisasContext *ctx, arg_RTS *a)
{
prt("rts");
return true;
}
/* nop */
static bool trans_NOP(DisasContext *ctx, arg_NOP *a)
{
prt("nop");
return true;
}
/* scmpu */
static bool trans_SCMPU(DisasContext *ctx, arg_SCMPU *a)
{
prt("scmpu");
return true;
}
/* smovu */
static bool trans_SMOVU(DisasContext *ctx, arg_SMOVU *a)
{
prt("smovu");
return true;
}
/* smovf */
static bool trans_SMOVF(DisasContext *ctx, arg_SMOVF *a)
{
prt("smovf");
return true;
}
/* smovb */
static bool trans_SMOVB(DisasContext *ctx, arg_SMOVB *a)
{
prt("smovb");
return true;
}
/* suntile */
static bool trans_SUNTIL(DisasContext *ctx, arg_SUNTIL *a)
{
prt("suntil.%c", size[a->sz]);
return true;
}
/* swhile */
static bool trans_SWHILE(DisasContext *ctx, arg_SWHILE *a)
{
prt("swhile.%c", size[a->sz]);
return true;
}
/* sstr */
static bool trans_SSTR(DisasContext *ctx, arg_SSTR *a)
{
prt("sstr.%c", size[a->sz]);
return true;
}
/* rmpa */
static bool trans_RMPA(DisasContext *ctx, arg_RMPA *a)
{
prt("rmpa.%c", size[a->sz]);
return true;
}
/* mulhi rs,rs2 */
static bool trans_MULHI(DisasContext *ctx, arg_MULHI *a)
{
prt("mulhi\tr%d,r%d", a->rs, a->rs2);
return true;
}
/* mullo rs,rs2 */
static bool trans_MULLO(DisasContext *ctx, arg_MULLO *a)
{
prt("mullo\tr%d, r%d", a->rs, a->rs2);
return true;
}
/* machi rs,rs2 */
static bool trans_MACHI(DisasContext *ctx, arg_MACHI *a)
{
prt("machi\tr%d, r%d", a->rs, a->rs2);
return true;
}
/* maclo rs,rs2 */
static bool trans_MACLO(DisasContext *ctx, arg_MACLO *a)
{
prt("maclo\tr%d, r%d", a->rs, a->rs2);
return true;
}
/* mvfachi rd */
static bool trans_MVFACHI(DisasContext *ctx, arg_MVFACHI *a)
{
prt("mvfachi\tr%d", a->rd);
return true;
}
/* mvfacmi rd */
static bool trans_MVFACMI(DisasContext *ctx, arg_MVFACMI *a)
{
prt("mvfacmi\tr%d", a->rd);
return true;
}
/* mvtachi rs */
static bool trans_MVTACHI(DisasContext *ctx, arg_MVTACHI *a)
{
prt("mvtachi\tr%d", a->rs);
return true;
}
/* mvtaclo rs */
static bool trans_MVTACLO(DisasContext *ctx, arg_MVTACLO *a)
{
prt("mvtaclo\tr%d", a->rs);
return true;
}
/* racw #imm */
static bool trans_RACW(DisasContext *ctx, arg_RACW *a)
{
prt("racw\t#%d", a->imm + 1);
return true;
}
/* sat rd */
static bool trans_SAT(DisasContext *ctx, arg_SAT *a)
{
prt("sat\tr%d", a->rd);
return true;
}
/* satr */
static bool trans_SATR(DisasContext *ctx, arg_SATR *a)
{
prt("satr");
return true;
}
/* fadd #imm, rd */
static bool trans_FADD_ir(DisasContext *ctx, arg_FADD_ir *a)
{
prt("fadd\t#%d,r%d", li(ctx, 0), a->rd);
return true;
}
/* fadd dsp[rs], rd */
/* fadd rs, rd */
static bool trans_FADD_mr(DisasContext *ctx, arg_FADD_mr *a)
{
prt_ldmi(ctx, "fadd", a->ld, RX_IM_LONG, a->rs, a->rd);
return true;
}
/* fcmp #imm, rd */
static bool trans_FCMP_ir(DisasContext *ctx, arg_FCMP_ir *a)
{
prt("fadd\t#%d,r%d", li(ctx, 0), a->rd);
return true;
}
/* fcmp dsp[rs], rd */
/* fcmp rs, rd */
static bool trans_FCMP_mr(DisasContext *ctx, arg_FCMP_mr *a)
{
prt_ldmi(ctx, "fcmp", a->ld, RX_IM_LONG, a->rs, a->rd);
return true;
}
/* fsub #imm, rd */
static bool trans_FSUB_ir(DisasContext *ctx, arg_FSUB_ir *a)
{
prt("fsub\t#%d,r%d", li(ctx, 0), a->rd);
return true;
}
/* fsub dsp[rs], rd */
/* fsub rs, rd */
static bool trans_FSUB_mr(DisasContext *ctx, arg_FSUB_mr *a)
{
prt_ldmi(ctx, "fsub", a->ld, RX_IM_LONG, a->rs, a->rd);
return true;
}
/* ftoi dsp[rs], rd */
/* ftoi rs, rd */
static bool trans_FTOI(DisasContext *ctx, arg_FTOI *a)
{
prt_ldmi(ctx, "ftoi", a->ld, RX_IM_LONG, a->rs, a->rd);
return true;
}
/* fmul #imm, rd */
static bool trans_FMUL_ir(DisasContext *ctx, arg_FMUL_ir *a)
{
prt("fmul\t#%d,r%d", li(ctx, 0), a->rd);
return true;
}
/* fmul dsp[rs], rd */
/* fmul rs, rd */
static bool trans_FMUL_mr(DisasContext *ctx, arg_FMUL_mr *a)
{
prt_ldmi(ctx, "fmul", a->ld, RX_IM_LONG, a->rs, a->rd);
return true;
}
/* fdiv #imm, rd */
static bool trans_FDIV_ir(DisasContext *ctx, arg_FDIV_ir *a)
{
prt("fdiv\t#%d,r%d", li(ctx, 0), a->rd);
return true;
}
/* fdiv dsp[rs], rd */
/* fdiv rs, rd */
static bool trans_FDIV_mr(DisasContext *ctx, arg_FDIV_mr *a)
{
prt_ldmi(ctx, "fdiv", a->ld, RX_IM_LONG, a->rs, a->rd);
return true;
}
/* round dsp[rs], rd */
/* round rs, rd */
static bool trans_ROUND(DisasContext *ctx, arg_ROUND *a)
{
prt_ldmi(ctx, "round", a->ld, RX_IM_LONG, a->rs, a->rd);
return true;
}
/* itof rs, rd */
/* itof dsp[rs], rd */
static bool trans_ITOF(DisasContext *ctx, arg_ITOF *a)
{
prt_ldmi(ctx, "itof", a->ld, RX_IM_LONG, a->rs, a->rd);
return true;
}
#define BOP_IM(name, reg) \
do { \
char dsp[8]; \
rx_index_addr(ctx, dsp, a->ld, RX_MEMORY_BYTE); \
prt("b%s\t#%d, %s[r%d]", #name, a->imm, dsp, reg); \
return true; \
} while (0)
#define BOP_RM(name) \
do { \
char dsp[8]; \
rx_index_addr(ctx, dsp, a->ld, RX_MEMORY_BYTE); \
prt("b%s\tr%d, %s[r%d]", #name, a->rd, dsp, a->rs); \
return true; \
} while (0)
/* bset #imm, dsp[rd] */
static bool trans_BSET_im(DisasContext *ctx, arg_BSET_im *a)
{
BOP_IM(bset, a->rs);
}
/* bset rs, dsp[rd] */
static bool trans_BSET_rm(DisasContext *ctx, arg_BSET_rm *a)
{
BOP_RM(set);
}
/* bset rs, rd */
static bool trans_BSET_rr(DisasContext *ctx, arg_BSET_rr *a)
{
prt("bset\tr%d,r%d", a->rs, a->rd);
return true;
}
/* bset #imm, rd */
static bool trans_BSET_ir(DisasContext *ctx, arg_BSET_ir *a)
{
prt("bset\t#%d, r%d", a->imm, a->rd);
return true;
}
/* bclr #imm, dsp[rd] */
static bool trans_BCLR_im(DisasContext *ctx, arg_BCLR_im *a)
{
BOP_IM(clr, a->rs);
}
/* bclr rs, dsp[rd] */
static bool trans_BCLR_rm(DisasContext *ctx, arg_BCLR_rm *a)
{
BOP_RM(clr);
}
/* bclr rs, rd */
static bool trans_BCLR_rr(DisasContext *ctx, arg_BCLR_rr *a)
{
prt("bclr\tr%d, r%d", a->rs, a->rd);
return true;
}
/* bclr #imm, rd */
static bool trans_BCLR_ir(DisasContext *ctx, arg_BCLR_ir *a)
{
prt("bclr\t#%d,r%d", a->imm, a->rd);
return true;
}
/* btst #imm, dsp[rd] */
static bool trans_BTST_im(DisasContext *ctx, arg_BTST_im *a)
{
BOP_IM(tst, a->rs);
}
/* btst rs, dsp[rd] */
static bool trans_BTST_rm(DisasContext *ctx, arg_BTST_rm *a)
{
BOP_RM(tst);
}
/* btst rs, rd */
static bool trans_BTST_rr(DisasContext *ctx, arg_BTST_rr *a)
{
prt("btst\tr%d, r%d", a->rs, a->rd);
return true;
}
/* btst #imm, rd */
static bool trans_BTST_ir(DisasContext *ctx, arg_BTST_ir *a)
{
prt("btst\t#%d, r%d", a->imm, a->rd);
return true;
}
/* bnot rs, dsp[rd] */
static bool trans_BNOT_rm(DisasContext *ctx, arg_BNOT_rm *a)
{
BOP_RM(not);
}
/* bnot rs, rd */
static bool trans_BNOT_rr(DisasContext *ctx, arg_BNOT_rr *a)
{
prt("bnot\tr%d, r%d", a->rs, a->rd);
return true;
}
/* bnot #imm, dsp[rd] */
static bool trans_BNOT_im(DisasContext *ctx, arg_BNOT_im *a)
{
BOP_IM(not, a->rs);
}
/* bnot #imm, rd */
static bool trans_BNOT_ir(DisasContext *ctx, arg_BNOT_ir *a)
{
prt("bnot\t#%d, r%d", a->imm, a->rd);
return true;
}
/* bmcond #imm, dsp[rd] */
static bool trans_BMCnd_im(DisasContext *ctx, arg_BMCnd_im *a)
{
char dsp[8];
rx_index_addr(ctx, dsp, a->ld, RX_MEMORY_BYTE);
prt("bm%s\t#%d, %s[r%d]", cond[a->cd], a->imm, dsp, a->rd);
return true;
}
/* bmcond #imm, rd */
static bool trans_BMCnd_ir(DisasContext *ctx, arg_BMCnd_ir *a)
{
prt("bm%s\t#%d, r%d", cond[a->cd], a->imm, a->rd);
return true;
}
/* clrpsw psw */
static bool trans_CLRPSW(DisasContext *ctx, arg_CLRPSW *a)
{
prt("clrpsw\t%c", psw[a->cb]);
return true;
}
/* setpsw psw */
static bool trans_SETPSW(DisasContext *ctx, arg_SETPSW *a)
{
prt("setpsw\t%c", psw[a->cb]);
return true;
}
/* mvtipl #imm */
static bool trans_MVTIPL(DisasContext *ctx, arg_MVTIPL *a)
{
prt("movtipl\t#%d", a->imm);
return true;
}
/* mvtc #imm, rd */
static bool trans_MVTC_i(DisasContext *ctx, arg_MVTC_i *a)
{
prt("mvtc\t#0x%08x, %s", a->imm, rx_crname(a->cr));
return true;
}
/* mvtc rs, rd */
static bool trans_MVTC_r(DisasContext *ctx, arg_MVTC_r *a)
{
prt("mvtc\tr%d, %s", a->rs, rx_crname(a->cr));
return true;
}
/* mvfc rs, rd */
static bool trans_MVFC(DisasContext *ctx, arg_MVFC *a)
{
prt("mvfc\t%s, r%d", rx_crname(a->cr), a->rd);
return true;
}
/* rtfi */
static bool trans_RTFI(DisasContext *ctx, arg_RTFI *a)
{
prt("rtfi");
return true;
}
/* rte */
static bool trans_RTE(DisasContext *ctx, arg_RTE *a)
{
prt("rte");
return true;
}
/* brk */
static bool trans_BRK(DisasContext *ctx, arg_BRK *a)
{
prt("brk");
return true;
}
/* int #imm */
static bool trans_INT(DisasContext *ctx, arg_INT *a)
{
prt("int\t#%d", a->imm);
return true;
}
/* wait */
static bool trans_WAIT(DisasContext *ctx, arg_WAIT *a)
{
prt("wait");
return true;
}
/* sccnd.[bwl] rd */
/* sccnd.[bwl] dsp:[rd] */
static bool trans_SCCnd(DisasContext *ctx, arg_SCCnd *a)
{
if (a->ld < 3) {
char dsp[8];
rx_index_addr(ctx, dsp, a->sz, a->ld);
prt("sc%s.%c\t%s[r%d]", cond[a->cd], size[a->sz], dsp, a->rd);
} else {
prt("sc%s.%c\tr%d", cond[a->cd], size[a->sz], a->rd);
}
return true;
}
int print_insn_rx(bfd_vma addr, disassemble_info *dis)
{
DisasContext ctx;
uint32_t insn;
int i;
ctx.dis = dis;
ctx.pc = ctx.addr = addr;
ctx.len = 0;
insn = decode_load(&ctx);
if (!decode(&ctx, insn)) {
ctx.dis->fprintf_func(ctx.dis->stream, ".byte\t");
for (i = 0; i < ctx.addr - addr; i++) {
if (i > 0) {
ctx.dis->fprintf_func(ctx.dis->stream, ",");
}
ctx.dis->fprintf_func(ctx.dis->stream, "0x%02x", insn >> 24);
insn <<= 8;
}
}
return ctx.addr - addr;
}
|