disassemble.c revision 89857
133965Sjdp/* Select disassembly routine for specified architecture.
278828Sobrien   Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
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
5289857Sobrien#define ARCH_pdp11
5360484Sobrien#define ARCH_pj
5433965Sjdp#define ARCH_powerpc
5533965Sjdp#define ARCH_rs6000
5689857Sobrien#define ARCH_s390
5733965Sjdp#define ARCH_sh
5833965Sjdp#define ARCH_sparc
5938889Sjdp#define ARCH_tic30
6077298Sobrien#define ARCH_tic54x
6160484Sobrien#define ARCH_tic80
6238889Sjdp#define ARCH_v850
6360484Sobrien#define ARCH_vax
6433965Sjdp#define ARCH_w65
6589857Sobrien#define ARCH_xstormy16
6633965Sjdp#define ARCH_z8k
6733965Sjdp#endif
6833965Sjdp
6938889Sjdp
7033965Sjdpdisassembler_ftype
7133965Sjdpdisassembler (abfd)
7233965Sjdp     bfd *abfd;
7333965Sjdp{
7433965Sjdp  enum bfd_architecture a = bfd_get_arch (abfd);
7533965Sjdp  disassembler_ftype disassemble;
7633965Sjdp
7733965Sjdp  switch (a)
7833965Sjdp    {
7933965Sjdp      /* If you add a case to this table, also add it to the
8033965Sjdp	 ARCH_all definition right above this function.  */
8133965Sjdp#ifdef ARCH_a29k
8233965Sjdp    case bfd_arch_a29k:
8333965Sjdp      /* As far as I know we only handle big-endian 29k objects.  */
8433965Sjdp      disassemble = print_insn_big_a29k;
8533965Sjdp      break;
8633965Sjdp#endif
8733965Sjdp#ifdef ARCH_alpha
8833965Sjdp    case bfd_arch_alpha:
8933965Sjdp      disassemble = print_insn_alpha;
9033965Sjdp      break;
9133965Sjdp#endif
9238889Sjdp#ifdef ARCH_arc
9338889Sjdp    case bfd_arch_arc:
9438889Sjdp      {
9577298Sobrien	disassemble = arc_get_disassembler (abfd);
9638889Sjdp	break;
9738889Sjdp      }
9838889Sjdp#endif
9933965Sjdp#ifdef ARCH_arm
10033965Sjdp    case bfd_arch_arm:
10133965Sjdp      if (bfd_big_endian (abfd))
10233965Sjdp	disassemble = print_insn_big_arm;
10333965Sjdp      else
10433965Sjdp	disassemble = print_insn_little_arm;
10533965Sjdp      break;
10633965Sjdp#endif
10760484Sobrien#ifdef ARCH_avr
10860484Sobrien    case bfd_arch_avr:
10960484Sobrien      disassemble = print_insn_avr;
11060484Sobrien      break;
11160484Sobrien#endif
11277298Sobrien#ifdef ARCH_cris
11377298Sobrien    case bfd_arch_cris:
11477298Sobrien      disassemble = cris_get_disassembler (abfd);
11577298Sobrien      break;
11677298Sobrien#endif
11733965Sjdp#ifdef ARCH_d10v
11833965Sjdp    case bfd_arch_d10v:
11933965Sjdp      disassemble = print_insn_d10v;
12033965Sjdp      break;
12133965Sjdp#endif
12260484Sobrien#ifdef ARCH_d30v
12360484Sobrien    case bfd_arch_d30v:
12460484Sobrien      disassemble = print_insn_d30v;
12560484Sobrien      break;
12660484Sobrien#endif
12733965Sjdp#ifdef ARCH_h8300
12833965Sjdp    case bfd_arch_h8300:
12933965Sjdp      if (bfd_get_mach(abfd) == bfd_mach_h8300h)
13033965Sjdp	disassemble = print_insn_h8300h;
13133965Sjdp      else if (bfd_get_mach(abfd) == bfd_mach_h8300s)
13233965Sjdp	disassemble = print_insn_h8300s;
13377298Sobrien      else
13433965Sjdp	disassemble = print_insn_h8300;
13533965Sjdp      break;
13633965Sjdp#endif
13733965Sjdp#ifdef ARCH_h8500
13833965Sjdp    case bfd_arch_h8500:
13933965Sjdp      disassemble = print_insn_h8500;
14033965Sjdp      break;
14133965Sjdp#endif
14233965Sjdp#ifdef ARCH_hppa
14333965Sjdp    case bfd_arch_hppa:
14433965Sjdp      disassemble = print_insn_hppa;
14533965Sjdp      break;
14633965Sjdp#endif
14760484Sobrien#ifdef ARCH_i370
14860484Sobrien    case bfd_arch_i370:
14960484Sobrien      disassemble = print_insn_i370;
15060484Sobrien      break;
15160484Sobrien#endif
15233965Sjdp#ifdef ARCH_i386
15333965Sjdp    case bfd_arch_i386:
15489857Sobrien      disassemble = print_insn_i386;
15533965Sjdp      break;
15633965Sjdp#endif
15777298Sobrien#ifdef ARCH_i860
15877298Sobrien    case bfd_arch_i860:
15977298Sobrien      disassemble = print_insn_i860;
16077298Sobrien      break;
16177298Sobrien#endif
16233965Sjdp#ifdef ARCH_i960
16333965Sjdp    case bfd_arch_i960:
16433965Sjdp      disassemble = print_insn_i960;
16533965Sjdp      break;
16633965Sjdp#endif
16777298Sobrien#ifdef ARCH_ia64
16877298Sobrien    case bfd_arch_ia64:
16977298Sobrien      disassemble = print_insn_ia64;
17077298Sobrien      break;
17177298Sobrien#endif
17260484Sobrien#ifdef ARCH_fr30
17360484Sobrien    case bfd_arch_fr30:
17460484Sobrien      disassemble = print_insn_fr30;
17560484Sobrien      break;
17660484Sobrien#endif
17733965Sjdp#ifdef ARCH_m32r
17833965Sjdp    case bfd_arch_m32r:
17933965Sjdp      disassemble = print_insn_m32r;
18033965Sjdp      break;
18133965Sjdp#endif
18277298Sobrien#if defined(ARCH_m68hc11) || defined(ARCH_m68hc12)
18377298Sobrien    case bfd_arch_m68hc11:
18477298Sobrien      disassemble = print_insn_m68hc11;
18577298Sobrien      break;
18677298Sobrien    case bfd_arch_m68hc12:
18777298Sobrien      disassemble = print_insn_m68hc12;
18877298Sobrien      break;
18977298Sobrien#endif
19033965Sjdp#ifdef ARCH_m68k
19133965Sjdp    case bfd_arch_m68k:
19233965Sjdp      disassemble = print_insn_m68k;
19333965Sjdp      break;
19433965Sjdp#endif
19533965Sjdp#ifdef ARCH_m88k
19633965Sjdp    case bfd_arch_m88k:
19733965Sjdp      disassemble = print_insn_m88k;
19833965Sjdp      break;
19933965Sjdp#endif
20033965Sjdp#ifdef ARCH_ns32k
20133965Sjdp    case bfd_arch_ns32k:
20233965Sjdp      disassemble = print_insn_ns32k;
20333965Sjdp      break;
20433965Sjdp#endif
20560484Sobrien#ifdef ARCH_mcore
20660484Sobrien    case bfd_arch_mcore:
20760484Sobrien      disassemble = print_insn_mcore;
20860484Sobrien      break;
20960484Sobrien#endif
21033965Sjdp#ifdef ARCH_mips
21133965Sjdp    case bfd_arch_mips:
21233965Sjdp      if (bfd_big_endian (abfd))
21333965Sjdp	disassemble = print_insn_big_mips;
21433965Sjdp      else
21533965Sjdp	disassemble = print_insn_little_mips;
21633965Sjdp      break;
21733965Sjdp#endif
21889857Sobrien#ifdef ARCH_mmix
21989857Sobrien    case bfd_arch_mmix:
22089857Sobrien      disassemble = print_insn_mmix;
22189857Sobrien      break;
22289857Sobrien#endif
22333965Sjdp#ifdef ARCH_mn10200
22433965Sjdp    case bfd_arch_mn10200:
22533965Sjdp      disassemble = print_insn_mn10200;
22633965Sjdp      break;
22733965Sjdp#endif
22833965Sjdp#ifdef ARCH_mn10300
22933965Sjdp    case bfd_arch_mn10300:
23033965Sjdp      disassemble = print_insn_mn10300;
23133965Sjdp      break;
23233965Sjdp#endif
23389857Sobrien#ifdef ARCH_openrisc
23489857Sobrien    case bfd_arch_openrisc:
23589857Sobrien      disassemble = print_insn_openrisc;
23689857Sobrien      break;
23789857Sobrien#endif
23889857Sobrien#ifdef ARCH_pdp11
23989857Sobrien    case bfd_arch_pdp11:
24089857Sobrien      disassemble = print_insn_pdp11;
24189857Sobrien      break;
24289857Sobrien#endif
24360484Sobrien#ifdef ARCH_pj
24460484Sobrien    case bfd_arch_pj:
24560484Sobrien      disassemble = print_insn_pj;
24660484Sobrien      break;
24760484Sobrien#endif
24833965Sjdp#ifdef ARCH_powerpc
24933965Sjdp    case bfd_arch_powerpc:
25033965Sjdp      if (bfd_big_endian (abfd))
25133965Sjdp	disassemble = print_insn_big_powerpc;
25233965Sjdp      else
25333965Sjdp	disassemble = print_insn_little_powerpc;
25433965Sjdp      break;
25533965Sjdp#endif
25633965Sjdp#ifdef ARCH_rs6000
25733965Sjdp    case bfd_arch_rs6000:
25877298Sobrien      if (bfd_get_mach (abfd) == bfd_mach_ppc_620)
25977298Sobrien	disassemble = print_insn_big_powerpc;
26077298Sobrien      else
26177298Sobrien	disassemble = print_insn_rs6000;
26233965Sjdp      break;
26333965Sjdp#endif
26489857Sobrien#ifdef ARCH_s390
26589857Sobrien    case bfd_arch_s390:
26689857Sobrien      disassemble = print_insn_s390;
26789857Sobrien      break;
26889857Sobrien#endif
26933965Sjdp#ifdef ARCH_sh
27033965Sjdp    case bfd_arch_sh:
27133965Sjdp      if (bfd_big_endian (abfd))
27233965Sjdp	disassemble = print_insn_sh;
27333965Sjdp      else
27433965Sjdp	disassemble = print_insn_shl;
27533965Sjdp      break;
27633965Sjdp#endif
27733965Sjdp#ifdef ARCH_sparc
27833965Sjdp    case bfd_arch_sparc:
27933965Sjdp      disassemble = print_insn_sparc;
28033965Sjdp      break;
28133965Sjdp#endif
28238889Sjdp#ifdef ARCH_tic30
28338889Sjdp    case bfd_arch_tic30:
28438889Sjdp      disassemble = print_insn_tic30;
28538889Sjdp      break;
28638889Sjdp#endif
28777298Sobrien#ifdef ARCH_tic54x
28877298Sobrien    case bfd_arch_tic54x:
28977298Sobrien      disassemble = print_insn_tic54x;
29077298Sobrien      break;
29177298Sobrien#endif
29260484Sobrien#ifdef ARCH_tic80
29360484Sobrien    case bfd_arch_tic80:
29460484Sobrien      disassemble = print_insn_tic80;
29560484Sobrien      break;
29660484Sobrien#endif
29738889Sjdp#ifdef ARCH_v850
29838889Sjdp    case bfd_arch_v850:
29938889Sjdp      disassemble = print_insn_v850;
30038889Sjdp      break;
30138889Sjdp#endif
30233965Sjdp#ifdef ARCH_w65
30333965Sjdp    case bfd_arch_w65:
30433965Sjdp      disassemble = print_insn_w65;
30533965Sjdp      break;
30633965Sjdp#endif
30789857Sobrien#ifdef ARCH_xstormy16
30889857Sobrien    case bfd_arch_xstormy16:
30989857Sobrien      disassemble = print_insn_xstormy16;
31089857Sobrien      break;
31189857Sobrien#endif
31233965Sjdp#ifdef ARCH_z8k
31333965Sjdp    case bfd_arch_z8k:
31433965Sjdp      if (bfd_get_mach(abfd) == bfd_mach_z8001)
31533965Sjdp	disassemble = print_insn_z8001;
31677298Sobrien      else
31733965Sjdp	disassemble = print_insn_z8002;
31833965Sjdp      break;
31933965Sjdp#endif
32060484Sobrien#ifdef ARCH_vax
32160484Sobrien    case bfd_arch_vax:
32260484Sobrien      disassemble = print_insn_vax;
32360484Sobrien      break;
32460484Sobrien#endif
32533965Sjdp    default:
32633965Sjdp      return 0;
32733965Sjdp    }
32833965Sjdp  return disassemble;
32933965Sjdp}
33038889Sjdp
33160484Sobrienvoid
33260484Sobriendisassembler_usage (stream)
33377298Sobrien     FILE * stream ATTRIBUTE_UNUSED;
33460484Sobrien{
33560484Sobrien#ifdef ARCH_arm
33660484Sobrien  print_arm_disassembler_options (stream);
33760484Sobrien#endif
33877298Sobrien
33960484Sobrien  return;
34060484Sobrien}
341