40 #define _NELEM(ary) (sizeof(ary) / sizeof((ary)[0]))
42 #define BIT(word, n) ((word) & (1 << (n)))
44 #define BITS(word, s, e) (((word) << (sizeof(word) * 8 - 1 - (e))) >> ((s) + (sizeof(word) * 8 - 1 - (e))))
46 #define OPCODE(word) (BITS((word), 27, 31))
47 #define FIELDA(word) (BITS((word), 0, 5))
48 #define FIELDb(word) (BITS((word), 24, 26))
49 #define FIELDB(word) (BITS((word), 12, 14))
50 #define FIELDC(word) (BITS((word), 6, 11))
51 #define OPCODE_AC(word) (BITS((word), 11, 15))
52 #define FIELDA_AC(word) (BITS((word), 0, 2))
53 #define FIELDB_AC(word) (BITS((word), 8, 10))
54 #define FIELDC_AC(word) (BITS((word), 5, 7))
55 #define FIELDU_AC(word) (BITS((word), 0, 4))
61 #define FIELDS_AC(word) (BITS(((signed int)(word)), 0, 8))
67 #define FIELDD(word) (BITS(((signed int)(word)), 16, 23))
73 #define FIELDD9(word) ((BITS(((signed int)(word)), 15, 15) << 8) | (BITS((word), 16, 23)))
78 #define FIELDS(word) ((BITS(((signed int)(word)), 0, 5) << 6) | (BITS((word), 6, 11)))
84 #define FIELDS9(word) (((BITS(((signed int)(word)), 15, 15) << 7) | (BITS((word), 17, 23))) << 1)
85 #define FIELDS9_FLAG(word) (((BITS(((signed int)(word)), 0, 5) << 6) | (BITS((word), 6, 11))))
87 #define PUT_NEXT_WORD_IN(a) \
89 if (is_limm == 1 && !NEXT_WORD(1)) { \
90 mwerror(state, "Illegal limm reference in last instruction!\n"); \
92 if (info->endian == BFD_ENDIAN_LITTLE) { \
93 (a) = ((state->words[1] & 0xff00) | (state->words[1] & 0xff)) << 16; \
94 (a) |= ((state->words[1] & 0xff0000) | (state->words[1] & 0xff000000)) >> 16; \
96 (a) = state->words[1]; \
100 #define CHECK_NULLIFY() \
102 state->nullifyMode = BITS(state->words[0], 5, 5); \
105 #define CHECK_COND_NULLIFY() \
107 state->nullifyMode = BITS(state->words[0], 5, 5); \
108 cond = BITS(state->words[0], 0, 4); \
111 #define CHECK_FLAG_COND_NULLIFY() \
113 if (is_shimm == 0) { \
114 flag = BIT(state->words[0], 15); \
115 state->nullifyMode = BITS(state->words[0], 5, 5); \
116 cond = BITS(state->words[0], 0, 4); \
120 #define CHECK_FLAG_COND() \
122 if (is_shimm == 0) { \
123 flag = BIT(state->words[0], 15); \
124 cond = BITS(state->words[0], 0, 4); \
128 #define CHECK_FLAG() \
130 flag = BIT(state->words[0], 15); \
133 #define CHECK_COND() \
135 if (is_shimm == 0) { \
136 cond = BITS(state->words[0], 0, 4); \
140 #define CHECK_FIELD(field) \
142 if ((field) == 62) { \
145 PUT_NEXT_WORD_IN(field); \
149 #define CHECK_FIELD_A() \
151 fieldA = FIELDA(state->words[0]); \
152 if (fieldA == 62) { \
160 fieldB = (FIELDB(state->words[0]) << 3); \
161 fieldB |= FIELDb(state->words[0]); \
162 if (fieldB == 62) { \
170 fieldC = FIELDC(state->words[0]); \
171 if (fieldC == 62) { \
179 fieldC = BITS(state->words[0], 15, 16); \
180 fieldC = fieldC << 6; \
181 fieldC |= FIELDC(state->words[0]); \
185 #define CHECK_FIELD_B() \
187 fieldB = (FIELDB(state->words[0]) << 3); \
188 fieldB |= FIELDb(state->words[0]); \
189 CHECK_FIELD(fieldB); \
192 #define CHECK_FIELD_C() \
194 fieldC = FIELDC(state->words[0]); \
195 CHECK_FIELD(fieldC); \
198 #define FIELD_C_S() \
200 fieldC_S = (FIELDC_S(state->words[0]) << 3); \
203 #define FIELD_B_S() \
205 fieldB_S = (FIELDB_S(state->words[0]) << 3); \
208 #define CHECK_FIELD_H_AC() \
210 fieldC = ((FIELDA_AC(state->words[0])) << 3); \
211 fieldC |= FIELDC_AC(state->words[0]); \
212 CHECK_FIELD(fieldC); \
215 #define FIELD_H_AC() \
217 fieldC = ((FIELDA_AC(state->words[0])) << 3); \
218 fieldC |= FIELDC_AC(state->words[0]); \
225 #define FIELD_C_AC() \
227 fieldC = FIELDC_AC(state->words[0]); \
233 #define FIELD_B_AC() \
235 fieldB = FIELDB_AC(state->words[0]); \
241 #define FIELD_A_AC() \
243 fieldA = FIELDA_AC(state->words[0]); \
249 #define IS_SMALL(x) (((field##x) < 256) && ((field##x) > -257))
250 #define IS_REG(x) (field##x##isReg)
251 #define IS_SIMD_128_REG(x) (usesSimdReg##x == 1)
252 #define IS_SIMD_16_REG(x) (usesSimdReg##x == 2)
253 #define IS_SIMD_DATA_REG(x) (usesSimdReg##x == 3)
254 #define WRITE_FORMAT_LB_Rx_RB(x) WRITE_FORMAT(x, "[", "]", "", "")
255 #define WRITE_FORMAT_x_COMMA_LB(x) WRITE_FORMAT(x, "", ", [", "", ",[")
256 #define WRITE_FORMAT_COMMA_x_RB(x) WRITE_FORMAT(x, ", ", "]", ", ", "]")
257 #define WRITE_FORMAT_x_RB(x) WRITE_FORMAT(x, "", "]", "", "]")
258 #define WRITE_FORMAT_COMMA_x(x) WRITE_FORMAT(x, ", ", "", ", ", "")
259 #define WRITE_FORMAT_x_COMMA(x) WRITE_FORMAT(x, "", ", ", "", ", ")
260 #define WRITE_FORMAT_x(x) WRITE_FORMAT(x, "", "", "", "")
261 #define WRITE_FORMAT(x, cb1, ca1, cb, ca) strcat(formatString, \
262 (IS_SIMD_128_REG(x) ? cb1 "%S" ca1 : IS_SIMD_16_REG(x) ? cb1 "%I" ca1 \
263 : IS_SIMD_DATA_REG(x) ? cb1 "%D" ca1 \
264 : IS_REG(x) ? cb1 "%r" ca1 \
265 : usesAuxReg ? cb "%a" ca \
266 : IS_SMALL(x) ? cb "%d" ca \
269 #define WRITE_FORMAT_LB() strcat(formatString, "[")
270 #define WRITE_FORMAT_RB() strcat(formatString, "]")
271 #define WRITE_COMMENT(str) (state->comm[state->commNum++] = (str))
272 #define WRITE_NOP_COMMENT() \
273 if (!fieldAisReg && !flag) \
274 WRITE_COMMENT("nop");
276 #define NEXT_WORD(x) (offset += 4, state->words[x])
278 #define NEXT_WORD_AC(x) (offset += 2, state->words[x])
280 #define add_target(x) (state->targets[state->tcnt++] = (x))
282 static short int enable_simd = 0;
283 static short int enable_insn_stream = 0;
287 if (
state->coreRegName) {
295 if (
state->auxRegName) {
303 if (
state->condCodeName) {
311 if (
state->instName) {
319 if (
state->err != 0) {
327 unsigned int j,
i =
state->acnt;
344 int size, leading_zero, regMap[2];
347 va_start(ap, format);
379 while (*
p >=
'0' && *
p <=
'9') {
384 #define inc_bp() bp = bp + strlen(bp)
387 unsigned u = va_arg(ap,
int);
396 sprintf(bp,
"0x%x_%04x", u >> 16, u & 0xffff);
407 int val = va_arg(ap,
int);
420 int val = va_arg(ap,
int);
430 int val = va_arg(ap,
int);
432 #define REG2NAME(num, name) \
434 sprintf(bp, "" name); \
435 regMap[((num) < 32) ? 0 : 1] |= 1 << ((num) - (((num) < 32) ? 0 : 32)); \
461 int val = va_arg(ap,
int);
479 sprintf(bp,
"%s", va_arg(ap,
char *));
491 extern void abort(
void);
499 int val = va_arg(ap,
int);
506 int val = va_arg(ap,
int);
513 int val = va_arg(ap,
int);
521 fprintf(stderr,
"?? format %c\n",
p[-1]);
534 "",
"z",
"nz",
"p",
"n",
"c",
"nc",
"v",
535 "nv",
"gt",
"ge",
"lt",
"le",
"hi",
"ls",
"pnz",
542 const char *instrName,
544 int condCodeIsPartOfName,
552 strncpy(
state->instrBuffer, instrName,
sizeof(
state->instrBuffer) - 1);
556 if (!condCodeIsPartOfName) {
557 strcat(
state->instrBuffer,
".");
560 if (
cond < condlim) {
568 strcat(
state->instrBuffer, cc);
571 strcat(
state->instrBuffer,
".f");
573 if (
state->nullifyMode) {
574 if (strstr(
state->instrBuffer,
".d") ==
NULL) {
575 strcat(
state->instrBuffer,
".d");
579 strcat(
state->instrBuffer,
".x");
581 switch (addrWriteBack) {
582 case 1: strcat(
state->instrBuffer,
".a");
break;
583 case 2: strcat(
state->instrBuffer,
".ab");
break;
584 case 3: strcat(
state->instrBuffer,
".as");
break;
587 strcat(
state->instrBuffer,
".di");
591 #define write_instr_name() \
593 write_instr_name_(state, instrName, cond, condCodeIsPartOfName, flag, signExtend, addrWriteBack, directMem); \
594 formatString[0] = '\0'; \
642 value = ((data & 0xff00) | (data & 0xff)) << 16;
643 value |= ((data & 0xff0000) | (data & 0xff000000)) >> 16;
657 value = ((data & 0xff) << 8 | (data & 0xff00) >> 8);
688 int condCodeIsPartOfName = 0;
690 const char *instrName;
691 int fieldAisReg = 1, fieldBisReg = 1, fieldCisReg = 1;
692 int fieldA = 0, fieldB = 0, fieldC = 0;
693 int flag = 0,
cond = 0, is_shimm = 0, is_limm = 0;
694 int signExtend = 0, addrWriteBack = 0, directMem = 0;
698 int usesSimdRegA = 0, usesSimdRegB = 0, usesSimdRegC = 0, simd_scale_u8 = -1;
700 char formatString[60];
705 state->_mem_load = 0;
706 state->_ea_present = 0;
707 state->_load_len = 0;
719 if (
state->instructionLen == 4) {
737 condCodeIsPartOfName = 0;
751 switch (
state->_opcode) {
756 condCodeIsPartOfName = 1;
770 condCodeIsPartOfName = 1;
774 case 0: instrName =
"breq";
break;
775 case 1: instrName =
"brne";
break;
776 case 2: instrName =
"brlt";
break;
777 case 3: instrName =
"brge";
break;
778 case 4: instrName =
"brlo";
break;
779 case 5: instrName =
"brhs";
break;
780 case 14: instrName =
"bbit0";
break;
781 case 15: instrName =
"bbit1";
break;
783 instrName =
"??? (0[3])";
789 instrName =
"??? (0[3])";
801 state->_load_len = 4;
805 state->_load_len = 1;
809 state->_load_len = 2;
812 instrName =
"??? (0[3])";
822 case 0: instrName =
"st";
break;
823 case 1: instrName =
"stb";
break;
824 case 2: instrName =
"stw";
break;
826 instrName =
"??? (2[3])";
835 subopcode =
BITS(
state->words[0], 16, 21);
837 case 0: instrName =
"add";
break;
838 case 1: instrName =
"adc";
break;
839 case 2: instrName =
"sub";
break;
840 case 3: instrName =
"sbc";
break;
841 case 4: instrName =
"and";
break;
842 case 5: instrName =
"or";
break;
843 case 6: instrName =
"bic";
break;
844 case 7: instrName =
"xor";
break;
845 case 8: instrName =
"max";
break;
846 case 9: instrName =
"min";
break;
848 if (
state->words[0] == 0x264a7000) {
869 case 14: instrName =
"rsub";
break;
870 case 15: instrName =
"bset";
break;
871 case 16: instrName =
"bclr";
break;
876 case 18: instrName =
"bxor";
break;
877 case 19: instrName =
"bmsk";
break;
878 case 20: instrName =
"add1";
break;
879 case 21: instrName =
"add2";
break;
880 case 22: instrName =
"add3";
break;
881 case 23: instrName =
"sub1";
break;
882 case 24: instrName =
"sub2";
break;
883 case 25: instrName =
"sub3";
break;
884 case 30: instrName =
"mpyw";
break;
885 case 31: instrName =
"mpyuw";
break;
896 condCodeIsPartOfName = 1;
902 condCodeIsPartOfName = 1;
921 case 0: instrName =
"asl";
break;
922 case 1: instrName =
"asr";
break;
923 case 2: instrName =
"lsr";
break;
924 case 3: instrName =
"ror";
break;
925 case 4: instrName =
"rrc";
break;
926 case 5: instrName =
"sexb";
break;
927 case 6: instrName =
"sexw";
break;
928 case 7: instrName =
"extb";
break;
929 case 8: instrName =
"extw";
break;
930 case 9: instrName =
"abs";
break;
931 case 10: instrName =
"not";
break;
932 case 11: instrName =
"rlc";
break;
966 if (
BITS(
state->words[0], 22, 23) == 1) {
971 case 4: instrName =
"rtie";
break;
972 case 5: instrName =
"brk";
break;
985 subopcode =
BITS(
state->words[0], 17, 21);
990 state->_load_len = 4;
994 state->_load_len = 1;
998 state->_load_len = 2;
1001 instrName =
"??? (0[3])";
1011 subopcode =
BITS(
state->words[0], 16, 21);
1012 switch (subopcode) {
1013 case 0: instrName =
"asl";
break;
1014 case 1: instrName =
"lsr";
break;
1015 case 2: instrName =
"asr";
break;
1016 case 3: instrName =
"ror";
break;
1018 instrName =
"mul64";
1023 instrName =
"mulu64";
1029 case 6: instrName =
"adds";
break;
1031 case 7: instrName =
"subs";
break;
1032 case 8: instrName =
"divaw";
break;
1033 case 0xA: instrName =
"asls";
break;
1034 case 0xB: instrName =
"asrs";
break;
1035 case 0x28: instrName =
"addsdw";
break;
1036 case 0x29: instrName =
"subsdw";
break;
1050 instrName =
"sat16";
1054 instrName =
"rnd16";
1058 instrName =
"abssw";
1066 instrName =
"negsw";
1075 instrName =
"normw";
1081 instrName =
"swape";
1093 instrName =
"??? (2[3])";
1102 subopcode =
BITS(
state->words[0], 0, 5);
1103 switch (subopcode) {
1104 case 26: instrName =
"rtsc";
break;
1106 instrName =
"??? (2[3])";
1118 subopcode =
BITS(
state->words[0], 17, 23);
1120 switch (subopcode) {
1123 instrName =
"vld32";
1132 instrName =
"vld64";
1141 instrName =
"vld64w";
1150 instrName =
"vld32wl";
1159 instrName =
"vld32wh";
1168 instrName =
"vld128";
1177 short sub_subopcode =
BITS(
state->words[0], 15, 16);
1178 switch (sub_subopcode) {
1180 instrName =
"vld128r";
1183 usesSimdRegB = usesSimdRegC = 0;
1191 instrName =
"vst16_0";
1200 instrName =
"vst16_1";
1209 instrName =
"vst16_2";
1218 instrName =
"vst16_3";
1227 instrName =
"vst16_4";
1236 instrName =
"vst16_5";
1245 instrName =
"vst16_6";
1254 instrName =
"vst16_7";
1263 instrName =
"vst32_0";
1272 instrName =
"vst32_2";
1281 instrName =
"vst32_4";
1290 instrName =
"vst32_6";
1299 instrName =
"vst64";
1308 instrName =
"vst128";
1317 short sub_subopcode =
BITS(
state->words[0], 15, 16);
1318 switch (sub_subopcode) {
1320 instrName =
"vst128r";
1323 usesSimdRegB = usesSimdRegC = 0;
1334 usesSimdRegA = usesSimdRegB = 1;
1340 instrName =
"vmvzw";
1342 usesSimdRegA = usesSimdRegB = 1;
1347 instrName =
"vmovw";
1350 usesSimdRegB = usesSimdRegC = 0;
1354 instrName =
"vmovzw";
1357 usesSimdRegB = usesSimdRegC = 0;
1361 instrName =
"vmvaw";
1363 usesSimdRegA = usesSimdRegB = 1;
1368 instrName =
"vmovaw";
1371 usesSimdRegB = usesSimdRegC = 0;
1375 short sub_subopcode =
BITS(
state->words[0], 15, 16);
1376 switch (sub_subopcode) {
1378 instrName =
"vaddw";
1380 usesSimdRegA = usesSimdRegB = usesSimdRegC = 1;
1384 instrName =
"vaddaw";
1386 usesSimdRegA = usesSimdRegB = usesSimdRegC = 1;
1390 instrName =
"vbaddw";
1392 usesSimdRegA = usesSimdRegB = 1;
1400 short sub_subopcode =
BITS(
state->words[0], 15, 16);
1401 switch (sub_subopcode) {
1403 instrName =
"vsubw";
1405 usesSimdRegA = usesSimdRegB = usesSimdRegC = 1;
1409 instrName =
"vsubaw";
1411 usesSimdRegA = usesSimdRegB = usesSimdRegC = 1;
1415 instrName =
"vbsubw";
1417 usesSimdRegA = usesSimdRegB = 1;
1424 short sub_subopcode =
BITS(
state->words[0], 15, 16);
1425 switch (sub_subopcode) {
1427 instrName =
"vmulw";
1429 usesSimdRegA = usesSimdRegB = usesSimdRegC = 1;
1433 instrName =
"vmulaw";
1435 usesSimdRegA = usesSimdRegB = usesSimdRegC = 1;
1439 instrName =
"vbmulw";
1441 usesSimdRegA = usesSimdRegB = 1;
1446 instrName =
"vbmulaw";
1448 usesSimdRegA = usesSimdRegB = 1;
1455 short sub_subopcode =
BITS(
state->words[0], 15, 16);
1456 switch (sub_subopcode) {
1458 instrName =
"vmulfw";
1460 usesSimdRegA = usesSimdRegB = usesSimdRegC = 1;
1464 instrName =
"vmulfaw";
1466 usesSimdRegA = usesSimdRegB = usesSimdRegC = 1;
1470 instrName =
"vbmulfw";
1472 usesSimdRegA = usesSimdRegB = 1;
1479 short sub_subopcode =
BITS(
state->words[0], 15, 16);
1480 switch (sub_subopcode) {
1482 instrName =
"vsummw";
1484 usesSimdRegA = usesSimdRegB = usesSimdRegC = 1;
1487 instrName =
"vbrsubw";
1489 usesSimdRegA = usesSimdRegB = 1;
1496 short sub_subopcode =
BITS(
state->words[0], 15, 16);
1497 switch (sub_subopcode) {
1499 instrName =
"vmr7w";
1501 usesSimdRegA = usesSimdRegB = usesSimdRegC = 1;
1505 instrName =
"vmr7aw";
1507 usesSimdRegA = usesSimdRegB = usesSimdRegC = 1;
1513 instrName =
"vaddsuw";
1515 usesSimdRegC = usesSimdRegB = 1;
1520 instrName =
"vabsw";
1522 usesSimdRegC = usesSimdRegB = 1;
1527 instrName =
"vsignw";
1529 usesSimdRegC = usesSimdRegB = 1;
1534 instrName =
"vupbw";
1536 usesSimdRegC = usesSimdRegB = 1;
1541 instrName =
"vexch1";
1543 usesSimdRegC = usesSimdRegB = 1;
1548 instrName =
"vexch2";
1550 usesSimdRegC = usesSimdRegB = 1;
1555 instrName =
"vexch4";
1557 usesSimdRegC = usesSimdRegB = 1;
1562 instrName =
"vupsbw";
1564 usesSimdRegC = usesSimdRegB = 1;
1569 instrName =
"vdirun";
1571 usesSimdRegC = usesSimdRegB = usesSimdRegA = 0;
1575 instrName =
"vdorun";
1577 usesSimdRegC = usesSimdRegB = usesSimdRegA = 0;
1581 instrName =
"vdiwr";
1584 usesSimdRegA = usesSimdRegC = 0;
1588 instrName =
"vdowr";
1591 usesSimdRegA = usesSimdRegC = 0;
1595 instrName =
"vdird";
1603 instrName =
"vdord";
1611 switch (
BITS(
state->words[0], 24, 25)) {
1616 usesSimdRegB = usesSimdRegA = 0;
1620 instrName =
"vrecrun";
1623 usesSimdRegA = usesSimdRegB = 0;
1630 usesSimdRegB = usesSimdRegA = 0;
1634 instrName =
"vendrec";
1637 usesSimdRegB = usesSimdRegA = 0;
1647 instrName =
"vabsaw";
1649 usesSimdRegC = usesSimdRegB = 1;
1653 instrName =
"vupbaw";
1655 usesSimdRegC = usesSimdRegB = 1;
1659 instrName =
"vupsbaw";
1661 usesSimdRegC = usesSimdRegB = 1;
1670 instrName =
"vasrw";
1672 usesSimdRegA = usesSimdRegB = 1;
1677 short sub_subopcode =
BITS(
state->words[0], 15, 16);
1678 switch (sub_subopcode) {
1680 instrName =
"vasrwi";
1682 usesSimdRegA = usesSimdRegB = 1;
1686 instrName =
"vasrrwi";
1688 usesSimdRegA = usesSimdRegB = 1;
1695 instrName =
"vasrsrwi";
1697 usesSimdRegA = usesSimdRegB = 1;
1702 short sub_subopcode =
BITS(
state->words[0], 15, 16);
1703 switch (sub_subopcode) {
1705 instrName =
"vmaxw";
1709 instrName =
"vmaxaw";
1713 instrName =
"vbmaxw";
1718 usesSimdRegA = usesSimdRegB = 1;
1723 short sub_subopcode =
BITS(
state->words[0], 15, 16);
1724 switch (sub_subopcode) {
1726 instrName =
"vminw";
1730 instrName =
"vminaw";
1734 instrName =
"vbminw";
1739 usesSimdRegA = usesSimdRegB = 1;
1744 short sub_subopcode =
BITS(
state->words[0], 15, 16);
1745 switch (sub_subopcode) {
1747 instrName =
"vdifw";
1750 instrName =
"vdifaw";
1757 usesSimdRegA = usesSimdRegB = usesSimdRegC = 1;
1762 short sub_subopcode =
BITS(
state->words[0], 15, 16);
1763 switch (sub_subopcode) {
1767 usesSimdRegA = usesSimdRegB = usesSimdRegC = 1;
1770 instrName =
"vandaw";
1772 usesSimdRegA = usesSimdRegB = usesSimdRegC = 1;
1779 short sub_subopcode =
BITS(
state->words[0], 15, 16);
1780 switch (sub_subopcode) {
1784 usesSimdRegA = usesSimdRegB = usesSimdRegC = 1;
1791 short sub_subopcode =
BITS(
state->words[0], 15, 16);
1792 switch (sub_subopcode) {
1797 instrName =
"vxoraw";
1801 usesSimdRegA = usesSimdRegB = usesSimdRegC = 1;
1806 short sub_subopcode =
BITS(
state->words[0], 15, 16);
1807 switch (sub_subopcode) {
1812 instrName =
"vbicaw";
1816 usesSimdRegA = usesSimdRegB = usesSimdRegC = 1;
1821 short sub_subopcode =
BITS(
state->words[0], 15, 16);
1822 switch (sub_subopcode) {
1827 instrName =
"vavrb";
1831 usesSimdRegA = usesSimdRegB = usesSimdRegC = 1;
1838 usesSimdRegA = usesSimdRegB = usesSimdRegC = 1;
1844 usesSimdRegA = usesSimdRegB = usesSimdRegC = 1;
1850 usesSimdRegA = usesSimdRegB = usesSimdRegC = 1;
1856 usesSimdRegA = usesSimdRegB = usesSimdRegC = 1;
1860 short sub_subopcode =
BITS(
state->words[0], 15, 16);
1861 switch (sub_subopcode) {
1863 instrName =
"vasrpwbi";
1865 usesSimdRegA = usesSimdRegB = 1;
1869 instrName =
"vasrrpwbi";
1871 usesSimdRegA = usesSimdRegB = 1;
1879 short sub_subopcode =
BITS(
state->words[0], 15, 16);
1880 switch (sub_subopcode) {
1884 usesSimdRegA = usesSimdRegB = 1;
1889 instrName =
"vsr8aw";
1891 usesSimdRegA = usesSimdRegB = 1;
1899 short sub_subopcode =
BITS(
state->words[0], 15, 16);
1900 switch (sub_subopcode) {
1902 instrName =
"vsr8i";
1904 usesSimdRegA = usesSimdRegB = 1;
1909 instrName =
"vsr8awi";
1911 usesSimdRegA = usesSimdRegB = 1;
1921 short subopcode2 =
BITS(
state->words[0], 15, 18);
1922 switch (subopcode2) {
1924 instrName =
"vmr1w";
1928 instrName =
"vmr2w";
1932 instrName =
"vmr3w";
1936 instrName =
"vmr4w";
1940 instrName =
"vmr5w";
1944 instrName =
"vmr6w";
1948 instrName =
"vmr1aw";
1952 instrName =
"vmr2aw";
1956 instrName =
"vmr3aw";
1960 instrName =
"vmr4aw";
1964 instrName =
"vmr5aw";
1968 instrName =
"vmr6aw";
1973 usesSimdRegA = usesSimdRegB = usesSimdRegC = 1;
1979 switch (
BITS(
state->words[0], 16, 19)) {
1981 instrName =
"vh264ft";
1984 instrName =
"vh264f";
1987 instrName =
"vvc1ft";
1990 instrName =
"vvc1f";
1994 usesSimdRegA = usesSimdRegB = usesSimdRegC = 1;
1999 instrName =
"vd6tapf";
2001 usesSimdRegA = usesSimdRegB = 1;
2006 instrName =
"vinti";
2008 usesSimdRegA = usesSimdRegB = usesSimdRegC = 0;
2017 instrName =
"???_SIMD";
2026 case 0: instrName =
"ld_s";
break;
2027 case 1: instrName =
"ldb_s";
break;
2028 case 2: instrName =
"ldw_s";
break;
2029 case 3: instrName =
"add_s";
break;
2031 instrName =
"??? (2[3])";
2041 case 0: instrName =
"add_s";
break;
2042 case 1: instrName =
"sub_s";
break;
2043 case 2: instrName =
"asl_s";
break;
2044 case 3: instrName =
"asr_s";
break;
2046 instrName =
"??? (2[3])";
2056 case 0: instrName =
"add_s";
break;
2059 instrName =
"mov_s";
2063 instrName =
"cmp_s";
2067 instrName =
"??? (2[3])";
2087 state->isBranch = 1;
2092 instrName =
"j_s.d";
2097 instrName =
"jl_s.d";
2099 state->isBranch = 1;
2103 instrName =
"sub_s.ne";
2110 instrName =
"nop_s";
2114 case 1: instrName =
"unimp_s";
break;
2117 instrName =
"jeq_s [blink]";
2121 instrName =
"jne_s [blink]";
2126 instrName =
"j_s [blink]";
2128 state->isBranch = 1;
2133 instrName =
"j_s.d [blink]";
2135 state->isBranch = 1;
2139 instrName =
"??? (2[3])";
2145 instrName =
"??? (2[3])";
2150 case 2: instrName =
"sub_s";
break;
2151 case 4: instrName =
"and_s";
break;
2152 case 5: instrName =
"or_s";
break;
2153 case 6: instrName =
"bic_s";
break;
2154 case 7: instrName =
"xor_s";
break;
2156 instrName =
"tst_s";
2160 instrName =
"mul64_s";
2165 instrName =
"sexb_s";
2169 instrName =
"sexw_s";
2173 instrName =
"extb_s";
2177 instrName =
"extw_s";
2181 instrName =
"abs_s";
2185 instrName =
"not_s";
2189 instrName =
"neg_s";
2192 case 20: instrName =
"add1_s";
break;
2193 case 21: instrName =
"add2_s";
break;
2194 case 22: instrName =
"add3_s";
break;
2195 case 24: instrName =
"asl_s";
break;
2196 case 25: instrName =
"lsr_s";
break;
2197 case 26: instrName =
"asr_s";
break;
2199 instrName =
"asl_s";
2203 instrName =
"asr_s";
2207 instrName =
"lsr_s";
2211 instrName =
"trap_s";
2215 instrName =
"brk_s";
2220 instrName =
"??? (2[3])";
2234 instrName =
"ldb_s";
2240 instrName =
"ldw_s";
2246 instrName =
"ldw_s.x";
2258 instrName =
"stb_s";
2264 instrName =
"stw_s";
2272 case 0: instrName =
"asl_s";
break;
2273 case 1: instrName =
"lsr_s";
break;
2274 case 2: instrName =
"asr_s";
break;
2275 case 3: instrName =
"sub_s";
break;
2276 case 4: instrName =
"bset_s";
break;
2277 case 5: instrName =
"bclr_s";
break;
2278 case 6: instrName =
"bmsk_s";
break;
2280 instrName =
"btst_s";
2290 case 0: instrName =
"ld_s";
break;
2291 case 1: instrName =
"ldb_s";
break;
2292 case 2: instrName =
"st_s";
break;
2293 case 3: instrName =
"stb_s";
break;
2294 case 4: instrName =
"add_s";
break;
2297 instrName =
"add_s";
2299 instrName =
"sub_s";
2303 instrName =
"pop_s";
2307 instrName =
"push_s";
2311 instrName =
"??? (2[3])";
2321 case 0: instrName =
"ld_s";
break;
2322 case 1: instrName =
"ldb_s";
break;
2323 case 2: instrName =
"ldw_s";
break;
2324 case 3: instrName =
"add_s";
break;
2336 instrName =
"mov_s";
2344 instrName =
"cmp_s";
2346 instrName =
"add_s";
2354 instrName =
"brne_s";
2356 instrName =
"breq_s";
2358 state->isBranch = 1;
2364 state->isBranch = 1;
2366 case 0: instrName =
"b_s";
break;
2367 case 1: instrName =
"beq_s";
break;
2368 case 2: instrName =
"bne_s";
break;
2371 case 0: instrName =
"bgt_s";
break;
2372 case 1: instrName =
"bge_s";
break;
2373 case 2: instrName =
"blt_s";
break;
2374 case 3: instrName =
"ble_s";
break;
2375 case 4: instrName =
"bhi_s";
break;
2376 case 5: instrName =
"bhs_s";
break;
2377 case 6: instrName =
"blo_s";
break;
2378 case 7: instrName =
"bls_s";
break;
2388 state->isBranch = 1;
2407 if (
state->instructionLen == 2) {
2451 fieldAisReg = fieldBisReg = fieldCisReg = 1;
2452 flag =
cond = is_shimm = is_limm = 0;
2454 signExtend = addrWriteBack = directMem = 0;
2458 switch (decodingClass) {
2463 subopcode =
BITS(
state->words[0], 22, 23);
2464 switch (subopcode) {
2497 state->_offset += fieldB,
state->_ea_present = 0;
2514 state->_offset += fieldB,
state->_ea_present = 0;
2516 fieldAisReg = fieldA = 0;
2534 fieldAisReg = fieldA = 0;
2538 }
else if (fieldC == 62) {
2572 if (
BITS(
state->words[0], 22, 23) == 1) {
2576 state->ea_reg1 = fieldC;
2580 state->_offset += fieldB,
state->_ea_present = 0;
2595 subopcode =
BITS(
state->words[0], 22, 23);
2596 if (subopcode == 0 || ((subopcode == 3) && (!
BIT(
state->words[0], 5)))) {
2606 }
else if (subopcode == 1 || ((subopcode == 3) && (
BIT(
state->words[0], 5)))) {
2610 }
else if (subopcode == 2) {
2619 state->ea_reg1 = fieldC;
2623 state->_offset += fieldB,
state->_ea_present = 0;
2646 subopcode =
BITS(
state->words[0], 22, 23);
2648 if (subopcode == 0 || ((subopcode == 3) && (!
BIT(
state->words[0], 5)))) {
2650 }
else if (subopcode == 1 || ((subopcode == 3) && (
BIT(
state->words[0], 5)))) {
2653 }
else if (subopcode == 2) {
2672 subopcode =
BITS(
state->words[0], 22, 23);
2673 if (subopcode == 0 || ((subopcode == 3) && (!
BIT(
state->words[0], 5)))) {
2676 if (fieldC == 29 || fieldC == 31)
2678 }
else if (subopcode == 1 || ((subopcode == 3) && (
BIT(
state->words[0], 5)))) {
2681 }
else if (subopcode == 2) {
2702 state->register_for_indirect_jump = fieldC;
2706 strcat(formatString,
2724 instrName =
"prefetch";
2736 state->_ea_present = 1;
2738 state->ea_reg1 = fieldB;
2740 state->_offset += fieldB;
2743 state->ea_reg2 = fieldC;
2745 state->_offset += fieldC;
2747 state->_mem_load = 1;
2749 directMem =
BIT(
state->words[0], 15);
2757 if (fieldBisReg && (fieldB != 62))
2759 addrWriteBack =
BITS(
state->words[0], 22, 23);
2760 signExtend =
BIT(
state->words[0], 16);
2768 strcat(formatString,
"%*");
2772 if (fieldBisReg || fieldB != 0) {
2790 instrName =
"prefetch";
2796 state->_ea_present = 1;
2797 state->_offset = fieldC;
2798 state->_mem_load = 1;
2800 state->ea_reg1 = fieldB;
2804 state->_offset += fieldB,
state->_ea_present = 0;
2807 directMem =
BIT(
state->words[0], 11);
2810 if (fieldBisReg && (fieldB != 62)) {
2811 addrWriteBack =
BITS(
state->words[0], 9, 10);
2813 signExtend =
BIT(
state->words[0], 6);
2819 strcat(formatString,
"%*");
2823 fieldB =
state->_offset;
2836 state->source_operand.registerNum = fieldC;
2841 state->_ea_present = 1;
2842 state->_offset = fieldA;
2844 state->ea_reg1 = fieldB;
2851 state->_offset += fieldB,
state->_ea_present = 0;
2854 directMem =
BIT(
state->words[0], 5);
2855 addrWriteBack =
BITS(
state->words[0], 3, 4);
2872 switch (
BITS(
state->words[0], 22, 23)) {
2906 if (is_limm ||
BIT(
state->words[0], 4)) {
2914 fieldA += (
addr & ~0x3);
2923 strcat(formatString,
",%s");
2931 switch (
BITS(
state->words[0], 22, 23)) {
2957 if (
BITS(
state->words[0], 22, 23) == 3) {
2964 fieldC = fieldC << 1;
2965 fieldC += (
addr & ~0x3);
2973 strcat(formatString,
"%s");
2980 subopcode =
BITS(
state->words[0], 22, 23);
2981 if (subopcode == 0 || ((subopcode == 3) && (!
BIT(
state->words[0], 5)))) {
2983 }
else if (subopcode == 1 || ((subopcode == 3) && (
BIT(
state->words[0], 5)))) {
2986 }
else if (subopcode == 2) {
2990 if (subopcode == 3) {
3010 fieldA = (
BITS(
state->words[0], 0, 4)) << 10;
3017 fieldA = fieldA << 9;
3018 fieldA |=
BITS(
state->words[0], 18, 26);
3019 fieldA = fieldA << 2;
3021 fieldA = fieldA << 10;
3022 fieldA |=
BITS(
state->words[0], 17, 26);
3023 fieldA = fieldA << 1;
3035 fieldA += (
addr & ~0x3);
3056 strcat(formatString,
"%s");
3069 fieldA = fieldAisReg = 0;
3145 }
else if (
BITS(
state->words[0], 3, 4) == 3) {
3210 fieldC = fieldC << 2;
3213 fieldC = fieldC << 1;
3220 if (
BITS(
state->words[0], 9, 10) != 3) {
3296 fieldA = (
BITS(
state->words[0], 0, 10)) << 2;
3298 }
else if (
BITS(
state->words[0], 9, 10) != 3) {
3299 fieldA = (
BITS(
state->words[0], 0, 8)) << 1;
3302 fieldA = (
BITS(
state->words[0], 0, 5)) << 1;
3305 fieldA += (
addr & ~0x3);
3316 strcat(formatString,
"%s");
3325 fieldC = (
BITS(
state->words[0], 0, 6)) << 1;
3328 fieldC += (
addr & ~0x3);
3329 fieldA = fieldAisReg = 0;
3338 strcat(formatString,
",%s");
3348 state->operandBuffer[0] =
'\0';
3357 strcat(formatString,
"[%r]");
3367 switch (
state->_opcode) {
3400 fieldA = (
BITS(
state->words[0], 0, 7)) << 2;
3434 }
else if (
BITS(
state->words[0], 0, 4) == 17) {
3459 state->operandBuffer[0] =
'\0';
3474 strcat(formatString,
"%d");
3491 directMem =
BIT(
state->words[0], 15);
3493 if (
BITS(
state->words[0], 22, 23) == 1) {
3497 state->ea_reg1 = fieldC;
3515 strcat(formatString,
"%r,%r,%r");
3535 fieldB = fieldBisReg = 0;
3563 if (decodingClass == 41) {
3568 if (simd_scale_u8 > 0) {
3569 fieldC = fieldC << simd_scale_u8;
3634 if (
BITS(
state->words[0], 17, 23) == 55) {
3645 mwerror(
state,
"Bad decoding class in ARC disassembler");
3709 enable_insn_stream = 1;
3730 int lowbyte, highbyte;
3733 if (
info->disassembler_options) {
3753 if (((
buffer[lowbyte] & 0xf8) > 0x38) && ((
buffer[lowbyte] & 0xf8) != 0x48)) {
3754 s.instructionLen = 2;
3763 s.instructionLen = 4;
3796 char *instr =
s.instrBuffer;
3798 char *space = strchr(instr,
' ');
3800 if (enable_insn_stream) {
3803 if (
s.instructionLen == 2) {
3804 (*func)(
stream,
" %04x ", (
unsigned int)
s.words[0]);
3806 (*func)(
stream,
"%08x ", (
unsigned int)
s.words[0]);
3818 (*func)(
stream,
"%s ", instr);
3829 buf[
sizeof(
buf) - 1] =
'\0';
3830 tmpBuffer = strtok(
buf,
"@");
3831 (*func)(
stream,
"%s", tmpBuffer);
3832 i = strlen(tmpBuffer) + 1;
3844 info->bytes_per_line = 8;
3863 int lowbyte, highbyte;
3875 s.instructionLen = -1;
3879 if (((
buffer[lowbyte] & 0xf8) > 0x38) && ((
buffer[lowbyte] & 0xf8) != 0x48)) {
3880 s.instructionLen = 2;
3889 s.instructionLen = 4;
3893 s.instructionLen = -1;
3927 ARC-specific disassembler options:\n\
3928 use with the -M switch, with options separated by commas\n\n");
3930 fprintf(
stream,
" insn-stream Show the instruction byte stream from most\n");
3931 fprintf(
stream,
" significant byte to least significant byte (excluding LIMM).\n");
3932 fprintf(
stream,
" This option is useful for viewing the actual encoding of instructions.\n");
3934 fprintf(
stream,
" simd Enable SIMD instructions disassembly.\n\n");
static const char * core_reg_name(struct arcDisState *state, int val)
#define __TRANSLATION_REQUIRED(state)
const char * arcExtMap_auxRegName(long address)
const char * arcExtMap_instName(int opcode, int insn, int *flags)
const char * arcExtMap_condCodeName(int code)
const char * arcExtMap_coreRegName(int regnum)
char * arc_aux_reg_name(int regVal)
static int dsmOneArcInst(bfd_vma addr, struct arcDisState *state, disassemble_info *info)
static const char * _coreRegName(void *_this ATTRIBUTE_UNUSED, int v)
static int sign_extend(int value, int bits)
disassemble_info tm_print_insn_info
#define WRITE_FORMAT_COMMA_x(x)
static const char * cond_code_name(struct arcDisState *state, int val)
#define write_instr_name()
#define CHECK_FLAG_COND()
struct arcDisState arcAnalyzeInstr(bfd_vma address, disassemble_info *info)
#define REG2NAME(num, name)
void arc_print_disassembler_options(FILE *stream)
#define WRITE_FORMAT_LB()
static const char * condName[]
#define WRITE_FORMAT_x(x)
#define CHECK_COND_NULLIFY()
#define WRITE_FORMAT_COMMA_x_RB(x)
#define WRITE_FORMAT_RB()
static const char * _instName(void *_this ATTRIBUTE_UNUSED, int op1, int op2, int *flags)
static void mwerror(struct arcDisState *state, const char *msg)
static const char * _auxRegName(void *_this ATTRIBUTE_UNUSED, int v)
#define WRITE_FORMAT_x_COMMA_LB(x)
static void my_sprintf(struct arcDisState *state, char *buf, const char *format,...)
#define WRITE_NOP_COMMENT()
static const char * post_address(struct arcDisState *state, int addr)
int ARCompact_decodeInstr(bfd_vma address, disassemble_info *info)
static const char * instruction_name(struct arcDisState *state, int op1, int op2, int *flags)
static bfd_vma bfd_getm32_ac(unsigned int)
#define WRITE_FORMAT_x_COMMA(x)
static bfd_vma bfd_getm32(unsigned int)
static const char * aux_reg_name(struct arcDisState *state, int val)
#define CHECK_FIELD_H_AC()
#define WRITE_FORMAT_x_RB(x)
static void write_instr_name_(struct arcDisState *state, const char *instrName, int cond, int condCodeIsPartOfName, int flag, int signExtend, int addrWriteBack, int directMem)
static void parse_disassembler_options(char *options)
static const char * _condCodeName(void *_this ATTRIBUTE_UNUSED, int v)
static RzILOpEffect * mul(cs_insn *insn, bool is_thumb)
RzBinInfo * info(RzBinFile *bf)
int bits(struct state *s, int need)
int(* fprintf_ftype)(void *, const char *,...) ATTRIBUTE_FPTR_PRINTF_2
return memset(p, 0, total)
static const char struct stat static buf struct stat static buf static vhangup int options
static const char struct stat static buf struct stat static buf static vhangup int status
#define CONST_STRNEQ(STR1, STR2)
BFD_HOST_U_64_BIT bfd_vma
static bfd_vma bfd_getb32(const void *p)
static bfd_vma bfd_getl32(const void *p)
static struct sockaddr static addrlen static backlog const void static flags void flags
static struct sockaddr static addrlen static backlog const void msg
#define cond(bop, top, mask, flags)