binutils/ChangeLog
[external/binutils.git] / opcodes / disassemble.c
1 /* Select disassembly routine for specified architecture.
2    Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
3    Free Software Foundation, Inc.
4
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.
9
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.
14
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.  */
18
19 #include "sysdep.h"
20 #include "dis-asm.h"
21
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_h8300
32 #define ARCH_h8500
33 #define ARCH_hppa
34 #define ARCH_i370
35 #define ARCH_i386
36 #define ARCH_i860
37 #define ARCH_i960
38 #define ARCH_ia64
39 #define ARCH_fr30
40 #define ARCH_m32r
41 #define ARCH_m68k
42 #define ARCH_m68hc11
43 #define ARCH_m68hc12
44 #define ARCH_m88k
45 #define ARCH_mcore
46 #define ARCH_mips
47 #define ARCH_mmix
48 #define ARCH_mn10200
49 #define ARCH_mn10300
50 #define ARCH_ns32k
51 #define ARCH_openrisc
52 #define ARCH_pdp11
53 #define ARCH_pj
54 #define ARCH_powerpc
55 #define ARCH_rs6000
56 #define ARCH_s390
57 #define ARCH_sh
58 #define ARCH_sparc
59 #define ARCH_tic30
60 #define ARCH_tic54x
61 #define ARCH_tic80
62 #define ARCH_v850
63 #define ARCH_vax
64 #define ARCH_w65
65 #define ARCH_z8k
66 #endif
67
68
69 disassembler_ftype
70 disassembler (abfd)
71      bfd *abfd;
72 {
73   enum bfd_architecture a = bfd_get_arch (abfd);
74   disassembler_ftype disassemble;
75
76   switch (a)
77     {
78       /* If you add a case to this table, also add it to the
79          ARCH_all definition right above this function.  */
80 #ifdef ARCH_a29k
81     case bfd_arch_a29k:
82       /* As far as I know we only handle big-endian 29k objects.  */
83       disassemble = print_insn_big_a29k;
84       break;
85 #endif
86 #ifdef ARCH_alpha
87     case bfd_arch_alpha:
88       disassemble = print_insn_alpha;
89       break;
90 #endif
91 #ifdef ARCH_arc
92     case bfd_arch_arc:
93       {
94         disassemble = arc_get_disassembler (abfd);
95         break;
96       }
97 #endif
98 #ifdef ARCH_arm
99     case bfd_arch_arm:
100       if (bfd_big_endian (abfd))
101         disassemble = print_insn_big_arm;
102       else
103         disassemble = print_insn_little_arm;
104       break;
105 #endif
106 #ifdef ARCH_avr
107     case bfd_arch_avr:
108       disassemble = print_insn_avr;
109       break;
110 #endif
111 #ifdef ARCH_cris
112     case bfd_arch_cris:
113       disassemble = cris_get_disassembler (abfd);
114       break;
115 #endif
116 #ifdef ARCH_d10v
117     case bfd_arch_d10v:
118       disassemble = print_insn_d10v;
119       break;
120 #endif
121 #ifdef ARCH_d30v
122     case bfd_arch_d30v:
123       disassemble = print_insn_d30v;
124       break;
125 #endif
126 #ifdef ARCH_h8300
127     case bfd_arch_h8300:
128       if (bfd_get_mach(abfd) == bfd_mach_h8300h)
129         disassemble = print_insn_h8300h;
130       else if (bfd_get_mach(abfd) == bfd_mach_h8300s)
131         disassemble = print_insn_h8300s;
132       else
133         disassemble = print_insn_h8300;
134       break;
135 #endif
136 #ifdef ARCH_h8500
137     case bfd_arch_h8500:
138       disassemble = print_insn_h8500;
139       break;
140 #endif
141 #ifdef ARCH_hppa
142     case bfd_arch_hppa:
143       disassemble = print_insn_hppa;
144       break;
145 #endif
146 #ifdef ARCH_i370
147     case bfd_arch_i370:
148       disassemble = print_insn_i370;
149       break;
150 #endif
151 #ifdef ARCH_i386
152     case bfd_arch_i386:
153       disassemble = print_insn_i386;
154       break;
155 #endif
156 #ifdef ARCH_i860
157     case bfd_arch_i860:
158       disassemble = print_insn_i860;
159       break;
160 #endif
161 #ifdef ARCH_i960
162     case bfd_arch_i960:
163       disassemble = print_insn_i960;
164       break;
165 #endif
166 #ifdef ARCH_ia64
167     case bfd_arch_ia64:
168       disassemble = print_insn_ia64;
169       break;
170 #endif
171 #ifdef ARCH_fr30
172     case bfd_arch_fr30:
173       disassemble = print_insn_fr30;
174       break;
175 #endif
176 #ifdef ARCH_m32r
177     case bfd_arch_m32r:
178       disassemble = print_insn_m32r;
179       break;
180 #endif
181 #if defined(ARCH_m68hc11) || defined(ARCH_m68hc12)
182     case bfd_arch_m68hc11:
183       disassemble = print_insn_m68hc11;
184       break;
185     case bfd_arch_m68hc12:
186       disassemble = print_insn_m68hc12;
187       break;
188 #endif
189 #ifdef ARCH_m68k
190     case bfd_arch_m68k:
191       disassemble = print_insn_m68k;
192       break;
193 #endif
194 #ifdef ARCH_m88k
195     case bfd_arch_m88k:
196       disassemble = print_insn_m88k;
197       break;
198 #endif
199 #ifdef ARCH_ns32k
200     case bfd_arch_ns32k:
201       disassemble = print_insn_ns32k;
202       break;
203 #endif
204 #ifdef ARCH_mcore
205     case bfd_arch_mcore:
206       disassemble = print_insn_mcore;
207       break;
208 #endif
209 #ifdef ARCH_mips
210     case bfd_arch_mips:
211       if (bfd_big_endian (abfd))
212         disassemble = print_insn_big_mips;
213       else
214         disassemble = print_insn_little_mips;
215       break;
216 #endif
217 #ifdef ARCH_mmix
218     case bfd_arch_mmix:
219       disassemble = print_insn_mmix;
220       break;
221 #endif
222 #ifdef ARCH_mn10200
223     case bfd_arch_mn10200:
224       disassemble = print_insn_mn10200;
225       break;
226 #endif
227 #ifdef ARCH_mn10300
228     case bfd_arch_mn10300:
229       disassemble = print_insn_mn10300;
230       break;
231 #endif
232 #ifdef ARCH_openrisc
233     case bfd_arch_openrisc:
234       disassemble = print_insn_openrisc;
235       break;
236 #endif
237 #ifdef ARCH_pdp11
238     case bfd_arch_pdp11:
239       disassemble = print_insn_pdp11;
240       break;
241 #endif
242 #ifdef ARCH_pj
243     case bfd_arch_pj:
244       disassemble = print_insn_pj;
245       break;
246 #endif
247 #ifdef ARCH_powerpc
248     case bfd_arch_powerpc:
249       if (bfd_big_endian (abfd))
250         disassemble = print_insn_big_powerpc;
251       else
252         disassemble = print_insn_little_powerpc;
253       break;
254 #endif
255 #ifdef ARCH_rs6000
256     case bfd_arch_rs6000:
257       if (bfd_get_mach (abfd) == bfd_mach_ppc_620)
258         disassemble = print_insn_big_powerpc;
259       else
260         disassemble = print_insn_rs6000;
261       break;
262 #endif
263 #ifdef ARCH_s390
264     case bfd_arch_s390:
265       disassemble = print_insn_s390;
266       break;
267 #endif
268 #ifdef ARCH_sh
269     case bfd_arch_sh:
270       if (bfd_big_endian (abfd))
271         disassemble = print_insn_sh;
272       else
273         disassemble = print_insn_shl;
274       break;
275 #endif
276 #ifdef ARCH_sparc
277     case bfd_arch_sparc:
278       disassemble = print_insn_sparc;
279       break;
280 #endif
281 #ifdef ARCH_tic30
282     case bfd_arch_tic30:
283       disassemble = print_insn_tic30;
284       break;
285 #endif
286 #ifdef ARCH_tic54x
287     case bfd_arch_tic54x:
288       disassemble = print_insn_tic54x;
289       break;
290 #endif
291 #ifdef ARCH_tic80
292     case bfd_arch_tic80:
293       disassemble = print_insn_tic80;
294       break;
295 #endif
296 #ifdef ARCH_v850
297     case bfd_arch_v850:
298       disassemble = print_insn_v850;
299       break;
300 #endif
301 #ifdef ARCH_w65
302     case bfd_arch_w65:
303       disassemble = print_insn_w65;
304       break;
305 #endif
306 #ifdef ARCH_z8k
307     case bfd_arch_z8k:
308       if (bfd_get_mach(abfd) == bfd_mach_z8001)
309         disassemble = print_insn_z8001;
310       else
311         disassemble = print_insn_z8002;
312       break;
313 #endif
314 #ifdef ARCH_vax
315     case bfd_arch_vax:
316       disassemble = print_insn_vax;
317       break;
318 #endif
319     default:
320       return 0;
321     }
322   return disassemble;
323 }
324
325 void
326 disassembler_usage (stream)
327      FILE * stream ATTRIBUTE_UNUSED;
328 {
329 #ifdef ARCH_arm
330   print_arm_disassembler_options (stream);
331 #endif
332
333   return;
334 }