2004-02-11 Andrew Cagney <cagney@redhat.com>
[binutils.git] / opcodes / disassemble.c
blobd5b17be325318277a8eca3555d2ffe1c55ab7904
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_msp430
53 #define ARCH_ns32k
54 #define ARCH_openrisc
55 #define ARCH_or32
56 #define ARCH_pdp11
57 #define ARCH_pj
58 #define ARCH_powerpc
59 #define ARCH_rs6000
60 #define ARCH_s390
61 #define ARCH_sh
62 #define ARCH_sparc
63 #define ARCH_tic30
64 #define ARCH_tic4x
65 #define ARCH_tic54x
66 #define ARCH_tic80
67 #define ARCH_v850
68 #define ARCH_vax
69 #define ARCH_w65
70 #define ARCH_xstormy16
71 #define ARCH_xtensa
72 #define ARCH_z8k
73 #define ARCH_frv
74 #define ARCH_iq2000
75 #define INCLUDE_SHMEDIA
76 #endif
79 disassembler_ftype
80 disassembler (abfd)
81 bfd *abfd;
83 enum bfd_architecture a = bfd_get_arch (abfd);
84 disassembler_ftype disassemble;
86 switch (a)
88 /* If you add a case to this table, also add it to the
89 ARCH_all definition right above this function. */
90 #ifdef ARCH_a29k
91 case bfd_arch_a29k:
92 /* As far as I know we only handle big-endian 29k objects. */
93 disassemble = print_insn_big_a29k;
94 break;
95 #endif
96 #ifdef ARCH_alpha
97 case bfd_arch_alpha:
98 disassemble = print_insn_alpha;
99 break;
100 #endif
101 #ifdef ARCH_arc
102 case bfd_arch_arc:
104 disassemble = arc_get_disassembler (abfd);
105 break;
107 #endif
108 #ifdef ARCH_arm
109 case bfd_arch_arm:
110 if (bfd_big_endian (abfd))
111 disassemble = print_insn_big_arm;
112 else
113 disassemble = print_insn_little_arm;
114 break;
115 #endif
116 #ifdef ARCH_avr
117 case bfd_arch_avr:
118 disassemble = print_insn_avr;
119 break;
120 #endif
121 #ifdef ARCH_cris
122 case bfd_arch_cris:
123 disassemble = cris_get_disassembler (abfd);
124 break;
125 #endif
126 #ifdef ARCH_d10v
127 case bfd_arch_d10v:
128 disassemble = print_insn_d10v;
129 break;
130 #endif
131 #ifdef ARCH_d30v
132 case bfd_arch_d30v:
133 disassemble = print_insn_d30v;
134 break;
135 #endif
136 #ifdef ARCH_dlx
137 case bfd_arch_dlx:
138 /* As far as I know we only handle big-endian DLX objects. */
139 disassemble = print_insn_dlx;
140 break;
141 #endif
142 #ifdef ARCH_h8300
143 case bfd_arch_h8300:
144 if (bfd_get_mach (abfd) == bfd_mach_h8300h
145 || bfd_get_mach (abfd) == bfd_mach_h8300hn)
146 disassemble = print_insn_h8300h;
147 else if (bfd_get_mach (abfd) == bfd_mach_h8300s
148 || bfd_get_mach (abfd) == bfd_mach_h8300sn
149 || bfd_get_mach (abfd) == bfd_mach_h8300sx)
150 disassemble = print_insn_h8300s;
151 else
152 disassemble = print_insn_h8300;
153 break;
154 #endif
155 #ifdef ARCH_h8500
156 case bfd_arch_h8500:
157 disassemble = print_insn_h8500;
158 break;
159 #endif
160 #ifdef ARCH_hppa
161 case bfd_arch_hppa:
162 disassemble = print_insn_hppa;
163 break;
164 #endif
165 #ifdef ARCH_i370
166 case bfd_arch_i370:
167 disassemble = print_insn_i370;
168 break;
169 #endif
170 #ifdef ARCH_i386
171 case bfd_arch_i386:
172 disassemble = print_insn_i386;
173 break;
174 #endif
175 #ifdef ARCH_i860
176 case bfd_arch_i860:
177 disassemble = print_insn_i860;
178 break;
179 #endif
180 #ifdef ARCH_i960
181 case bfd_arch_i960:
182 disassemble = print_insn_i960;
183 break;
184 #endif
185 #ifdef ARCH_ia64
186 case bfd_arch_ia64:
187 disassemble = print_insn_ia64;
188 break;
189 #endif
190 #ifdef ARCH_ip2k
191 case bfd_arch_ip2k:
192 disassemble = print_insn_ip2k;
193 break;
194 #endif
195 #ifdef ARCH_fr30
196 case bfd_arch_fr30:
197 disassemble = print_insn_fr30;
198 break;
199 #endif
200 #ifdef ARCH_m32r
201 case bfd_arch_m32r:
202 disassemble = print_insn_m32r;
203 break;
204 #endif
205 #if defined(ARCH_m68hc11) || defined(ARCH_m68hc12)
206 case bfd_arch_m68hc11:
207 disassemble = print_insn_m68hc11;
208 break;
209 case bfd_arch_m68hc12:
210 disassemble = print_insn_m68hc12;
211 break;
212 #endif
213 #ifdef ARCH_m68k
214 case bfd_arch_m68k:
215 disassemble = print_insn_m68k;
216 break;
217 #endif
218 #ifdef ARCH_m88k
219 case bfd_arch_m88k:
220 disassemble = print_insn_m88k;
221 break;
222 #endif
223 #ifdef ARCH_msp430
224 case bfd_arch_msp430:
225 disassemble = print_insn_msp430;
226 break;
227 #endif
228 #ifdef ARCH_ns32k
229 case bfd_arch_ns32k:
230 disassemble = print_insn_ns32k;
231 break;
232 #endif
233 #ifdef ARCH_mcore
234 case bfd_arch_mcore:
235 disassemble = print_insn_mcore;
236 break;
237 #endif
238 #ifdef ARCH_mips
239 case bfd_arch_mips:
240 if (bfd_big_endian (abfd))
241 disassemble = print_insn_big_mips;
242 else
243 disassemble = print_insn_little_mips;
244 break;
245 #endif
246 #ifdef ARCH_mmix
247 case bfd_arch_mmix:
248 disassemble = print_insn_mmix;
249 break;
250 #endif
251 #ifdef ARCH_mn10200
252 case bfd_arch_mn10200:
253 disassemble = print_insn_mn10200;
254 break;
255 #endif
256 #ifdef ARCH_mn10300
257 case bfd_arch_mn10300:
258 disassemble = print_insn_mn10300;
259 break;
260 #endif
261 #ifdef ARCH_openrisc
262 case bfd_arch_openrisc:
263 disassemble = print_insn_openrisc;
264 break;
265 #endif
266 #ifdef ARCH_or32
267 case bfd_arch_or32:
268 if (bfd_big_endian (abfd))
269 disassemble = print_insn_big_or32;
270 else
271 disassemble = print_insn_little_or32;
272 break;
273 #endif
274 #ifdef ARCH_pdp11
275 case bfd_arch_pdp11:
276 disassemble = print_insn_pdp11;
277 break;
278 #endif
279 #ifdef ARCH_pj
280 case bfd_arch_pj:
281 disassemble = print_insn_pj;
282 break;
283 #endif
284 #ifdef ARCH_powerpc
285 case bfd_arch_powerpc:
286 if (bfd_big_endian (abfd))
287 disassemble = print_insn_big_powerpc;
288 else
289 disassemble = print_insn_little_powerpc;
290 break;
291 #endif
292 #ifdef ARCH_rs6000
293 case bfd_arch_rs6000:
294 if (bfd_get_mach (abfd) == bfd_mach_ppc_620)
295 disassemble = print_insn_big_powerpc;
296 else
297 disassemble = print_insn_rs6000;
298 break;
299 #endif
300 #ifdef ARCH_s390
301 case bfd_arch_s390:
302 disassemble = print_insn_s390;
303 break;
304 #endif
305 #ifdef ARCH_sh
306 case bfd_arch_sh:
307 disassemble = print_insn_sh;
308 break;
309 #endif
310 #ifdef ARCH_sparc
311 case bfd_arch_sparc:
312 disassemble = print_insn_sparc;
313 break;
314 #endif
315 #ifdef ARCH_tic30
316 case bfd_arch_tic30:
317 disassemble = print_insn_tic30;
318 break;
319 #endif
320 #ifdef ARCH_tic4x
321 case bfd_arch_tic4x:
322 disassemble = print_insn_tic4x;
323 break;
324 #endif
325 #ifdef ARCH_tic54x
326 case bfd_arch_tic54x:
327 disassemble = print_insn_tic54x;
328 break;
329 #endif
330 #ifdef ARCH_tic80
331 case bfd_arch_tic80:
332 disassemble = print_insn_tic80;
333 break;
334 #endif
335 #ifdef ARCH_v850
336 case bfd_arch_v850:
337 disassemble = print_insn_v850;
338 break;
339 #endif
340 #ifdef ARCH_w65
341 case bfd_arch_w65:
342 disassemble = print_insn_w65;
343 break;
344 #endif
345 #ifdef ARCH_xstormy16
346 case bfd_arch_xstormy16:
347 disassemble = print_insn_xstormy16;
348 break;
349 #endif
350 #ifdef ARCH_xtensa
351 case bfd_arch_xtensa:
352 disassemble = print_insn_xtensa;
353 break;
354 #endif
355 #ifdef ARCH_z8k
356 case bfd_arch_z8k:
357 if (bfd_get_mach(abfd) == bfd_mach_z8001)
358 disassemble = print_insn_z8001;
359 else
360 disassemble = print_insn_z8002;
361 break;
362 #endif
363 #ifdef ARCH_vax
364 case bfd_arch_vax:
365 disassemble = print_insn_vax;
366 break;
367 #endif
368 #ifdef ARCH_frv
369 case bfd_arch_frv:
370 disassemble = print_insn_frv;
371 break;
372 #endif
373 #ifdef ARCH_iq2000
374 case bfd_arch_iq2000:
375 disassemble = print_insn_iq2000;
376 break;
377 #endif
378 default:
379 return 0;
381 return disassemble;
384 void
385 disassembler_usage (stream)
386 FILE * stream ATTRIBUTE_UNUSED;
388 #ifdef ARCH_arm
389 print_arm_disassembler_options (stream);
390 #endif
391 #ifdef ARCH_mips
392 print_mips_disassembler_options (stream);
393 #endif
394 #ifdef ARCH_powerpc
395 print_ppc_disassembler_options (stream);
396 #endif
398 return;
401 void
402 disassemble_init_for_target (struct disassemble_info * info)
404 if (info == NULL)
405 return;
407 switch (info->arch)
409 #ifdef ARCH_arm
410 case bfd_arch_arm:
411 info->symbol_is_valid = arm_symbol_is_valid;
412 break;
413 #endif
414 default:
415 break;