Do not create $(bfdlibdir) and $(bfdincludedir) if !INSTALL_LIBBFD.
[binutils.git] / opcodes / disassemble.c
blob7c4f7344293b2c7c34e61dc209d3c8ba1e426a63
1 /* Select disassembly routine for specified architecture.
2 Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
3 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
5 This file is part of the GNU opcodes library.
7 This library is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */
22 #include "sysdep.h"
23 #include "dis-asm.h"
25 #ifdef ARCH_all
26 #define ARCH_alpha
27 #define ARCH_arc
28 #define ARCH_arm
29 #define ARCH_avr
30 #define ARCH_bfin
31 #define ARCH_cr16
32 #define ARCH_cris
33 #define ARCH_crx
34 #define ARCH_d10v
35 #define ARCH_d30v
36 #define ARCH_dlx
37 #define ARCH_fr30
38 #define ARCH_frv
39 #define ARCH_h8300
40 #define ARCH_h8500
41 #define ARCH_hppa
42 #define ARCH_i370
43 #define ARCH_i386
44 #define ARCH_i860
45 #define ARCH_i960
46 #define ARCH_ia64
47 #define ARCH_ip2k
48 #define ARCH_iq2000
49 #define ARCH_lm32
50 #define ARCH_m32c
51 #define ARCH_m32r
52 #define ARCH_m68hc11
53 #define ARCH_m68hc12
54 #define ARCH_m68k
55 #define ARCH_m88k
56 #define ARCH_maxq
57 #define ARCH_mcore
58 #define ARCH_mep
59 #define ARCH_microblaze
60 #define ARCH_mips
61 #define ARCH_mmix
62 #define ARCH_mn10200
63 #define ARCH_mn10300
64 #define ARCH_moxie
65 #define ARCH_mt
66 #define ARCH_msp430
67 #define ARCH_ns32k
68 #define ARCH_openrisc
69 #define ARCH_or32
70 #define ARCH_pdp11
71 #define ARCH_pj
72 #define ARCH_powerpc
73 #define ARCH_rs6000
74 #define ARCH_s390
75 #define ARCH_score
76 #define ARCH_sh
77 #define ARCH_sparc
78 #define ARCH_spu
79 #define ARCH_tic30
80 #define ARCH_tic4x
81 #define ARCH_tic54x
82 #define ARCH_tic80
83 #define ARCH_v850
84 #define ARCH_vax
85 #define ARCH_w65
86 #define ARCH_xstormy16
87 #define ARCH_xc16x
88 #define ARCH_xtensa
89 #define ARCH_z80
90 #define ARCH_z8k
91 #define INCLUDE_SHMEDIA
92 #endif
94 #ifdef ARCH_m32c
95 #include "m32c-desc.h"
96 #endif
98 disassembler_ftype
99 disassembler (abfd)
100 bfd *abfd;
102 enum bfd_architecture a = bfd_get_arch (abfd);
103 disassembler_ftype disassemble;
105 switch (a)
107 /* If you add a case to this table, also add it to the
108 ARCH_all definition right above this function. */
109 #ifdef ARCH_alpha
110 case bfd_arch_alpha:
111 disassemble = print_insn_alpha;
112 break;
113 #endif
114 #ifdef ARCH_arc
115 case bfd_arch_arc:
117 disassemble = arc_get_disassembler (abfd);
118 break;
120 #endif
121 #ifdef ARCH_arm
122 case bfd_arch_arm:
123 if (bfd_big_endian (abfd))
124 disassemble = print_insn_big_arm;
125 else
126 disassemble = print_insn_little_arm;
127 break;
128 #endif
129 #ifdef ARCH_avr
130 case bfd_arch_avr:
131 disassemble = print_insn_avr;
132 break;
133 #endif
134 #ifdef ARCH_bfin
135 case bfd_arch_bfin:
136 disassemble = print_insn_bfin;
137 break;
138 #endif
139 #ifdef ARCH_cr16
140 case bfd_arch_cr16:
141 disassemble = print_insn_cr16;
142 break;
143 #endif
144 #ifdef ARCH_cris
145 case bfd_arch_cris:
146 disassemble = cris_get_disassembler (abfd);
147 break;
148 #endif
149 #ifdef ARCH_crx
150 case bfd_arch_crx:
151 disassemble = print_insn_crx;
152 break;
153 #endif
154 #ifdef ARCH_d10v
155 case bfd_arch_d10v:
156 disassemble = print_insn_d10v;
157 break;
158 #endif
159 #ifdef ARCH_d30v
160 case bfd_arch_d30v:
161 disassemble = print_insn_d30v;
162 break;
163 #endif
164 #ifdef ARCH_dlx
165 case bfd_arch_dlx:
166 /* As far as I know we only handle big-endian DLX objects. */
167 disassemble = print_insn_dlx;
168 break;
169 #endif
170 #ifdef ARCH_h8300
171 case bfd_arch_h8300:
172 if (bfd_get_mach (abfd) == bfd_mach_h8300h
173 || bfd_get_mach (abfd) == bfd_mach_h8300hn)
174 disassemble = print_insn_h8300h;
175 else if (bfd_get_mach (abfd) == bfd_mach_h8300s
176 || bfd_get_mach (abfd) == bfd_mach_h8300sn
177 || bfd_get_mach (abfd) == bfd_mach_h8300sx
178 || bfd_get_mach (abfd) == bfd_mach_h8300sxn)
179 disassemble = print_insn_h8300s;
180 else
181 disassemble = print_insn_h8300;
182 break;
183 #endif
184 #ifdef ARCH_h8500
185 case bfd_arch_h8500:
186 disassemble = print_insn_h8500;
187 break;
188 #endif
189 #ifdef ARCH_hppa
190 case bfd_arch_hppa:
191 disassemble = print_insn_hppa;
192 break;
193 #endif
194 #ifdef ARCH_i370
195 case bfd_arch_i370:
196 disassemble = print_insn_i370;
197 break;
198 #endif
199 #ifdef ARCH_i386
200 case bfd_arch_i386:
201 case bfd_arch_l1om:
202 disassemble = print_insn_i386;
203 break;
204 #endif
205 #ifdef ARCH_i860
206 case bfd_arch_i860:
207 disassemble = print_insn_i860;
208 break;
209 #endif
210 #ifdef ARCH_i960
211 case bfd_arch_i960:
212 disassemble = print_insn_i960;
213 break;
214 #endif
215 #ifdef ARCH_ia64
216 case bfd_arch_ia64:
217 disassemble = print_insn_ia64;
218 break;
219 #endif
220 #ifdef ARCH_ip2k
221 case bfd_arch_ip2k:
222 disassemble = print_insn_ip2k;
223 break;
224 #endif
225 #ifdef ARCH_fr30
226 case bfd_arch_fr30:
227 disassemble = print_insn_fr30;
228 break;
229 #endif
230 #ifdef ARCH_lm32
231 case bfd_arch_lm32:
232 disassemble = print_insn_lm32;
233 break;
234 #endif
235 #ifdef ARCH_m32r
236 case bfd_arch_m32r:
237 disassemble = print_insn_m32r;
238 break;
239 #endif
240 #if defined(ARCH_m68hc11) || defined(ARCH_m68hc12)
241 case bfd_arch_m68hc11:
242 disassemble = print_insn_m68hc11;
243 break;
244 case bfd_arch_m68hc12:
245 disassemble = print_insn_m68hc12;
246 break;
247 #endif
248 #ifdef ARCH_m68k
249 case bfd_arch_m68k:
250 disassemble = print_insn_m68k;
251 break;
252 #endif
253 #ifdef ARCH_m88k
254 case bfd_arch_m88k:
255 disassemble = print_insn_m88k;
256 break;
257 #endif
258 #ifdef ARCH_maxq
259 case bfd_arch_maxq:
260 disassemble = print_insn_maxq_little;
261 break;
262 #endif
263 #ifdef ARCH_mt
264 case bfd_arch_mt:
265 disassemble = print_insn_mt;
266 break;
267 #endif
268 #ifdef ARCH_microblaze
269 case bfd_arch_microblaze:
270 disassemble = print_insn_microblaze;
271 break;
272 #endif
273 #ifdef ARCH_msp430
274 case bfd_arch_msp430:
275 disassemble = print_insn_msp430;
276 break;
277 #endif
278 #ifdef ARCH_ns32k
279 case bfd_arch_ns32k:
280 disassemble = print_insn_ns32k;
281 break;
282 #endif
283 #ifdef ARCH_mcore
284 case bfd_arch_mcore:
285 disassemble = print_insn_mcore;
286 break;
287 #endif
288 #ifdef ARCH_mep
289 case bfd_arch_mep:
290 disassemble = print_insn_mep;
291 break;
292 #endif
293 #ifdef ARCH_mips
294 case bfd_arch_mips:
295 if (bfd_big_endian (abfd))
296 disassemble = print_insn_big_mips;
297 else
298 disassemble = print_insn_little_mips;
299 break;
300 #endif
301 #ifdef ARCH_mmix
302 case bfd_arch_mmix:
303 disassemble = print_insn_mmix;
304 break;
305 #endif
306 #ifdef ARCH_mn10200
307 case bfd_arch_mn10200:
308 disassemble = print_insn_mn10200;
309 break;
310 #endif
311 #ifdef ARCH_mn10300
312 case bfd_arch_mn10300:
313 disassemble = print_insn_mn10300;
314 break;
315 #endif
316 #ifdef ARCH_openrisc
317 case bfd_arch_openrisc:
318 disassemble = print_insn_openrisc;
319 break;
320 #endif
321 #ifdef ARCH_or32
322 case bfd_arch_or32:
323 if (bfd_big_endian (abfd))
324 disassemble = print_insn_big_or32;
325 else
326 disassemble = print_insn_little_or32;
327 break;
328 #endif
329 #ifdef ARCH_pdp11
330 case bfd_arch_pdp11:
331 disassemble = print_insn_pdp11;
332 break;
333 #endif
334 #ifdef ARCH_pj
335 case bfd_arch_pj:
336 disassemble = print_insn_pj;
337 break;
338 #endif
339 #ifdef ARCH_powerpc
340 case bfd_arch_powerpc:
341 if (bfd_big_endian (abfd))
342 disassemble = print_insn_big_powerpc;
343 else
344 disassemble = print_insn_little_powerpc;
345 break;
346 #endif
347 #ifdef ARCH_rs6000
348 case bfd_arch_rs6000:
349 if (bfd_get_mach (abfd) == bfd_mach_ppc_620)
350 disassemble = print_insn_big_powerpc;
351 else
352 disassemble = print_insn_rs6000;
353 break;
354 #endif
355 #ifdef ARCH_s390
356 case bfd_arch_s390:
357 disassemble = print_insn_s390;
358 break;
359 #endif
360 #ifdef ARCH_score
361 case bfd_arch_score:
362 if (bfd_big_endian (abfd))
363 disassemble = print_insn_big_score;
364 else
365 disassemble = print_insn_little_score;
366 break;
367 #endif
368 #ifdef ARCH_sh
369 case bfd_arch_sh:
370 disassemble = print_insn_sh;
371 break;
372 #endif
373 #ifdef ARCH_sparc
374 case bfd_arch_sparc:
375 disassemble = print_insn_sparc;
376 break;
377 #endif
378 #ifdef ARCH_spu
379 case bfd_arch_spu:
380 disassemble = print_insn_spu;
381 break;
382 #endif
383 #ifdef ARCH_tic30
384 case bfd_arch_tic30:
385 disassemble = print_insn_tic30;
386 break;
387 #endif
388 #ifdef ARCH_tic4x
389 case bfd_arch_tic4x:
390 disassemble = print_insn_tic4x;
391 break;
392 #endif
393 #ifdef ARCH_tic54x
394 case bfd_arch_tic54x:
395 disassemble = print_insn_tic54x;
396 break;
397 #endif
398 #ifdef ARCH_tic80
399 case bfd_arch_tic80:
400 disassemble = print_insn_tic80;
401 break;
402 #endif
403 #ifdef ARCH_v850
404 case bfd_arch_v850:
405 disassemble = print_insn_v850;
406 break;
407 #endif
408 #ifdef ARCH_w65
409 case bfd_arch_w65:
410 disassemble = print_insn_w65;
411 break;
412 #endif
413 #ifdef ARCH_xstormy16
414 case bfd_arch_xstormy16:
415 disassemble = print_insn_xstormy16;
416 break;
417 #endif
418 #ifdef ARCH_xc16x
419 case bfd_arch_xc16x:
420 disassemble = print_insn_xc16x;
421 break;
422 #endif
423 #ifdef ARCH_xtensa
424 case bfd_arch_xtensa:
425 disassemble = print_insn_xtensa;
426 break;
427 #endif
428 #ifdef ARCH_z80
429 case bfd_arch_z80:
430 disassemble = print_insn_z80;
431 break;
432 #endif
433 #ifdef ARCH_z8k
434 case bfd_arch_z8k:
435 if (bfd_get_mach(abfd) == bfd_mach_z8001)
436 disassemble = print_insn_z8001;
437 else
438 disassemble = print_insn_z8002;
439 break;
440 #endif
441 #ifdef ARCH_vax
442 case bfd_arch_vax:
443 disassemble = print_insn_vax;
444 break;
445 #endif
446 #ifdef ARCH_frv
447 case bfd_arch_frv:
448 disassemble = print_insn_frv;
449 break;
450 #endif
451 #ifdef ARCH_moxie
452 case bfd_arch_moxie:
453 disassemble = print_insn_moxie;
454 break;
455 #endif
456 #ifdef ARCH_iq2000
457 case bfd_arch_iq2000:
458 disassemble = print_insn_iq2000;
459 break;
460 #endif
461 #ifdef ARCH_m32c
462 case bfd_arch_m32c:
463 disassemble = print_insn_m32c;
464 break;
465 #endif
466 default:
467 return 0;
469 return disassemble;
472 void
473 disassembler_usage (stream)
474 FILE * stream ATTRIBUTE_UNUSED;
476 #ifdef ARCH_arm
477 print_arm_disassembler_options (stream);
478 #endif
479 #ifdef ARCH_mips
480 print_mips_disassembler_options (stream);
481 #endif
482 #ifdef ARCH_powerpc
483 print_ppc_disassembler_options (stream);
484 #endif
485 #ifdef ARCH_i386
486 print_i386_disassembler_options (stream);
487 #endif
488 #ifdef ARCH_s390
489 print_s390_disassembler_options (stream);
490 #endif
492 return;
495 void
496 disassemble_init_for_target (struct disassemble_info * info)
498 if (info == NULL)
499 return;
501 switch (info->arch)
503 #ifdef ARCH_arm
504 case bfd_arch_arm:
505 info->symbol_is_valid = arm_symbol_is_valid;
506 info->disassembler_needs_relocs = TRUE;
507 break;
508 #endif
509 #ifdef ARCH_ia64
510 case bfd_arch_ia64:
511 info->skip_zeroes = 16;
512 break;
513 #endif
514 #ifdef ARCH_tic4x
515 case bfd_arch_tic4x:
516 info->skip_zeroes = 32;
517 break;
518 #endif
519 #ifdef ARCH_mep
520 case bfd_arch_mep:
521 info->skip_zeroes = 256;
522 info->skip_zeroes_at_end = 0;
523 break;
524 #endif
525 #ifdef ARCH_m32c
526 case bfd_arch_m32c:
527 info->endian = BFD_ENDIAN_BIG;
528 if (! info->insn_sets)
530 info->insn_sets = cgen_bitset_create (ISA_MAX);
531 if (info->mach == bfd_mach_m16c)
532 cgen_bitset_set (info->insn_sets, ISA_M16C);
533 else
534 cgen_bitset_set (info->insn_sets, ISA_M32C);
536 break;
537 #endif
538 default:
539 break;