comparison arm7dis/armdis.c @ 90:f68d8e7a904f

armdis: implemented decoding of multiplication instructions
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sat, 29 Mar 2014 22:19:21 +0000
parents c5d52666d2eb
children daf69d5edb3f
comparison
equal deleted inserted replaced
89:c5d52666d2eb 90:f68d8e7a904f
97 else 97 else
98 op2_regshift(word); 98 op2_regshift(word);
99 } 99 }
100 100
101 static void 101 static void
102 dataproc_74_overlay(off, word) 102 dataproc_tstcmp_overlay(word)
103 unsigned off, word; 103 unsigned word;
104 {
105 printf("<dataproc overlay with 7&4 set>\n");
106 }
107
108 static void
109 dataproc_tstcmp_overlay(off, word)
110 unsigned off, word;
111 { 104 {
112 char msrmask[5], *cp; 105 char msrmask[5], *cp;
113 106
114 if ((word & 0x0FFFFFF0) == 0x012FFF10) { 107 if ((word & 0x0FFFFFF0) == 0x012FFF10) {
115 printf("bx%s\t%s\n", condition_decode[word>>28], 108 printf("bx%s\t%s\n", condition_decode[word>>28],
144 } 137 }
145 printf("<invalid BX/MRS/MSR>\n"); 138 printf("<invalid BX/MRS/MSR>\n");
146 } 139 }
147 140
148 static void 141 static void
149 dataproc(off, word) 142 dataproc(word)
150 unsigned off, word; 143 unsigned word;
151 { 144 {
152 unsigned opc; 145 unsigned opc;
153 146
154 opc = (word >> 21) & 0xF; 147 opc = (word >> 21) & 0xF;
155 switch (opc) { 148 switch (opc) {
183 printf("%s%s\t%s, ", dataproc_ops[opc], 176 printf("%s%s\t%s, ", dataproc_ops[opc],
184 condition_decode[word>>28], 177 condition_decode[word>>28],
185 regnames[(word>>16)&0xF]); 178 regnames[(word>>16)&0xF]);
186 dataproc_op2(word); 179 dataproc_op2(word);
187 } else 180 } else
188 dataproc_tstcmp_overlay(off, word); 181 dataproc_tstcmp_overlay(word);
189 return; 182 return;
190 } 183 }
184 }
185
186 static void
187 multiply(word)
188 unsigned word;
189 {
190 if ((word & 0x0FE000F0) == 0x90)
191 printf("mul%s%s\t%s, %s, %s\n", condition_decode[word>>28],
192 word&0x100000 ? "s" : "", regnames[(word>>16)&0xF],
193 regnames[word&0xF], regnames[(word>>8)&0xF]);
194 else if ((word & 0x0FE000F0) == 0x00200090)
195 printf("mla%s%s\t%s, %s, %s, %s\n", condition_decode[word>>28],
196 word&0x100000 ? "s" : "", regnames[(word>>16)&0xF],
197 regnames[word&0xF], regnames[(word>>8)&0xF],
198 regnames[(word>>12)&0xF]);
199 else if ((word & 0x0F8000F0) == 0x00800090)
200 printf("%c%sl%s%s\t%s, %s, %s, %s\n",
201 word&0x400000 ? 's' : 'u',
202 word&0x200000 ? "mla" : "mul",
203 condition_decode[word>>28],
204 word&0x100000 ? "s" : "",
205 regnames[(word>>12)&0xF], regnames[(word>>16)&0xF],
206 regnames[word&0xF], regnames[(word>>8)&0xF]);
207 else
208 printf("<invalid multiply>\n");
209 }
210
211 static void
212 ldr_str_ext(off, word)
213 unsigned off, word;
214 {
215 printf("<extended ldr/str>\n");
216 }
217
218 static void
219 dataproc_74_overlay(off, word)
220 unsigned off, word;
221 {
222 if (word & 0x60)
223 ldr_str_ext(off, word);
224 else
225 multiply(word);
191 } 226 }
192 227
193 void 228 void
194 arm_disasm_line(off) 229 arm_disasm_line(off)
195 unsigned off; 230 unsigned off;
206 case 0: 241 case 0:
207 case 1: 242 case 1:
208 if ((word & 0x90) == 0x90) 243 if ((word & 0x90) == 0x90)
209 dataproc_74_overlay(off, word); 244 dataproc_74_overlay(off, word);
210 else 245 else
211 dataproc(off, word); 246 dataproc(word);
212 return; 247 return;
213 case 2: 248 case 2:
214 case 3: 249 case 3:
215 dataproc(off, word); 250 dataproc(word);
216 return; 251 return;
217 case 4: 252 case 4:
218 case 5: 253 case 5:
219 printf("<ldr/str, immediate offset>\n"); 254 printf("<ldr/str, immediate offset>\n");
220 return; 255 return;