bfd/
[binutils.git] / opcodes / disassemble.c
blob19de8f6f8411b7d0dfb0993cdd6366c0519c1f7f
1 /* Select disassembly routine for specified architecture.
2 Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004
3 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19 #include "sysdep.h"
20 #include "dis-asm.h"
22 #ifdef ARCH_all
23 #define ARCH_a29k
24 #define ARCH_alpha
25 #define ARCH_arc
26 #define ARCH_arm
27 #define ARCH_avr
28 #define ARCH_cris
29 #define ARCH_crx
30 #define ARCH_d10v
31 #define ARCH_d30v
32 #define ARCH_dlx
33 #define ARCH_h8300
34 #define ARCH_h8500
35 #define ARCH_hppa
36 #define ARCH_i370
37 #define ARCH_i386
38 #define ARCH_i860
39 #define ARCH_i960
40 #define ARCH_ip2k
41 #define ARCH_ia64
42 #define ARCH_fr30
43 #define ARCH_m32r
44 #define ARCH_m68k
45 #define ARCH_m68hc11
46 #define ARCH_m68hc12
47 #define ARCH_m88k
48 #define ARCH_maxq
49 #define ARCH_mcore
50 #define ARCH_mips
51 #define ARCH_mmix
52 #define ARCH_mn10200
53 #define ARCH_mn10300
54 #define ARCH_msp430
55 #define ARCH_ns32k
56 #define ARCH_openrisc
57 #define ARCH_or32
58 #define ARCH_pdp11
59 #define ARCH_pj
60 #define ARCH_powerpc
61 #define ARCH_rs6000
62 #define ARCH_s390
63 #define ARCH_sh
64 #define ARCH_sparc
65 #define ARCH_tic30
66 #define ARCH_tic4x
67 #define ARCH_tic54x
68 #define ARCH_tic80
69 #define ARCH_v850
70 #define ARCH_vax
71 #define ARCH_w65
72 #define ARCH_xstormy16
73 #define ARCH_xtensa
74 #define ARCH_z8k
75 #define ARCH_frv
76 #define ARCH_iq2000
77 #define INCLUDE_SHMEDIA
78 #endif
81 disassembler_ftype
82 disassembler (abfd)
83 bfd *abfd;
85 enum bfd_architecture a = bfd_get_arch (abfd);
86 disassembler_ftype disassemble;
88 switch (a)
90 /* If you add a case to this table, also add it to the
91 ARCH_all definition right above this function. */
92 #ifdef ARCH_a29k
93 case bfd_arch_a29k:
94 /* As far as I know we only handle big-endian 29k objects. */
95 disassemble = print_insn_big_a29k;
96 break;
97 #endif
98 #ifdef ARCH_alpha
99 case bfd_arch_alpha:
100 disassemble = print_insn_alpha;
101 break;
102 #endif
103 #ifdef ARCH_arc
104 case bfd_arch_arc:
106 disassemble = arc_get_disassembler (abfd);
107 break;
109 #endif
110 #ifdef ARCH_arm
111 case bfd_arch_arm:
112 if (bfd_big_endian (abfd))
113 disassemble = print_insn_big_arm;
114 else
115 disassemble = print_insn_little_arm;
116 break;
117 #endif
118 #ifdef ARCH_avr
119 case bfd_arch_avr:
120 disassemble = print_insn_avr;
121 break;
122 #endif
123 #ifdef ARCH_cris
124 case bfd_arch_cris:
125 disassemble = cris_get_disassembler (abfd);
126 break;
127 #endif
128 #ifdef ARCH_crx
129 case bfd_arch_crx:
130 disassemble = print_insn_crx;
131 break;
132 #endif
133 #ifdef ARCH_d10v
134 case bfd_arch_d10v:
135 disassemble = print_insn_d10v;
136 break;
137 #endif
138 #ifdef ARCH_d30v
139 case bfd_arch_d30v:
140 disassemble = print_insn_d30v;
141 break;
142 #endif
143 #ifdef ARCH_dlx
144 case bfd_arch_dlx:
145 /* As far as I know we only handle big-endian DLX objects. */
146 disassemble = print_insn_dlx;
147 break;
148 #endif
149 #ifdef ARCH_h8300
150 case bfd_arch_h8300:
151 if (bfd_get_mach (abfd) == bfd_mach_h8300h
152 || bfd_get_mach (abfd) == bfd_mach_h8300hn)
153 disassemble = print_insn_h8300h;
154 else if (bfd_get_mach (abfd) == bfd_mach_h8300s
155 || bfd_get_mach (abfd) == bfd_mach_h8300sn
156 || bfd_get_mach (abfd) == bfd_mach_h8300sx
157 || bfd_get_mach (abfd) == bfd_mach_h8300sxn)
158 disassemble = print_insn_h8300s;
159 else
160 disassemble = print_insn_h8300;
161 break;
162 #endif
163 #ifdef ARCH_h8500
164 case bfd_arch_h8500:
165 disassemble = print_insn_h8500;
166 break;
167 #endif
168 #ifdef ARCH_hppa
169 case bfd_arch_hppa:
170 disassemble = print_insn_hppa;
171 break;
172 #endif
173 #ifdef ARCH_i370
174 case bfd_arch_i370:
175 disassemble = print_insn_i370;
176 break;
177 #endif
178 #ifdef ARCH_i386
179 case bfd_arch_i386:
180 disassemble = print_insn_i386;
181 break;
182 #endif
183 #ifdef ARCH_i860
184 case bfd_arch_i860:
185 disassemble = print_insn_i860;
186 break;
187 #endif
188 #ifdef ARCH_i960
189 case bfd_arch_i960:
190 disassemble = print_insn_i960;
191 break;
192 #endif
193 #ifdef ARCH_ia64
194 case bfd_arch_ia64:
195 disassemble = print_insn_ia64;
196 break;
197 #endif
198 #ifdef ARCH_ip2k
199 case bfd_arch_ip2k:
200 disassemble = print_insn_ip2k;
201 break;
202 #endif
203 #ifdef ARCH_fr30
204 case bfd_arch_fr30:
205 disassemble = print_insn_fr30;
206 break;
207 #endif
208 #ifdef ARCH_m32r
209 case bfd_arch_m32r:
210 disassemble = print_insn_m32r;
211 break;
212 #endif
213 #if defined(ARCH_m68hc11) || defined(ARCH_m68hc12)
214 case bfd_arch_m68hc11:
215 disassemble = print_insn_m68hc11;
216 break;
217 case bfd_arch_m68hc12:
218 disassemble = print_insn_m68hc12;
219 break;
220 #endif
221 #ifdef ARCH_m68k
222 case bfd_arch_m68k:
223 disassemble = print_insn_m68k;
224 break;
225 #endif
226 #ifdef ARCH_m88k
227 case bfd_arch_m88k:
228 disassemble = print_insn_m88k;
229 break;
230 #endif
231 #ifdef ARCH_maxq
232 case bfd_arch_maxq:
233 disassemble = print_insn_maxq_little;
234 break;
235 #endif
236 #ifdef ARCH_msp430
237 case bfd_arch_msp430:
238 disassemble = print_insn_msp430;
239 break;
240 #endif
241 #ifdef ARCH_ns32k
242 case bfd_arch_ns32k:
243 disassemble = print_insn_ns32k;
244 break;
245 #endif
246 #ifdef ARCH_mcore
247 case bfd_arch_mcore:
248 disassemble = print_insn_mcore;
249 break;
250 #endif
251 #ifdef ARCH_mips
252 case bfd_arch_mips:
253 if (bfd_big_endian (abfd))
254 disassemble = print_insn_big_mips;
255 else
256 disassemble = print_insn_little_mips;
257 break;
258 #endif
259 #ifdef ARCH_mmix
260 case bfd_arch_mmix:
261 disassemble = print_insn_mmix;
262 break;
263 #endif
264 #ifdef ARCH_mn10200
265 case bfd_arch_mn10200:
266 disassemble = print_insn_mn10200;
267 break;
268 #endif
269 #ifdef ARCH_mn10300
270 case bfd_arch_mn10300:
271 disassemble = print_insn_mn10300;
272 break;
273 #endif
274 #ifdef ARCH_openrisc
275 case bfd_arch_openrisc:
276 disassemble = print_insn_openrisc;
277 break;
278 #endif
279 #ifdef ARCH_or32
280 case bfd_arch_or32:
281 if (bfd_big_endian (abfd))
282 disassemble = print_insn_big_or32;
283 else
284 disassemble = print_insn_little_or32;
285 break;
286 #endif
287 #ifdef ARCH_pdp11
288 case bfd_arch_pdp11:
289 disassemble = print_insn_pdp11;
290 break;
291 #endif
292 #ifdef ARCH_pj
293 case bfd_arch_pj:
294 disassemble = print_insn_pj;
295 break;
296 #endif
297 #ifdef ARCH_powerpc
298 case bfd_arch_powerpc:
299 if (bfd_big_endian (abfd))
300 disassemble = print_insn_big_powerpc;
301 else
302 disassemble = print_insn_little_powerpc;
303 break;
304 #endif
305 #ifdef ARCH_rs6000
306 case bfd_arch_rs6000:
307 if (bfd_get_mach (abfd) == bfd_mach_ppc_620)
308 disassemble = print_insn_big_powerpc;
309 else
310 disassemble = print_insn_rs6000;
311 break;
312 #endif
313 #ifdef ARCH_s390
314 case bfd_arch_s390:
315 disassemble = print_insn_s390;
316 break;
317 #endif
318 #ifdef ARCH_sh
319 case bfd_arch_sh:
320 disassemble = print_insn_sh;
321 break;
322 #endif
323 #ifdef ARCH_sparc
324 case bfd_arch_sparc:
325 disassemble = print_insn_sparc;
326 break;
327 #endif
328 #ifdef ARCH_tic30
329 case bfd_arch_tic30:
330 disassemble = print_insn_tic30;
331 break;
332 #endif
333 #ifdef ARCH_tic4x
334 case bfd_arch_tic4x:
335 disassemble = print_insn_tic4x;
336 break;
337 #endif
338 #ifdef ARCH_tic54x
339 case bfd_arch_tic54x:
340 disassemble = print_insn_tic54x;
341 break;
342 #endif
343 #ifdef ARCH_tic80
344 case bfd_arch_tic80:
345 disassemble = print_insn_tic80;
346 break;
347 #endif
348 #ifdef ARCH_v850
349 case bfd_arch_v850:
350 disassemble = print_insn_v850;
351 break;
352 #endif
353 #ifdef ARCH_w65
354 case bfd_arch_w65:
355 disassemble = print_insn_w65;
356 break;
357 #endif
358 #ifdef ARCH_xstormy16
359 case bfd_arch_xstormy16:
360 disassemble = print_insn_xstormy16;
361 break;
362 #endif
363 #ifdef ARCH_xtensa
364 case bfd_arch_xtensa:
365 disassemble = print_insn_xtensa;
366 break;
367 #endif
368 #ifdef ARCH_z8k
369 case bfd_arch_z8k:
370 if (bfd_get_mach(abfd) == bfd_mach_z8001)
371 disassemble = print_insn_z8001;
372 else
373 disassemble = print_insn_z8002;
374 break;
375 #endif
376 #ifdef ARCH_vax
377 case bfd_arch_vax:
378 disassemble = print_insn_vax;
379 break;
380 #endif
381 #ifdef ARCH_frv
382 case bfd_arch_frv:
383 disassemble = print_insn_frv;
384 break;
385 #endif
386 #ifdef ARCH_iq2000
387 case bfd_arch_iq2000:
388 disassemble = print_insn_iq2000;
389 break;
390 #endif
391 default:
392 return 0;
394 return disassemble;
397 void
398 disassembler_usage (stream)
399 FILE * stream ATTRIBUTE_UNUSED;
401 #ifdef ARCH_arm
402 print_arm_disassembler_options (stream);
403 #endif
404 #ifdef ARCH_mips
405 print_mips_disassembler_options (stream);
406 #endif
407 #ifdef ARCH_powerpc
408 print_ppc_disassembler_options (stream);
409 #endif
411 return;
414 void
415 disassemble_init_for_target (struct disassemble_info * info)
417 if (info == NULL)
418 return;
420 switch (info->arch)
422 #ifdef ARCH_arm
423 case bfd_arch_arm:
424 info->symbol_is_valid = arm_symbol_is_valid;
425 break;
426 #endif
427 default:
428 break;