disassemble.c revision 91041
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 3133965Sjdp#define ARCH_h8300 3233965Sjdp#define ARCH_h8500 3333965Sjdp#define ARCH_hppa 3460484Sobrien#define ARCH_i370 3533965Sjdp#define ARCH_i386 3677298Sobrien#define ARCH_i860 3733965Sjdp#define ARCH_i960 3877298Sobrien#define ARCH_ia64 3960484Sobrien#define ARCH_fr30 4033965Sjdp#define ARCH_m32r 4133965Sjdp#define ARCH_m68k 4277298Sobrien#define ARCH_m68hc11 4377298Sobrien#define ARCH_m68hc12 4433965Sjdp#define ARCH_m88k 4560484Sobrien#define ARCH_mcore 4633965Sjdp#define ARCH_mips 4789857Sobrien#define ARCH_mmix 4833965Sjdp#define ARCH_mn10200 4933965Sjdp#define ARCH_mn10300 5033965Sjdp#define ARCH_ns32k 5189857Sobrien#define ARCH_openrisc 5291041Sobrien#define ARCH_or32 5389857Sobrien#define ARCH_pdp11 5460484Sobrien#define ARCH_pj 5533965Sjdp#define ARCH_powerpc 5633965Sjdp#define ARCH_rs6000 5789857Sobrien#define ARCH_s390 5833965Sjdp#define ARCH_sh 5933965Sjdp#define ARCH_sparc 6038889Sjdp#define ARCH_tic30 6177298Sobrien#define ARCH_tic54x 6260484Sobrien#define ARCH_tic80 6338889Sjdp#define ARCH_v850 6460484Sobrien#define ARCH_vax 6533965Sjdp#define ARCH_w65 6689857Sobrien#define ARCH_xstormy16 6733965Sjdp#define ARCH_z8k 6891041Sobrien#define INCLUDE_SHMEDIA 6933965Sjdp#endif 7033965Sjdp 7138889Sjdp 7233965Sjdpdisassembler_ftype 7333965Sjdpdisassembler (abfd) 7433965Sjdp bfd *abfd; 7533965Sjdp{ 7633965Sjdp enum bfd_architecture a = bfd_get_arch (abfd); 7733965Sjdp disassembler_ftype disassemble; 7833965Sjdp 7933965Sjdp switch (a) 8033965Sjdp { 8133965Sjdp /* If you add a case to this table, also add it to the 8233965Sjdp ARCH_all definition right above this function. */ 8333965Sjdp#ifdef ARCH_a29k 8433965Sjdp case bfd_arch_a29k: 8533965Sjdp /* As far as I know we only handle big-endian 29k objects. */ 8633965Sjdp disassemble = print_insn_big_a29k; 8733965Sjdp break; 8833965Sjdp#endif 8933965Sjdp#ifdef ARCH_alpha 9033965Sjdp case bfd_arch_alpha: 9133965Sjdp disassemble = print_insn_alpha; 9233965Sjdp break; 9333965Sjdp#endif 9438889Sjdp#ifdef ARCH_arc 9538889Sjdp case bfd_arch_arc: 9638889Sjdp { 9777298Sobrien disassemble = arc_get_disassembler (abfd); 9838889Sjdp break; 9938889Sjdp } 10038889Sjdp#endif 10133965Sjdp#ifdef ARCH_arm 10233965Sjdp case bfd_arch_arm: 10333965Sjdp if (bfd_big_endian (abfd)) 10433965Sjdp disassemble = print_insn_big_arm; 10533965Sjdp else 10633965Sjdp disassemble = print_insn_little_arm; 10733965Sjdp break; 10833965Sjdp#endif 10960484Sobrien#ifdef ARCH_avr 11060484Sobrien case bfd_arch_avr: 11160484Sobrien disassemble = print_insn_avr; 11260484Sobrien break; 11360484Sobrien#endif 11477298Sobrien#ifdef ARCH_cris 11577298Sobrien case bfd_arch_cris: 11677298Sobrien disassemble = cris_get_disassembler (abfd); 11777298Sobrien break; 11877298Sobrien#endif 11933965Sjdp#ifdef ARCH_d10v 12033965Sjdp case bfd_arch_d10v: 12133965Sjdp disassemble = print_insn_d10v; 12233965Sjdp break; 12333965Sjdp#endif 12460484Sobrien#ifdef ARCH_d30v 12560484Sobrien case bfd_arch_d30v: 12660484Sobrien disassemble = print_insn_d30v; 12760484Sobrien break; 12860484Sobrien#endif 12933965Sjdp#ifdef ARCH_h8300 13033965Sjdp case bfd_arch_h8300: 13133965Sjdp if (bfd_get_mach(abfd) == bfd_mach_h8300h) 13233965Sjdp disassemble = print_insn_h8300h; 13333965Sjdp else if (bfd_get_mach(abfd) == bfd_mach_h8300s) 13433965Sjdp disassemble = print_insn_h8300s; 13577298Sobrien else 13633965Sjdp disassemble = print_insn_h8300; 13733965Sjdp break; 13833965Sjdp#endif 13933965Sjdp#ifdef ARCH_h8500 14033965Sjdp case bfd_arch_h8500: 14133965Sjdp disassemble = print_insn_h8500; 14233965Sjdp break; 14333965Sjdp#endif 14433965Sjdp#ifdef ARCH_hppa 14533965Sjdp case bfd_arch_hppa: 14633965Sjdp disassemble = print_insn_hppa; 14733965Sjdp break; 14833965Sjdp#endif 14960484Sobrien#ifdef ARCH_i370 15060484Sobrien case bfd_arch_i370: 15160484Sobrien disassemble = print_insn_i370; 15260484Sobrien break; 15360484Sobrien#endif 15433965Sjdp#ifdef ARCH_i386 15533965Sjdp case bfd_arch_i386: 15689857Sobrien disassemble = print_insn_i386; 15733965Sjdp break; 15833965Sjdp#endif 15977298Sobrien#ifdef ARCH_i860 16077298Sobrien case bfd_arch_i860: 16177298Sobrien disassemble = print_insn_i860; 16277298Sobrien break; 16377298Sobrien#endif 16433965Sjdp#ifdef ARCH_i960 16533965Sjdp case bfd_arch_i960: 16633965Sjdp disassemble = print_insn_i960; 16733965Sjdp break; 16833965Sjdp#endif 16977298Sobrien#ifdef ARCH_ia64 17077298Sobrien case bfd_arch_ia64: 17177298Sobrien disassemble = print_insn_ia64; 17277298Sobrien break; 17377298Sobrien#endif 17460484Sobrien#ifdef ARCH_fr30 17560484Sobrien case bfd_arch_fr30: 17660484Sobrien disassemble = print_insn_fr30; 17760484Sobrien break; 17860484Sobrien#endif 17933965Sjdp#ifdef ARCH_m32r 18033965Sjdp case bfd_arch_m32r: 18133965Sjdp disassemble = print_insn_m32r; 18233965Sjdp break; 18333965Sjdp#endif 18477298Sobrien#if defined(ARCH_m68hc11) || defined(ARCH_m68hc12) 18577298Sobrien case bfd_arch_m68hc11: 18677298Sobrien disassemble = print_insn_m68hc11; 18777298Sobrien break; 18877298Sobrien case bfd_arch_m68hc12: 18977298Sobrien disassemble = print_insn_m68hc12; 19077298Sobrien break; 19177298Sobrien#endif 19233965Sjdp#ifdef ARCH_m68k 19333965Sjdp case bfd_arch_m68k: 19433965Sjdp disassemble = print_insn_m68k; 19533965Sjdp break; 19633965Sjdp#endif 19733965Sjdp#ifdef ARCH_m88k 19833965Sjdp case bfd_arch_m88k: 19933965Sjdp disassemble = print_insn_m88k; 20033965Sjdp break; 20133965Sjdp#endif 20233965Sjdp#ifdef ARCH_ns32k 20333965Sjdp case bfd_arch_ns32k: 20433965Sjdp disassemble = print_insn_ns32k; 20533965Sjdp break; 20633965Sjdp#endif 20760484Sobrien#ifdef ARCH_mcore 20860484Sobrien case bfd_arch_mcore: 20960484Sobrien disassemble = print_insn_mcore; 21060484Sobrien break; 21160484Sobrien#endif 21233965Sjdp#ifdef ARCH_mips 21333965Sjdp case bfd_arch_mips: 21433965Sjdp if (bfd_big_endian (abfd)) 21533965Sjdp disassemble = print_insn_big_mips; 21633965Sjdp else 21733965Sjdp disassemble = print_insn_little_mips; 21833965Sjdp break; 21933965Sjdp#endif 22089857Sobrien#ifdef ARCH_mmix 22189857Sobrien case bfd_arch_mmix: 22289857Sobrien disassemble = print_insn_mmix; 22389857Sobrien break; 22489857Sobrien#endif 22533965Sjdp#ifdef ARCH_mn10200 22633965Sjdp case bfd_arch_mn10200: 22733965Sjdp disassemble = print_insn_mn10200; 22833965Sjdp break; 22933965Sjdp#endif 23033965Sjdp#ifdef ARCH_mn10300 23133965Sjdp case bfd_arch_mn10300: 23233965Sjdp disassemble = print_insn_mn10300; 23333965Sjdp break; 23433965Sjdp#endif 23589857Sobrien#ifdef ARCH_openrisc 23689857Sobrien case bfd_arch_openrisc: 23789857Sobrien disassemble = print_insn_openrisc; 23889857Sobrien break; 23989857Sobrien#endif 24091041Sobrien#ifdef ARCH_or32 24191041Sobrien case bfd_arch_or32: 24291041Sobrien if (bfd_big_endian (abfd)) 24391041Sobrien disassemble = print_insn_big_or32; 24491041Sobrien else 24591041Sobrien disassemble = print_insn_little_or32; 24691041Sobrien break; 24791041Sobrien#endif 24889857Sobrien#ifdef ARCH_pdp11 24989857Sobrien case bfd_arch_pdp11: 25089857Sobrien disassemble = print_insn_pdp11; 25189857Sobrien break; 25289857Sobrien#endif 25360484Sobrien#ifdef ARCH_pj 25460484Sobrien case bfd_arch_pj: 25560484Sobrien disassemble = print_insn_pj; 25660484Sobrien break; 25760484Sobrien#endif 25833965Sjdp#ifdef ARCH_powerpc 25933965Sjdp case bfd_arch_powerpc: 26033965Sjdp if (bfd_big_endian (abfd)) 26133965Sjdp disassemble = print_insn_big_powerpc; 26233965Sjdp else 26333965Sjdp disassemble = print_insn_little_powerpc; 26433965Sjdp break; 26533965Sjdp#endif 26633965Sjdp#ifdef ARCH_rs6000 26733965Sjdp case bfd_arch_rs6000: 26877298Sobrien if (bfd_get_mach (abfd) == bfd_mach_ppc_620) 26977298Sobrien disassemble = print_insn_big_powerpc; 27077298Sobrien else 27177298Sobrien disassemble = print_insn_rs6000; 27233965Sjdp break; 27333965Sjdp#endif 27489857Sobrien#ifdef ARCH_s390 27589857Sobrien case bfd_arch_s390: 27689857Sobrien disassemble = print_insn_s390; 27789857Sobrien break; 27889857Sobrien#endif 27933965Sjdp#ifdef ARCH_sh 28033965Sjdp case bfd_arch_sh: 28191041Sobrien#ifdef INCLUDE_SHMEDIA 28291041Sobrien if (bfd_get_mach (abfd) == bfd_mach_sh5) 28391041Sobrien { 28491041Sobrien if (bfd_big_endian (abfd)) 28591041Sobrien disassemble = print_insn_sh64; 28691041Sobrien else 28791041Sobrien disassemble = print_insn_sh64l; 28891041Sobrien break; 28991041Sobrien } 29091041Sobrien#endif 29133965Sjdp if (bfd_big_endian (abfd)) 29233965Sjdp disassemble = print_insn_sh; 29333965Sjdp else 29433965Sjdp disassemble = print_insn_shl; 29533965Sjdp break; 29633965Sjdp#endif 29733965Sjdp#ifdef ARCH_sparc 29833965Sjdp case bfd_arch_sparc: 29933965Sjdp disassemble = print_insn_sparc; 30033965Sjdp break; 30133965Sjdp#endif 30238889Sjdp#ifdef ARCH_tic30 30338889Sjdp case bfd_arch_tic30: 30438889Sjdp disassemble = print_insn_tic30; 30538889Sjdp break; 30638889Sjdp#endif 30777298Sobrien#ifdef ARCH_tic54x 30877298Sobrien case bfd_arch_tic54x: 30977298Sobrien disassemble = print_insn_tic54x; 31077298Sobrien break; 31177298Sobrien#endif 31260484Sobrien#ifdef ARCH_tic80 31360484Sobrien case bfd_arch_tic80: 31460484Sobrien disassemble = print_insn_tic80; 31560484Sobrien break; 31660484Sobrien#endif 31738889Sjdp#ifdef ARCH_v850 31838889Sjdp case bfd_arch_v850: 31938889Sjdp disassemble = print_insn_v850; 32038889Sjdp break; 32138889Sjdp#endif 32233965Sjdp#ifdef ARCH_w65 32333965Sjdp case bfd_arch_w65: 32433965Sjdp disassemble = print_insn_w65; 32533965Sjdp break; 32633965Sjdp#endif 32789857Sobrien#ifdef ARCH_xstormy16 32889857Sobrien case bfd_arch_xstormy16: 32989857Sobrien disassemble = print_insn_xstormy16; 33089857Sobrien break; 33189857Sobrien#endif 33233965Sjdp#ifdef ARCH_z8k 33333965Sjdp case bfd_arch_z8k: 33433965Sjdp if (bfd_get_mach(abfd) == bfd_mach_z8001) 33533965Sjdp disassemble = print_insn_z8001; 33677298Sobrien else 33733965Sjdp disassemble = print_insn_z8002; 33833965Sjdp break; 33933965Sjdp#endif 34060484Sobrien#ifdef ARCH_vax 34160484Sobrien case bfd_arch_vax: 34260484Sobrien disassemble = print_insn_vax; 34360484Sobrien break; 34460484Sobrien#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 35877298Sobrien 35960484Sobrien return; 36060484Sobrien} 361