annotate ticoff/thumbdis.c @ 111:0f94d17899b3

tiobjd: disassembly integrated, no relocs or hints yet
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Thu, 03 Apr 2014 05:14:15 +0000
parents
children d97fbe98600b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * Thumb state disassembly
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 */
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 #include <sys/types.h>
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <stdio.h>
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <stdlib.h>
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <string.h>
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include <strings.h>
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 #include "intstruct.h"
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #include "globals.h"
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 extern unsigned get_u16(), get_u32();
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 extern char *regnames[16], *condition_decode[16], *shift_types[4];
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 static void
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 format_1_2(word)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 unsigned word;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 unsigned op, imm;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 op = (word >> 11) & 3;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 if (op != 3) {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 /* format 1 */
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 imm = (word >> 6) & 0x1F;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 if (op != 0 && imm == 0)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 imm = 32;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 printf("%s\t%s, %s, #%u\n", shift_types[op], regnames[word&7],
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 regnames[(word>>3)&7], imm);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 return;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 /* format 2 */
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 printf("%s\t%s, %s, ", word&0x200 ? "sub" : "add", regnames[word&7],
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 regnames[(word>>3)&7]);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 if (word & 0x400)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 printf("#%u\n", (word >> 6) & 7);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 else
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 printf("%s\n", regnames[(word >> 6) & 7]);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 static void
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 format_3(word)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 unsigned word;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 static char *opctab[4] = {"mov", "cmp", "add", "sub"};
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 unsigned imm;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 imm = word & 0xFF;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 printf("%s\t%s, #%u", opctab[(word>>11)&3], regnames[(word>>8)&7], imm);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 if (imm > 9)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52 printf("\t; 0x%x", imm);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 putchar('\n');
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 static void
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57 format_4(word)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58 unsigned word;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59 {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60 static char *opc[16] = {"and", "eor", "lsl", "lsr",
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61 "asr", "adc", "sbc", "ror",
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62 "tst", "neg", "cmp", "cmn",
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63 "orr", "mul", "bic", "mvn"};
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
64
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
65 printf("%s\t%s, %s\n", opc[(word>>6)&0xF], regnames[word&7],
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
66 regnames[(word>>3)&7]);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
67 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
68
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
69 static void
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
70 format_5_bx(word)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
71 unsigned word;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
72 {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
73 if (word & 0x80)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
74 printf("<invalid: blx instead of bx>\n");
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
75 else
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
76 printf("bx\t%s\n", regnames[(word>>3)&0xF]);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
77 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
78
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
79 static void
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
80 format_5_hiops(word)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
81 unsigned word;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
82 {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
83 static char *opctab[3] = {"add", "cmp", "mov"};
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
84 int reg1, reg2, op;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
85
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
86 if (word & 0xC0) {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
87 reg1 = word & 7;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
88 if (word & 0x80)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
89 reg1 += 8;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
90 reg2 = (word >> 3) & 0xF;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
91 op = (word >> 8) & 3;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
92 if (op == 2 && reg1 == reg2 && reg1 != 15)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
93 printf("nop\t\t\t(mov %s, %s)\n",
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
94 regnames[reg1], regnames[reg2]);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
95 else
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
96 printf("%s\t%s, %s\n", opctab[op],
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
97 regnames[reg1], regnames[reg2]);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
98 } else
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
99 printf("<invalid: hi-reg format with both low regs>\n");
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
100 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
101
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
102 static void
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
103 format_5(word)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
104 unsigned word;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
105 {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
106 if ((word & 0x300) == 0x300)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
107 format_5_bx(word);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
108 else
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
109 format_5_hiops(word);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
110 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
111
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
112 static void
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
113 format_6(sec, off, word)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
114 struct internal_scnhdr *sec;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
115 unsigned off, word;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
116 {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
117 unsigned loff, litoff;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
118
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
119 loff = (word & 0xFF) << 2;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
120 off &= ~3;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
121 off += 4;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
122 litoff = off + loff;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
123 if (litoff+4 <= sec->size)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
124 printf("ldr\t%s, =0x%x\t; via 0x%x\n", regnames[(word>>8)&7],
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
125 get_u32(filemap + sec->data_offset + litoff), litoff);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
126 else
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
127 printf("ldr\t%s, [pc, #%u]\t(0x%x)\n", regnames[(word>>8)&7],
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
128 loff, litoff);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
129 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
130
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
131 static void
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
132 format_7(word)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
133 unsigned word;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
134 {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
135 printf("%s%s\t%s, [%s, %s]\n", word&0x800 ? "ldr" : "str",
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
136 word&0x400 ? "b" : "", regnames[word&7],
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
137 regnames[(word>>3)&7], regnames[(word>>6)&7]);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
138 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
139
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
140 static void
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
141 format_8(word)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
142 unsigned word;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
143 {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
144 static char *opc[4] = {"strh", "ldrsb", "ldrh", "ldrsh"};
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
145
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
146 printf("%s\t%s, [%s, %s]\n", opc[(word>>10)&3], regnames[word&7],
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
147 regnames[(word>>3)&7], regnames[(word>>6)&7]);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
148 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
149
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
150 static void
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
151 format_9(word)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
152 unsigned word;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
153 {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
154 unsigned loff;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
155
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
156 loff = (word >> 6) & 0x1F;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
157 if (!(word & 0x1000))
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
158 loff <<= 2;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
159 printf("%s%s\t%s, [%s, #%u]", word&0x800 ? "ldr" : "str",
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
160 word&0x1000 ? "b" : "", regnames[word&7],
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
161 regnames[(word>>3)&7], loff);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
162 if (loff >= 10)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
163 printf("\t; 0x%x", loff);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
164 putchar('\n');
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
165 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
166
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
167 static void
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
168 format_10(word)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
169 unsigned word;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
170 {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
171 unsigned loff;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
172
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
173 loff = (word >> 6) & 0x1F;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
174 loff <<= 1;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
175 printf("%sh\t%s, [%s, #%u]", word&0x800 ? "ldr" : "str",
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
176 regnames[word&7], regnames[(word>>3)&7], loff);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
177 if (loff >= 10)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
178 printf("\t; 0x%x", loff);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
179 putchar('\n');
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
180 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
181
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
182 static void
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
183 format_11(word)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
184 unsigned word;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
185 {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
186 unsigned loff;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
187
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
188 loff = (word & 0xFF) << 2;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
189 printf("%s\t%s, [sp, #%u]", word&0x800 ? "ldr" : "str",
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
190 regnames[(word>>8)&7], loff);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
191 if (loff >= 10)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
192 printf("\t; 0x%x", loff);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
193 putchar('\n');
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
194 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
195
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
196 static void
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
197 format_12(off, word)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
198 unsigned off, word;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
199 {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
200 unsigned loff;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
201
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
202 loff = (word & 0xFF) << 2;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
203 printf("add\t%s, %s, #%u", regnames[(word>>8)&7],
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
204 word&0x800 ? "sp" : "pc", loff);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
205 if (loff >= 10)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
206 printf("\t; 0x%x", loff);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
207 putchar('\n');
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
208 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
209
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
210 static void
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
211 format_13(word)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
212 unsigned word;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
213 {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
214 unsigned loff;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
215
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
216 if ((word & 0xFF00) != 0xB000) {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
217 printf("<invalid format 13>\n");
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
218 return;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
219 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
220 loff = (word & 0x7F) << 2;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
221 printf("%s\tsp, #%u", word&0x80 ? "sub" : "add", loff);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
222 if (loff >= 10)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
223 printf("\t; 0x%x", loff);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
224 putchar('\n');
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
225 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
226
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
227 static void
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
228 format_14(word)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
229 unsigned word;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
230 {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
231 int r, flag;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
232
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
233 if ((word & 0xF600) != 0xB400) {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
234 printf("<invalid format 14>\n");
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
235 return;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
236 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
237 printf("%s\t{", word&0x800 ? "pop" : "push");
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
238 flag = 0;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
239 for (r = 0; r < 9; r++)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
240 if (word & (1 << r)) {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
241 if (flag)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
242 fputs(", ", stdout);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
243 if (r == 8)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
244 fputs(word&0x800 ? "pc" : "lr", stdout);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
245 else
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
246 fputs(regnames[r], stdout);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
247 flag = 1;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
248 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
249 putchar('}');
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
250 putchar('\n');
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
251 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
252
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
253 static void
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
254 format_15(word)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
255 unsigned word;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
256 {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
257 int r, flag;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
258
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
259 printf("%sia\t%s!, {", word&0x800 ? "ldm" : "stm",
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
260 regnames[(word>>8)&7]);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
261 flag = 0;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
262 for (r = 0; r < 8; r++)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
263 if (word & (1 << r)) {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
264 if (flag)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
265 fputs(", ", stdout);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
266 fputs(regnames[r], stdout);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
267 flag = 1;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
268 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
269 putchar('}');
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
270 putchar('\n');
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
271 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
272
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
273 static void
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
274 format_16_17(off, word)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
275 unsigned off, word;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
276 {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
277 unsigned cond;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
278 unsigned dest;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
279
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
280 cond = (word >> 8) & 0xF;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
281 switch (cond) {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
282 case 0xE:
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
283 printf("<invalid: bal>\n");
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
284 return;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
285 case 0xF:
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
286 printf("swi\t0x%x\n", word & 0xFF);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
287 return;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
288 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
289 dest = (word & 0xFF) << 1;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
290 if (dest & 0x00000100)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
291 dest |= 0xFFFFFE00;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
292 dest += off + 4;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
293 printf("b%s\t0x%x\n", condition_decode[cond], dest);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
294 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
295
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
296 static void
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
297 format_18(off, word)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
298 unsigned off, word;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
299 {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
300 unsigned dest;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
301
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
302 if (word & 0x800) {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
303 printf("<invalid format 18>\n");
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
304 return;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
305 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
306 dest = (word & 0x7FF) << 1;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
307 if (dest & 0x00000800)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
308 dest |= 0xFFFFF000;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
309 dest += off + 4;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
310 printf("b\t0x%x\n", dest);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
311 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
312
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
313 void
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
314 thumb_disasm_line(sec, off)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
315 struct internal_scnhdr *sec;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
316 unsigned off;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
317 {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
318 unsigned word;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
319
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
320 word = get_u16(filemap + sec->data_offset + off);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
321 printf("%04x\t\t", word);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
322 switch (word >> 12) {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
323 case 0:
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
324 case 1:
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
325 format_1_2(word);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
326 return;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
327 case 2:
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
328 case 3:
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
329 format_3(word);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
330 return;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
331 case 4:
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
332 if (word & 0x800)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
333 format_6(sec, off, word);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
334 else if (word & 0x400)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
335 format_5(word);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
336 else
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
337 format_4(word);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
338 return;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
339 case 5:
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
340 if (word & 0x200)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
341 format_8(word);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
342 else
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
343 format_7(word);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
344 return;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
345 case 6:
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
346 case 7:
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
347 format_9(word);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
348 return;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
349 case 8:
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
350 format_10(word);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
351 return;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
352 case 9:
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
353 format_11(word);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
354 return;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
355 case 0xA:
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
356 format_12(off, word);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
357 return;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
358 case 0xB:
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
359 if (word & 0x400)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
360 format_14(word);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
361 else
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
362 format_13(word);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
363 return;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
364 case 0xC:
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
365 format_15(word);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
366 return;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
367 case 0xD:
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
368 format_16_17(off, word);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
369 return;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
370 case 0xE:
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
371 format_18(off, word);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
372 return;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
373 case 0xF:
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
374 printf("<half-bl>\n");
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
375 return;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
376 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
377 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
378
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
379 thumb_check_bl(sec, off)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
380 struct internal_scnhdr *sec;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
381 unsigned off;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
382 {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
383 unsigned ins1, ins2;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
384 unsigned dest;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
385
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
386 ins1 = get_u16(filemap + sec->data_offset + off);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
387 if ((ins1 & 0xF800) != 0xF000)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
388 return(0);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
389 ins2 = get_u16(filemap + sec->data_offset + off + 2);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
390 if ((ins2 & 0xF800) != 0xF800)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
391 return(0);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
392 /* match */
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
393 dest = ((ins1 & 0x7FF) << 12) | ((ins2 & 0x7FF) << 1);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
394 if (dest & 0x00400000)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
395 dest |= 0xFF800000;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
396 dest += off + 4;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
397 printf("%04x %04x\tbl\t0x%x\n", ins1, ins2, dest);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
398 return(1);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
399 }