* dwarf2.c (add_line_info): Ensure that the line_info_table is
[binutils.git] / opcodes / disassemble.c
blob4bd0d898c32821e4f054b67e9b542a8b089a4876
1 /* Select disassembly routine for specified architecture.
2 Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19 #include "sysdep.h"
20 #include "dis-asm.h"
22 #ifdef ARCH_all
23 #define ARCH_a29k
24 #define ARCH_alpha
25 #define ARCH_arc
26 #define ARCH_arm
27 #define ARCH_avr
28 #define ARCH_cris
29 #define ARCH_d10v
30 #define ARCH_d30v
31 #define ARCH_dlx
32 #define ARCH_h8300
33 #define ARCH_h8500
34 #define ARCH_hppa
35 #define ARCH_i370
36 #define ARCH_i386
37 #define ARCH_i860
38 #define ARCH_i960
39 #define ARCH_ip2k
40 #define ARCH_ia64
41 #define ARCH_fr30
42 #define ARCH_m32r
43 #define ARCH_m68k
44 #define ARCH_m68hc11
45 #define ARCH_m68hc12
46 #define ARCH_m88k
47 #define ARCH_mcore
48 #define ARCH_mips
49 #define ARCH_mmix
50 #define ARCH_mn10200
51 #define ARCH_mn10300
52 #define ARCH_ns32k
53 #define ARCH_openrisc
54 #define ARCH_or32
55 #define ARCH_pdp11
56 #define ARCH_pj
57 #define ARCH_powerpc
58 #define ARCH_rs6000
59 #define ARCH_s390
60 #define ARCH_sh
61 #define ARCH_sparc
62 #define ARCH_tic30
63 #define ARCH_tic4x
64 #define ARCH_tic54x
65 #define ARCH_tic80
66 #define ARCH_v850
67 #define ARCH_vax
68 #define ARCH_w65
69 #define ARCH_xstormy16
70 #define ARCH_z8k
71 #define ARCH_frv
72 #define INCLUDE_SHMEDIA
73 #endif
76 disassembler_ftype
77 disassembler (abfd)
78 bfd *abfd;
80 enum bfd_architecture a = bfd_get_arch (abfd);
81 disassembler_ftype disassemble;
83 switch (a)
85 /* If you add a case to this table, also add it to the
86 ARCH_all definition right above this function. */
87 #ifdef ARCH_a29k
88 case bfd_arch_a29k:
89 /* As far as I know we only handle big-endian 29k objects. */
90 disassemble = print_insn_big_a29k;
91 break;
92 #endif
93 #ifdef ARCH_alpha
94 case bfd_arch_alpha:
95 disassemble = print_insn_alpha;
96 break;
97 #endif
98 #ifdef ARCH_arc
99 case bfd_arch_arc:
101 disassemble = arc_get_disassembler (abfd);
102 break;
104 #endif
105 #ifdef ARCH_arm
106 case bfd_arch_arm:
107 if (bfd_big_endian (abfd))
108 disassemble = print_insn_big_arm;
109 else
110 disassemble = print_insn_little_arm;
111 break;
112 #endif
113 #ifdef ARCH_avr
114 case bfd_arch_avr:
115 disassemble = print_insn_avr;
116 break;
117 #endif
118 #ifdef ARCH_cris
119 case bfd_arch_cris:
120 disassemble = cris_get_disassembler (abfd);
121 break;
122 #endif
123 #ifdef ARCH_d10v
124 case bfd_arch_d10v:
125 disassemble = print_insn_d10v;
126 break;
127 #endif
128 #ifdef ARCH_d30v
129 case bfd_arch_d30v:
130 disassemble = print_insn_d30v;
131 break;
132 #endif
133 #ifdef ARCH_dlx
134 case bfd_arch_dlx:
135 /* As far as I know we only handle big-endian DLX objects. */
136 disassemble = print_insn_dlx;
137 break;
138 #endif
139 #ifdef ARCH_h8300
140 case bfd_arch_h8300:
141 if (bfd_get_mach(abfd) == bfd_mach_h8300h)
142 disassemble = print_insn_h8300h;
143 else if (bfd_get_mach(abfd) == bfd_mach_h8300s)
144 disassemble = print_insn_h8300s;
145 else
146 disassemble = print_insn_h8300;
147 break;
148 #endif
149 #ifdef ARCH_h8500
150 case bfd_arch_h8500:
151 disassemble = print_insn_h8500;
152 break;
153 #endif
154 #ifdef ARCH_hppa
155 case bfd_arch_hppa:
156 disassemble = print_insn_hppa;
157 break;
158 #endif
159 #ifdef ARCH_i370
160 case bfd_arch_i370:
161 disassemble = print_insn_i370;
162 break;
163 #endif
164 #ifdef ARCH_i386
165 case bfd_arch_i386:
166 disassemble = print_insn_i386;
167 break;
168 #endif
169 #ifdef ARCH_i860
170 case bfd_arch_i860:
171 disassemble = print_insn_i860;
172 break;
173 #endif
174 #ifdef ARCH_i960
175 case bfd_arch_i960:
176 disassemble = print_insn_i960;
177 break;
178 #endif
179 #ifdef ARCH_ia64
180 case bfd_arch_ia64:
181 disassemble = print_insn_ia64;
182 break;
183 #endif
184 #ifdef ARCH_ip2k
185 case bfd_arch_ip2k:
186 disassemble = print_insn_ip2k;
187 break;
188 #endif
189 #ifdef ARCH_fr30
190 case bfd_arch_fr30:
191 disassemble = print_insn_fr30;
192 break;
193 #endif
194 #ifdef ARCH_m32r
195 case bfd_arch_m32r:
196 disassemble = print_insn_m32r;
197 break;
198 #endif
199 #if defined(ARCH_m68hc11) || defined(ARCH_m68hc12)
200 case bfd_arch_m68hc11:
201 disassemble = print_insn_m68hc11;
202 break;
203 case bfd_arch_m68hc12:
204 disassemble = print_insn_m68hc12;
205 break;
206 #endif
207 #ifdef ARCH_m68k
208 case bfd_arch_m68k:
209 disassemble = print_insn_m68k;
210 break;
211 #endif
212 #ifdef ARCH_m88k
213 case bfd_arch_m88k:
214 disassemble = print_insn_m88k;
215 break;
216 #endif
217 #ifdef ARCH_ns32k
218 case bfd_arch_ns32k:
219 disassemble = print_insn_ns32k;
220 break;
221 #endif
222 #ifdef ARCH_mcore
223 case bfd_arch_mcore:
224 disassemble = print_insn_mcore;
225 break;
226 #endif
227 #ifdef ARCH_mips
228 case bfd_arch_mips:
229 if (bfd_big_endian (abfd))
230 disassemble = print_insn_big_mips;
231 else
232 disassemble = print_insn_little_mips;
233 break;
234 #endif
235 #ifdef ARCH_mmix
236 case bfd_arch_mmix:
237 disassemble = print_insn_mmix;
238 break;
239 #endif
240 #ifdef ARCH_mn10200
241 case bfd_arch_mn10200:
242 disassemble = print_insn_mn10200;
243 break;
244 #endif
245 #ifdef ARCH_mn10300
246 case bfd_arch_mn10300:
247 disassemble = print_insn_mn10300;
248 break;
249 #endif
250 #ifdef ARCH_openrisc
251 case bfd_arch_openrisc:
252 disassemble = print_insn_openrisc;
253 break;
254 #endif
255 #ifdef ARCH_or32
256 case bfd_arch_or32:
257 if (bfd_big_endian (abfd))
258 disassemble = print_insn_big_or32;
259 else
260 disassemble = print_insn_little_or32;
261 break;
262 #endif
263 #ifdef ARCH_pdp11
264 case bfd_arch_pdp11:
265 disassemble = print_insn_pdp11;
266 break;
267 #endif
268 #ifdef ARCH_pj
269 case bfd_arch_pj:
270 disassemble = print_insn_pj;
271 break;
272 #endif
273 #ifdef ARCH_powerpc
274 case bfd_arch_powerpc:
275 if (bfd_big_endian (abfd))
276 disassemble = print_insn_big_powerpc;
277 else
278 disassemble = print_insn_little_powerpc;
279 break;
280 #endif
281 #ifdef ARCH_rs6000
282 case bfd_arch_rs6000:
283 if (bfd_get_mach (abfd) == bfd_mach_ppc_620)
284 disassemble = print_insn_big_powerpc;
285 else
286 disassemble = print_insn_rs6000;
287 break;
288 #endif
289 #ifdef ARCH_s390
290 case bfd_arch_s390:
291 disassemble = print_insn_s390;
292 break;
293 #endif
294 #ifdef ARCH_sh
295 case bfd_arch_sh:
296 disassemble = print_insn_sh;
297 break;
298 #endif
299 #ifdef ARCH_sparc
300 case bfd_arch_sparc:
301 disassemble = print_insn_sparc;
302 break;
303 #endif
304 #ifdef ARCH_tic30
305 case bfd_arch_tic30:
306 disassemble = print_insn_tic30;
307 break;
308 #endif
309 #ifdef ARCH_tic4x
310 case bfd_arch_tic4x:
311 disassemble = print_insn_tic4x;
312 break;
313 #endif
314 #ifdef ARCH_tic54x
315 case bfd_arch_tic54x:
316 disassemble = print_insn_tic54x;
317 break;
318 #endif
319 #ifdef ARCH_tic80
320 case bfd_arch_tic80:
321 disassemble = print_insn_tic80;
322 break;
323 #endif
324 #ifdef ARCH_v850
325 case bfd_arch_v850:
326 disassemble = print_insn_v850;
327 break;
328 #endif
329 #ifdef ARCH_w65
330 case bfd_arch_w65:
331 disassemble = print_insn_w65;
332 break;
333 #endif
334 #ifdef ARCH_xstormy16
335 case bfd_arch_xstormy16:
336 disassemble = print_insn_xstormy16;
337 break;
338 #endif
339 #ifdef ARCH_z8k
340 case bfd_arch_z8k:
341 if (bfd_get_mach(abfd) == bfd_mach_z8001)
342 disassemble = print_insn_z8001;
343 else
344 disassemble = print_insn_z8002;
345 break;
346 #endif
347 #ifdef ARCH_vax
348 case bfd_arch_vax:
349 disassemble = print_insn_vax;
350 break;
351 #endif
352 #ifdef ARCH_frv
353 case bfd_arch_frv:
354 disassemble = print_insn_frv;
355 break;
356 #endif
357 default:
358 return 0;
360 return disassemble;
363 void
364 disassembler_usage (stream)
365 FILE * stream ATTRIBUTE_UNUSED;
367 #ifdef ARCH_arm
368 print_arm_disassembler_options (stream);
369 #endif
370 #ifdef ARCH_powerpc
371 print_ppc_disassembler_options (stream);
372 #endif
374 return;