disassemble.c revision 104834
133965Sjdp/* Select disassembly routine for specified architecture. 291041Sobrien Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 360484Sobrien Free Software Foundation, Inc. 433965Sjdp 533965SjdpThis program is free software; you can redistribute it and/or modify 633965Sjdpit under the terms of the GNU General Public License as published by 733965Sjdpthe Free Software Foundation; either version 2 of the License, or 833965Sjdp(at your option) any later version. 933965Sjdp 1033965SjdpThis program is distributed in the hope that it will be useful, 1133965Sjdpbut WITHOUT ANY WARRANTY; without even the implied warranty of 1233965SjdpMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1333965SjdpGNU General Public License for more details. 1433965Sjdp 1533965SjdpYou should have received a copy of the GNU General Public License 1633965Sjdpalong with this program; if not, write to the Free Software 1733965SjdpFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 1833965Sjdp 1960484Sobrien#include "sysdep.h" 2033965Sjdp#include "dis-asm.h" 2133965Sjdp 2233965Sjdp#ifdef ARCH_all 2333965Sjdp#define ARCH_a29k 2433965Sjdp#define ARCH_alpha 2538889Sjdp#define ARCH_arc 2633965Sjdp#define ARCH_arm 2760484Sobrien#define ARCH_avr 2877298Sobrien#define ARCH_cris 2933965Sjdp#define ARCH_d10v 3060484Sobrien#define ARCH_d30v 31104834Sobrien#define ARCH_dlx 3233965Sjdp#define ARCH_h8300 3333965Sjdp#define ARCH_h8500 3433965Sjdp#define ARCH_hppa 3560484Sobrien#define ARCH_i370 3633965Sjdp#define ARCH_i386 3777298Sobrien#define ARCH_i860 3833965Sjdp#define ARCH_i960 3977298Sobrien#define ARCH_ia64 4060484Sobrien#define ARCH_fr30 4133965Sjdp#define ARCH_m32r 4233965Sjdp#define ARCH_m68k 4377298Sobrien#define ARCH_m68hc11 4477298Sobrien#define ARCH_m68hc12 4533965Sjdp#define ARCH_m88k 4660484Sobrien#define ARCH_mcore 4733965Sjdp#define ARCH_mips 4889857Sobrien#define ARCH_mmix 4933965Sjdp#define ARCH_mn10200 5033965Sjdp#define ARCH_mn10300 5133965Sjdp#define ARCH_ns32k 5289857Sobrien#define ARCH_openrisc 5391041Sobrien#define ARCH_or32 5489857Sobrien#define ARCH_pdp11 5560484Sobrien#define ARCH_pj 5633965Sjdp#define ARCH_powerpc 5733965Sjdp#define ARCH_rs6000 5889857Sobrien#define ARCH_s390 5933965Sjdp#define ARCH_sh 6033965Sjdp#define ARCH_sparc 6138889Sjdp#define ARCH_tic30 6277298Sobrien#define ARCH_tic54x 6360484Sobrien#define ARCH_tic80 6438889Sjdp#define ARCH_v850 6560484Sobrien#define ARCH_vax 6633965Sjdp#define ARCH_w65 6789857Sobrien#define ARCH_xstormy16 6833965Sjdp#define ARCH_z8k 69104834Sobrien#define ARCH_frv 7091041Sobrien#define INCLUDE_SHMEDIA 7133965Sjdp#endif 7233965Sjdp 7338889Sjdp 7433965Sjdpdisassembler_ftype 7533965Sjdpdisassembler (abfd) 7633965Sjdp bfd *abfd; 7733965Sjdp{ 7833965Sjdp enum bfd_architecture a = bfd_get_arch (abfd); 7933965Sjdp disassembler_ftype disassemble; 8033965Sjdp 8133965Sjdp switch (a) 8233965Sjdp { 8333965Sjdp /* If you add a case to this table, also add it to the 8433965Sjdp ARCH_all definition right above this function. */ 8533965Sjdp#ifdef ARCH_a29k 8633965Sjdp case bfd_arch_a29k: 8733965Sjdp /* As far as I know we only handle big-endian 29k objects. */ 8833965Sjdp disassemble = print_insn_big_a29k; 8933965Sjdp break; 9033965Sjdp#endif 9133965Sjdp#ifdef ARCH_alpha 9233965Sjdp case bfd_arch_alpha: 9333965Sjdp disassemble = print_insn_alpha; 9433965Sjdp break; 9533965Sjdp#endif 9638889Sjdp#ifdef ARCH_arc 9738889Sjdp case bfd_arch_arc: 9838889Sjdp { 9977298Sobrien disassemble = arc_get_disassembler (abfd); 10038889Sjdp break; 10138889Sjdp } 10238889Sjdp#endif 10333965Sjdp#ifdef ARCH_arm 10433965Sjdp case bfd_arch_arm: 10533965Sjdp if (bfd_big_endian (abfd)) 10633965Sjdp disassemble = print_insn_big_arm; 10733965Sjdp else 10833965Sjdp disassemble = print_insn_little_arm; 10933965Sjdp break; 11033965Sjdp#endif 11160484Sobrien#ifdef ARCH_avr 11260484Sobrien case bfd_arch_avr: 11360484Sobrien disassemble = print_insn_avr; 11460484Sobrien break; 11560484Sobrien#endif 11677298Sobrien#ifdef ARCH_cris 11777298Sobrien case bfd_arch_cris: 11877298Sobrien disassemble = cris_get_disassembler (abfd); 11977298Sobrien break; 12077298Sobrien#endif 12133965Sjdp#ifdef ARCH_d10v 12233965Sjdp case bfd_arch_d10v: 12333965Sjdp disassemble = print_insn_d10v; 12433965Sjdp break; 12533965Sjdp#endif 12660484Sobrien#ifdef ARCH_d30v 12760484Sobrien case bfd_arch_d30v: 12860484Sobrien disassemble = print_insn_d30v; 12960484Sobrien break; 13060484Sobrien#endif 131104834Sobrien#ifdef ARCH_dlx 132104834Sobrien case bfd_arch_dlx: 133104834Sobrien /* As far as I know we only handle big-endian DLX objects. */ 134104834Sobrien disassemble = print_insn_dlx; 135104834Sobrien break; 136104834Sobrien#endif 13733965Sjdp#ifdef ARCH_h8300 13833965Sjdp case bfd_arch_h8300: 13933965Sjdp if (bfd_get_mach(abfd) == bfd_mach_h8300h) 14033965Sjdp disassemble = print_insn_h8300h; 14133965Sjdp else if (bfd_get_mach(abfd) == bfd_mach_h8300s) 14233965Sjdp disassemble = print_insn_h8300s; 14377298Sobrien else 14433965Sjdp disassemble = print_insn_h8300; 14533965Sjdp break; 14633965Sjdp#endif 14733965Sjdp#ifdef ARCH_h8500 14833965Sjdp case bfd_arch_h8500: 14933965Sjdp disassemble = print_insn_h8500; 15033965Sjdp break; 15133965Sjdp#endif 15233965Sjdp#ifdef ARCH_hppa 15333965Sjdp case bfd_arch_hppa: 15433965Sjdp disassemble = print_insn_hppa; 15533965Sjdp break; 15633965Sjdp#endif 15760484Sobrien#ifdef ARCH_i370 15860484Sobrien case bfd_arch_i370: 15960484Sobrien disassemble = print_insn_i370; 16060484Sobrien break; 16160484Sobrien#endif 16233965Sjdp#ifdef ARCH_i386 16333965Sjdp case bfd_arch_i386: 16489857Sobrien disassemble = print_insn_i386; 16533965Sjdp break; 16633965Sjdp#endif 16777298Sobrien#ifdef ARCH_i860 16877298Sobrien case bfd_arch_i860: 16977298Sobrien disassemble = print_insn_i860; 17077298Sobrien break; 17177298Sobrien#endif 17233965Sjdp#ifdef ARCH_i960 17333965Sjdp case bfd_arch_i960: 17433965Sjdp disassemble = print_insn_i960; 17533965Sjdp break; 17633965Sjdp#endif 17777298Sobrien#ifdef ARCH_ia64 17877298Sobrien case bfd_arch_ia64: 17977298Sobrien disassemble = print_insn_ia64; 18077298Sobrien break; 18177298Sobrien#endif 18260484Sobrien#ifdef ARCH_fr30 18360484Sobrien case bfd_arch_fr30: 18460484Sobrien disassemble = print_insn_fr30; 18560484Sobrien break; 18660484Sobrien#endif 18733965Sjdp#ifdef ARCH_m32r 18833965Sjdp case bfd_arch_m32r: 18933965Sjdp disassemble = print_insn_m32r; 19033965Sjdp break; 19133965Sjdp#endif 19277298Sobrien#if defined(ARCH_m68hc11) || defined(ARCH_m68hc12) 19377298Sobrien case bfd_arch_m68hc11: 19477298Sobrien disassemble = print_insn_m68hc11; 19577298Sobrien break; 19677298Sobrien case bfd_arch_m68hc12: 19777298Sobrien disassemble = print_insn_m68hc12; 19877298Sobrien break; 19977298Sobrien#endif 20033965Sjdp#ifdef ARCH_m68k 20133965Sjdp case bfd_arch_m68k: 20233965Sjdp disassemble = print_insn_m68k; 20333965Sjdp break; 20433965Sjdp#endif 20533965Sjdp#ifdef ARCH_m88k 20633965Sjdp case bfd_arch_m88k: 20733965Sjdp disassemble = print_insn_m88k; 20833965Sjdp break; 20933965Sjdp#endif 21033965Sjdp#ifdef ARCH_ns32k 21133965Sjdp case bfd_arch_ns32k: 21233965Sjdp disassemble = print_insn_ns32k; 21333965Sjdp break; 21433965Sjdp#endif 21560484Sobrien#ifdef ARCH_mcore 21660484Sobrien case bfd_arch_mcore: 21760484Sobrien disassemble = print_insn_mcore; 21860484Sobrien break; 21960484Sobrien#endif 22033965Sjdp#ifdef ARCH_mips 22133965Sjdp case bfd_arch_mips: 22233965Sjdp if (bfd_big_endian (abfd)) 22333965Sjdp disassemble = print_insn_big_mips; 22433965Sjdp else 22533965Sjdp disassemble = print_insn_little_mips; 22633965Sjdp break; 22733965Sjdp#endif 22889857Sobrien#ifdef ARCH_mmix 22989857Sobrien case bfd_arch_mmix: 23089857Sobrien disassemble = print_insn_mmix; 23189857Sobrien break; 23289857Sobrien#endif 23333965Sjdp#ifdef ARCH_mn10200 23433965Sjdp case bfd_arch_mn10200: 23533965Sjdp disassemble = print_insn_mn10200; 23633965Sjdp break; 23733965Sjdp#endif 23833965Sjdp#ifdef ARCH_mn10300 23933965Sjdp case bfd_arch_mn10300: 24033965Sjdp disassemble = print_insn_mn10300; 24133965Sjdp break; 24233965Sjdp#endif 24389857Sobrien#ifdef ARCH_openrisc 24489857Sobrien case bfd_arch_openrisc: 24589857Sobrien disassemble = print_insn_openrisc; 24689857Sobrien break; 24789857Sobrien#endif 24891041Sobrien#ifdef ARCH_or32 24991041Sobrien case bfd_arch_or32: 25091041Sobrien if (bfd_big_endian (abfd)) 25191041Sobrien disassemble = print_insn_big_or32; 25291041Sobrien else 25391041Sobrien disassemble = print_insn_little_or32; 25491041Sobrien break; 25591041Sobrien#endif 25689857Sobrien#ifdef ARCH_pdp11 25789857Sobrien case bfd_arch_pdp11: 25889857Sobrien disassemble = print_insn_pdp11; 25989857Sobrien break; 26089857Sobrien#endif 26160484Sobrien#ifdef ARCH_pj 26260484Sobrien case bfd_arch_pj: 26360484Sobrien disassemble = print_insn_pj; 26460484Sobrien break; 26560484Sobrien#endif 26633965Sjdp#ifdef ARCH_powerpc 26733965Sjdp case bfd_arch_powerpc: 26833965Sjdp if (bfd_big_endian (abfd)) 26933965Sjdp disassemble = print_insn_big_powerpc; 27033965Sjdp else 27133965Sjdp disassemble = print_insn_little_powerpc; 27233965Sjdp break; 27333965Sjdp#endif 27433965Sjdp#ifdef ARCH_rs6000 27533965Sjdp case bfd_arch_rs6000: 27677298Sobrien if (bfd_get_mach (abfd) == bfd_mach_ppc_620) 27777298Sobrien disassemble = print_insn_big_powerpc; 27877298Sobrien else 27977298Sobrien disassemble = print_insn_rs6000; 28033965Sjdp break; 28133965Sjdp#endif 28289857Sobrien#ifdef ARCH_s390 28389857Sobrien case bfd_arch_s390: 28489857Sobrien disassemble = print_insn_s390; 28589857Sobrien break; 28689857Sobrien#endif 28733965Sjdp#ifdef ARCH_sh 28833965Sjdp case bfd_arch_sh: 289104834Sobrien disassemble = print_insn_sh; 29033965Sjdp break; 29133965Sjdp#endif 29233965Sjdp#ifdef ARCH_sparc 29333965Sjdp case bfd_arch_sparc: 29433965Sjdp disassemble = print_insn_sparc; 29533965Sjdp break; 29633965Sjdp#endif 29738889Sjdp#ifdef ARCH_tic30 29838889Sjdp case bfd_arch_tic30: 29938889Sjdp disassemble = print_insn_tic30; 30038889Sjdp break; 30138889Sjdp#endif 30277298Sobrien#ifdef ARCH_tic54x 30377298Sobrien case bfd_arch_tic54x: 30477298Sobrien disassemble = print_insn_tic54x; 30577298Sobrien break; 30677298Sobrien#endif 30760484Sobrien#ifdef ARCH_tic80 30860484Sobrien case bfd_arch_tic80: 30960484Sobrien disassemble = print_insn_tic80; 31060484Sobrien break; 31160484Sobrien#endif 31238889Sjdp#ifdef ARCH_v850 31338889Sjdp case bfd_arch_v850: 31438889Sjdp disassemble = print_insn_v850; 31538889Sjdp break; 31638889Sjdp#endif 31733965Sjdp#ifdef ARCH_w65 31833965Sjdp case bfd_arch_w65: 31933965Sjdp disassemble = print_insn_w65; 32033965Sjdp break; 32133965Sjdp#endif 32289857Sobrien#ifdef ARCH_xstormy16 32389857Sobrien case bfd_arch_xstormy16: 32489857Sobrien disassemble = print_insn_xstormy16; 32589857Sobrien break; 32689857Sobrien#endif 32733965Sjdp#ifdef ARCH_z8k 32833965Sjdp case bfd_arch_z8k: 32933965Sjdp if (bfd_get_mach(abfd) == bfd_mach_z8001) 33033965Sjdp disassemble = print_insn_z8001; 33177298Sobrien else 33233965Sjdp disassemble = print_insn_z8002; 33333965Sjdp break; 33433965Sjdp#endif 33560484Sobrien#ifdef ARCH_vax 33660484Sobrien case bfd_arch_vax: 33760484Sobrien disassemble = print_insn_vax; 33860484Sobrien break; 33960484Sobrien#endif 340104834Sobrien#ifdef ARCH_frv 341104834Sobrien case bfd_arch_frv: 342104834Sobrien disassemble = print_insn_frv; 343104834Sobrien break; 344104834Sobrien#endif 34533965Sjdp default: 34633965Sjdp return 0; 34733965Sjdp } 34833965Sjdp return disassemble; 34933965Sjdp} 35038889Sjdp 35160484Sobrienvoid 35260484Sobriendisassembler_usage (stream) 35377298Sobrien FILE * stream ATTRIBUTE_UNUSED; 35460484Sobrien{ 35560484Sobrien#ifdef ARCH_arm 35660484Sobrien print_arm_disassembler_options (stream); 35760484Sobrien#endif 358104834Sobrien#ifdef ARCH_powerpc 359104834Sobrien print_ppc_disassembler_options (stream); 360104834Sobrien#endif 36177298Sobrien 36260484Sobrien return; 36360484Sobrien} 364