disassemble.c revision 38889
1/* Select disassembly routine for specified architecture.
2   Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
3
4This program is free software; you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation; either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program; if not, write to the Free Software
16Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
17
18#include "ansidecl.h"
19#include "dis-asm.h"
20
21#ifdef ARCH_all
22#define ARCH_a29k
23#define ARCH_alpha
24#define ARCH_arc
25#define ARCH_arm
26#define ARCH_d10v
27#define ARCH_h8300
28#define ARCH_h8500
29#define ARCH_hppa
30#define ARCH_i386
31#define ARCH_i960
32#define ARCH_m32r
33#define ARCH_m68k
34#define ARCH_m88k
35#define ARCH_mips
36#define ARCH_mn10200
37#define ARCH_mn10300
38#define ARCH_ns32k
39#define ARCH_powerpc
40#define ARCH_rs6000
41#define ARCH_sh
42#define ARCH_sparc
43#define ARCH_tic30
44#define ARCH_v850
45#define ARCH_w65
46#define ARCH_z8k
47#endif
48
49
50disassembler_ftype
51disassembler (abfd)
52     bfd *abfd;
53{
54  enum bfd_architecture a = bfd_get_arch (abfd);
55  disassembler_ftype disassemble;
56
57  switch (a)
58    {
59      /* If you add a case to this table, also add it to the
60	 ARCH_all definition right above this function.  */
61#ifdef ARCH_a29k
62    case bfd_arch_a29k:
63      /* As far as I know we only handle big-endian 29k objects.  */
64      disassemble = print_insn_big_a29k;
65      break;
66#endif
67#ifdef ARCH_alpha
68    case bfd_arch_alpha:
69      disassemble = print_insn_alpha;
70      break;
71#endif
72#ifdef ARCH_arc
73    case bfd_arch_arc:
74      {
75	disassemble = arc_get_disassembler (bfd_get_mach (abfd),
76					    bfd_big_endian (abfd));
77	break;
78      }
79#endif
80#ifdef ARCH_arm
81    case bfd_arch_arm:
82      if (bfd_big_endian (abfd))
83	disassemble = print_insn_big_arm;
84      else
85	disassemble = print_insn_little_arm;
86      break;
87#endif
88#ifdef ARCH_d10v
89    case bfd_arch_d10v:
90      disassemble = print_insn_d10v;
91      break;
92#endif
93#ifdef ARCH_h8300
94    case bfd_arch_h8300:
95      if (bfd_get_mach(abfd) == bfd_mach_h8300h)
96	disassemble = print_insn_h8300h;
97      else if (bfd_get_mach(abfd) == bfd_mach_h8300s)
98	disassemble = print_insn_h8300s;
99      else
100	disassemble = print_insn_h8300;
101      break;
102#endif
103#ifdef ARCH_h8500
104    case bfd_arch_h8500:
105      disassemble = print_insn_h8500;
106      break;
107#endif
108#ifdef ARCH_hppa
109    case bfd_arch_hppa:
110      disassemble = print_insn_hppa;
111      break;
112#endif
113#ifdef ARCH_i386
114    case bfd_arch_i386:
115      disassemble = print_insn_i386;
116      break;
117#endif
118#ifdef ARCH_i960
119    case bfd_arch_i960:
120      disassemble = print_insn_i960;
121      break;
122#endif
123#ifdef ARCH_m32r
124    case bfd_arch_m32r:
125      disassemble = print_insn_m32r;
126      break;
127#endif
128#ifdef ARCH_m68k
129    case bfd_arch_m68k:
130      disassemble = print_insn_m68k;
131      break;
132#endif
133#ifdef ARCH_m88k
134    case bfd_arch_m88k:
135      disassemble = print_insn_m88k;
136      break;
137#endif
138#ifdef ARCH_ns32k
139    case bfd_arch_ns32k:
140      disassemble = print_insn_ns32k;
141      break;
142#endif
143#ifdef ARCH_mips
144    case bfd_arch_mips:
145      if (bfd_big_endian (abfd))
146	disassemble = print_insn_big_mips;
147      else
148	disassemble = print_insn_little_mips;
149      break;
150#endif
151#ifdef ARCH_mn10200
152    case bfd_arch_mn10200:
153      disassemble = print_insn_mn10200;
154      break;
155#endif
156#ifdef ARCH_mn10300
157    case bfd_arch_mn10300:
158      disassemble = print_insn_mn10300;
159      break;
160#endif
161#ifdef ARCH_powerpc
162    case bfd_arch_powerpc:
163      if (bfd_big_endian (abfd))
164	disassemble = print_insn_big_powerpc;
165      else
166	disassemble = print_insn_little_powerpc;
167      break;
168#endif
169#ifdef ARCH_rs6000
170    case bfd_arch_rs6000:
171      disassemble = print_insn_rs6000;
172      break;
173#endif
174#ifdef ARCH_sh
175    case bfd_arch_sh:
176      if (bfd_big_endian (abfd))
177	disassemble = print_insn_sh;
178      else
179	disassemble = print_insn_shl;
180      break;
181#endif
182#ifdef ARCH_sparc
183    case bfd_arch_sparc:
184      disassemble = print_insn_sparc;
185      break;
186#endif
187#ifdef ARCH_tic30
188    case bfd_arch_tic30:
189      disassemble = print_insn_tic30;
190      break;
191#endif
192#ifdef ARCH_v850
193    case bfd_arch_v850:
194      disassemble = print_insn_v850;
195      break;
196#endif
197#ifdef ARCH_w65
198    case bfd_arch_w65:
199      disassemble = print_insn_w65;
200      break;
201#endif
202#ifdef ARCH_z8k
203    case bfd_arch_z8k:
204      if (bfd_get_mach(abfd) == bfd_mach_z8001)
205	disassemble = print_insn_z8001;
206      else
207	disassemble = print_insn_z8002;
208      break;
209#endif
210    default:
211      return 0;
212    }
213  return disassemble;
214}
215
216