IA-64 ELF support.
[platform/upstream/binutils.git] / opcodes / disassemble.c
1 /* Select disassembly routine for specified architecture.
2    Copyright (C) 1994, 95, 96, 97, 98, 99, 2000
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_d10v
29 #define ARCH_d30v
30 #define ARCH_h8300
31 #define ARCH_h8500
32 #define ARCH_hppa
33 #define ARCH_i370
34 #define ARCH_i386
35 #define ARCH_i960
36 #define ARCH_ia64
37 #define ARCH_fr30
38 #define ARCH_m32r
39 #define ARCH_m68k
40 #define ARCH_m88k
41 #define ARCH_mcore
42 #define ARCH_mips
43 #define ARCH_mn10200
44 #define ARCH_mn10300
45 #define ARCH_ns32k
46 #define ARCH_pj
47 #define ARCH_powerpc
48 #define ARCH_rs6000
49 #define ARCH_sh
50 #define ARCH_sparc
51 #define ARCH_tic30
52 #define ARCH_tic80
53 #define ARCH_v850
54 #define ARCH_vax
55 #define ARCH_w65
56 #define ARCH_z8k
57 #endif
58
59
60 disassembler_ftype
61 disassembler (abfd)
62      bfd *abfd;
63 {
64   enum bfd_architecture a = bfd_get_arch (abfd);
65   disassembler_ftype disassemble;
66
67   switch (a)
68     {
69       /* If you add a case to this table, also add it to the
70          ARCH_all definition right above this function.  */
71 #ifdef ARCH_a29k
72     case bfd_arch_a29k:
73       /* As far as I know we only handle big-endian 29k objects.  */
74       disassemble = print_insn_big_a29k;
75       break;
76 #endif
77 #ifdef ARCH_alpha
78     case bfd_arch_alpha:
79       disassemble = print_insn_alpha;
80       break;
81 #endif
82 #ifdef ARCH_arc
83     case bfd_arch_arc:
84       {
85         disassemble = arc_get_disassembler (bfd_get_mach (abfd),
86                                             bfd_big_endian (abfd));
87         break;
88       }
89 #endif
90 #ifdef ARCH_arm
91     case bfd_arch_arm:
92       if (bfd_big_endian (abfd))
93         disassemble = print_insn_big_arm;
94       else
95         disassemble = print_insn_little_arm;
96       break;
97 #endif
98 #ifdef ARCH_avr
99     case bfd_arch_avr:
100       disassemble = print_insn_avr;
101       break;
102 #endif
103 #ifdef ARCH_d10v
104     case bfd_arch_d10v:
105       disassemble = print_insn_d10v;
106       break;
107 #endif
108 #ifdef ARCH_d30v
109     case bfd_arch_d30v:
110       disassemble = print_insn_d30v;
111       break;
112 #endif
113 #ifdef ARCH_h8300
114     case bfd_arch_h8300:
115       if (bfd_get_mach(abfd) == bfd_mach_h8300h)
116         disassemble = print_insn_h8300h;
117       else if (bfd_get_mach(abfd) == bfd_mach_h8300s)
118         disassemble = print_insn_h8300s;
119       else 
120         disassemble = print_insn_h8300;
121       break;
122 #endif
123 #ifdef ARCH_h8500
124     case bfd_arch_h8500:
125       disassemble = print_insn_h8500;
126       break;
127 #endif
128 #ifdef ARCH_hppa
129     case bfd_arch_hppa:
130       disassemble = print_insn_hppa;
131       break;
132 #endif
133 #ifdef ARCH_i370
134     case bfd_arch_i370:
135       disassemble = print_insn_i370;
136       break;
137 #endif
138 #ifdef ARCH_i386
139     case bfd_arch_i386:
140       if (bfd_get_mach (abfd) == bfd_mach_i386_i386_intel_syntax)
141         disassemble = print_insn_i386_intel;
142       else
143         disassemble = print_insn_i386_att;
144       break;
145 #endif
146 #ifdef ARCH_i960
147     case bfd_arch_i960:
148       disassemble = print_insn_i960;
149       break;
150 #endif
151 #ifdef ARCH_ia64
152     case bfd_arch_ia64:
153       disassemble = print_insn_ia64;
154       break;
155 #endif
156 #ifdef ARCH_fr30
157     case bfd_arch_fr30:
158       disassemble = print_insn_fr30;
159       break;
160 #endif
161 #ifdef ARCH_m32r
162     case bfd_arch_m32r:
163       disassemble = print_insn_m32r;
164       break;
165 #endif
166 #ifdef ARCH_m68k
167     case bfd_arch_m68k:
168       disassemble = print_insn_m68k;
169       break;
170 #endif
171 #ifdef ARCH_m88k
172     case bfd_arch_m88k:
173       disassemble = print_insn_m88k;
174       break;
175 #endif
176 #ifdef ARCH_ns32k
177     case bfd_arch_ns32k:
178       disassemble = print_insn_ns32k;
179       break;
180 #endif
181 #ifdef ARCH_mcore
182     case bfd_arch_mcore:
183       disassemble = print_insn_mcore;
184       break;
185 #endif
186 #ifdef ARCH_mips
187     case bfd_arch_mips:
188       if (bfd_big_endian (abfd))
189         disassemble = print_insn_big_mips;
190       else
191         disassemble = print_insn_little_mips;
192       break;
193 #endif
194 #ifdef ARCH_mn10200
195     case bfd_arch_mn10200:
196       disassemble = print_insn_mn10200;
197       break;
198 #endif
199 #ifdef ARCH_mn10300
200     case bfd_arch_mn10300:
201       disassemble = print_insn_mn10300;
202       break;
203 #endif
204 #ifdef ARCH_pj
205     case bfd_arch_pj:
206       disassemble = print_insn_pj;
207       break;
208 #endif
209 #ifdef ARCH_powerpc
210     case bfd_arch_powerpc:
211       if (bfd_big_endian (abfd))
212         disassemble = print_insn_big_powerpc;
213       else
214         disassemble = print_insn_little_powerpc;
215       break;
216 #endif
217 #ifdef ARCH_rs6000
218     case bfd_arch_rs6000:
219       disassemble = print_insn_rs6000;
220       break;
221 #endif
222 #ifdef ARCH_sh
223     case bfd_arch_sh:
224       if (bfd_big_endian (abfd))
225         disassemble = print_insn_sh;
226       else
227         disassemble = print_insn_shl;
228       break;
229 #endif
230 #ifdef ARCH_sparc
231     case bfd_arch_sparc:
232       disassemble = print_insn_sparc;
233       break;
234 #endif
235 #ifdef ARCH_tic30
236     case bfd_arch_tic30:
237       disassemble = print_insn_tic30;
238       break;
239 #endif
240 #ifdef ARCH_tic80
241     case bfd_arch_tic80:
242       disassemble = print_insn_tic80;
243       break;
244 #endif
245 #ifdef ARCH_v850
246     case bfd_arch_v850:
247       disassemble = print_insn_v850;
248       break;
249 #endif
250 #ifdef ARCH_w65
251     case bfd_arch_w65:
252       disassemble = print_insn_w65;
253       break;
254 #endif
255 #ifdef ARCH_z8k
256     case bfd_arch_z8k:
257       if (bfd_get_mach(abfd) == bfd_mach_z8001)
258         disassemble = print_insn_z8001;
259       else 
260         disassemble = print_insn_z8002;
261       break;
262 #endif
263 #ifdef ARCH_vax
264     case bfd_arch_vax:
265       disassemble = print_insn_vax;
266       break;
267 #endif
268     default:
269       return 0;
270     }
271   return disassemble;
272 }
273
274 void
275 disassembler_usage (stream)
276      FILE *stream ATTRIBUTE_UNUSED;
277 {
278 #ifdef ARCH_arm
279   print_arm_disassembler_options (stream);
280 #endif
281   
282   return;
283 }