2000-02-22 H.J. Lu <hjl@gnu.org>
[binutils.git] / opcodes / disassemble.c
blobb961be330ba98744c07150743297b94f797bc3a4
1 /* Select disassembly routine for specified architecture.
2 Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18 #include "ansidecl.h"
19 #include "dis-asm.h"
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_d30v
28 #define ARCH_h8300
29 #define ARCH_h8500
30 #define ARCH_hppa
31 #define ARCH_i386
32 #define ARCH_i960
33 #define ARCH_fr30
34 #define ARCH_m32r
35 #define ARCH_m68k
36 #define ARCH_m88k
37 #define ARCH_mcore
38 #define ARCH_mips
39 #define ARCH_mn10200
40 #define ARCH_mn10300
41 #define ARCH_ns32k
42 #define ARCH_pj
43 #define ARCH_powerpc
44 #define ARCH_rs6000
45 #define ARCH_sh
46 #define ARCH_sparc
47 #define ARCH_tic30
48 #define ARCH_tic80
49 #define ARCH_v850
50 #define ARCH_vax
51 #define ARCH_w65
52 #define ARCH_z8k
53 #endif
56 disassembler_ftype
57 disassembler (abfd)
58 bfd *abfd;
60 enum bfd_architecture a = bfd_get_arch (abfd);
61 disassembler_ftype disassemble;
63 switch (a)
65 /* If you add a case to this table, also add it to the
66 ARCH_all definition right above this function. */
67 #ifdef ARCH_a29k
68 case bfd_arch_a29k:
69 /* As far as I know we only handle big-endian 29k objects. */
70 disassemble = print_insn_big_a29k;
71 break;
72 #endif
73 #ifdef ARCH_alpha
74 case bfd_arch_alpha:
75 disassemble = print_insn_alpha;
76 break;
77 #endif
78 #ifdef ARCH_arc
79 case bfd_arch_arc:
81 disassemble = arc_get_disassembler (bfd_get_mach (abfd),
82 bfd_big_endian (abfd));
83 break;
85 #endif
86 #ifdef ARCH_arm
87 case bfd_arch_arm:
88 if (bfd_big_endian (abfd))
89 disassemble = print_insn_big_arm;
90 else
91 disassemble = print_insn_little_arm;
92 break;
93 #endif
94 #ifdef ARCH_d10v
95 case bfd_arch_d10v:
96 disassemble = print_insn_d10v;
97 break;
98 #endif
99 #ifdef ARCH_d30v
100 case bfd_arch_d30v:
101 disassemble = print_insn_d30v;
102 break;
103 #endif
104 #ifdef ARCH_h8300
105 case bfd_arch_h8300:
106 if (bfd_get_mach(abfd) == bfd_mach_h8300h)
107 disassemble = print_insn_h8300h;
108 else if (bfd_get_mach(abfd) == bfd_mach_h8300s)
109 disassemble = print_insn_h8300s;
110 else
111 disassemble = print_insn_h8300;
112 break;
113 #endif
114 #ifdef ARCH_h8500
115 case bfd_arch_h8500:
116 disassemble = print_insn_h8500;
117 break;
118 #endif
119 #ifdef ARCH_hppa
120 case bfd_arch_hppa:
121 disassemble = print_insn_hppa;
122 break;
123 #endif
124 #ifdef ARCH_i386
125 case bfd_arch_i386:
126 if (bfd_get_mach (abfd) == bfd_mach_i386_i386_intel_syntax)
127 disassemble = print_insn_i386_intel;
128 else
129 disassemble = print_insn_i386_att;
130 break;
131 #endif
132 #ifdef ARCH_i960
133 case bfd_arch_i960:
134 disassemble = print_insn_i960;
135 break;
136 #endif
137 #ifdef ARCH_fr30
138 case bfd_arch_fr30:
139 disassemble = print_insn_fr30;
140 break;
141 #endif
142 #ifdef ARCH_m32r
143 case bfd_arch_m32r:
144 disassemble = print_insn_m32r;
145 break;
146 #endif
147 #ifdef ARCH_m68k
148 case bfd_arch_m68k:
149 disassemble = print_insn_m68k;
150 break;
151 #endif
152 #ifdef ARCH_m88k
153 case bfd_arch_m88k:
154 disassemble = print_insn_m88k;
155 break;
156 #endif
157 #ifdef ARCH_ns32k
158 case bfd_arch_ns32k:
159 disassemble = print_insn_ns32k;
160 break;
161 #endif
162 #ifdef ARCH_mcore
163 case bfd_arch_mcore:
164 disassemble = print_insn_mcore;
165 break;
166 #endif
167 #ifdef ARCH_mips
168 case bfd_arch_mips:
169 if (bfd_big_endian (abfd))
170 disassemble = print_insn_big_mips;
171 else
172 disassemble = print_insn_little_mips;
173 break;
174 #endif
175 #ifdef ARCH_mn10200
176 case bfd_arch_mn10200:
177 disassemble = print_insn_mn10200;
178 break;
179 #endif
180 #ifdef ARCH_mn10300
181 case bfd_arch_mn10300:
182 disassemble = print_insn_mn10300;
183 break;
184 #endif
185 #ifdef ARCH_pj
186 case bfd_arch_pj:
187 disassemble = print_insn_pj;
188 break;
189 #endif
190 #ifdef ARCH_powerpc
191 case bfd_arch_powerpc:
192 if (bfd_big_endian (abfd))
193 disassemble = print_insn_big_powerpc;
194 else
195 disassemble = print_insn_little_powerpc;
196 break;
197 #endif
198 #ifdef ARCH_rs6000
199 case bfd_arch_rs6000:
200 disassemble = print_insn_rs6000;
201 break;
202 #endif
203 #ifdef ARCH_sh
204 case bfd_arch_sh:
205 if (bfd_big_endian (abfd))
206 disassemble = print_insn_sh;
207 else
208 disassemble = print_insn_shl;
209 break;
210 #endif
211 #ifdef ARCH_sparc
212 case bfd_arch_sparc:
213 disassemble = print_insn_sparc;
214 break;
215 #endif
216 #ifdef ARCH_tic30
217 case bfd_arch_tic30:
218 disassemble = print_insn_tic30;
219 break;
220 #endif
221 #ifdef ARCH_tic80
222 case bfd_arch_tic80:
223 disassemble = print_insn_tic80;
224 break;
225 #endif
226 #ifdef ARCH_v850
227 case bfd_arch_v850:
228 disassemble = print_insn_v850;
229 break;
230 #endif
231 #ifdef ARCH_w65
232 case bfd_arch_w65:
233 disassemble = print_insn_w65;
234 break;
235 #endif
236 #ifdef ARCH_z8k
237 case bfd_arch_z8k:
238 if (bfd_get_mach(abfd) == bfd_mach_z8001)
239 disassemble = print_insn_z8001;
240 else
241 disassemble = print_insn_z8002;
242 break;
243 #endif
244 #ifdef ARCH_vax
245 case bfd_arch_vax:
246 disassemble = print_insn_vax;
247 break;
248 #endif
249 default:
250 return 0;
252 return disassemble;
255 void
256 disassembler_usage (FILE * stream)
258 #ifdef ARCH_arm
259 print_arm_disassembler_options (stream);
260 #endif
262 return;