Initial revision
[binutils.git] / opcodes / disassemble.c
blob4898b42458d03ca9ab2092a32bfa5e97b6fff7e7
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_powerpc
43 #define ARCH_rs6000
44 #define ARCH_sh
45 #define ARCH_sparc
46 #define ARCH_tic30
47 #define ARCH_tic80
48 #define ARCH_v850
49 #define ARCH_vax
50 #define ARCH_w65
51 #define ARCH_z8k
52 #endif
55 disassembler_ftype
56 disassembler (abfd)
57 bfd *abfd;
59 enum bfd_architecture a = bfd_get_arch (abfd);
60 disassembler_ftype disassemble;
62 switch (a)
64 /* If you add a case to this table, also add it to the
65 ARCH_all definition right above this function. */
66 #ifdef ARCH_a29k
67 case bfd_arch_a29k:
68 /* As far as I know we only handle big-endian 29k objects. */
69 disassemble = print_insn_big_a29k;
70 break;
71 #endif
72 #ifdef ARCH_alpha
73 case bfd_arch_alpha:
74 disassemble = print_insn_alpha;
75 break;
76 #endif
77 #ifdef ARCH_arc
78 case bfd_arch_arc:
80 disassemble = arc_get_disassembler (bfd_get_mach (abfd),
81 bfd_big_endian (abfd));
82 break;
84 #endif
85 #ifdef ARCH_arm
86 case bfd_arch_arm:
87 if (bfd_big_endian (abfd))
88 disassemble = print_insn_big_arm;
89 else
90 disassemble = print_insn_little_arm;
91 break;
92 #endif
93 #ifdef ARCH_d10v
94 case bfd_arch_d10v:
95 disassemble = print_insn_d10v;
96 break;
97 #endif
98 #ifdef ARCH_d30v
99 case bfd_arch_d30v:
100 disassemble = print_insn_d30v;
101 break;
102 #endif
103 #ifdef ARCH_h8300
104 case bfd_arch_h8300:
105 if (bfd_get_mach(abfd) == bfd_mach_h8300h)
106 disassemble = print_insn_h8300h;
107 else if (bfd_get_mach(abfd) == bfd_mach_h8300s)
108 disassemble = print_insn_h8300s;
109 else
110 disassemble = print_insn_h8300;
111 break;
112 #endif
113 #ifdef ARCH_h8500
114 case bfd_arch_h8500:
115 disassemble = print_insn_h8500;
116 break;
117 #endif
118 #ifdef ARCH_hppa
119 case bfd_arch_hppa:
120 disassemble = print_insn_hppa;
121 break;
122 #endif
123 #ifdef ARCH_i386
124 case bfd_arch_i386:
125 if (bfd_get_mach (abfd) == bfd_mach_i386_i386_intel_syntax)
126 disassemble = print_insn_i386_intel;
127 else
128 disassemble = print_insn_i386_att;
129 break;
130 #endif
131 #ifdef ARCH_i960
132 case bfd_arch_i960:
133 disassemble = print_insn_i960;
134 break;
135 #endif
136 #ifdef ARCH_fr30
137 case bfd_arch_fr30:
138 disassemble = print_insn_fr30;
139 break;
140 #endif
141 #ifdef ARCH_m32r
142 case bfd_arch_m32r:
143 disassemble = print_insn_m32r;
144 break;
145 #endif
146 #ifdef ARCH_m68k
147 case bfd_arch_m68k:
148 disassemble = print_insn_m68k;
149 break;
150 #endif
151 #ifdef ARCH_m88k
152 case bfd_arch_m88k:
153 disassemble = print_insn_m88k;
154 break;
155 #endif
156 #ifdef ARCH_ns32k
157 case bfd_arch_ns32k:
158 disassemble = print_insn_ns32k;
159 break;
160 #endif
161 #ifdef ARCH_mcore
162 case bfd_arch_mcore:
163 disassemble = print_insn_mcore;
164 break;
165 #endif
166 #ifdef ARCH_mips
167 case bfd_arch_mips:
168 if (bfd_big_endian (abfd))
169 disassemble = print_insn_big_mips;
170 else
171 disassemble = print_insn_little_mips;
172 break;
173 #endif
174 #ifdef ARCH_mn10200
175 case bfd_arch_mn10200:
176 disassemble = print_insn_mn10200;
177 break;
178 #endif
179 #ifdef ARCH_mn10300
180 case bfd_arch_mn10300:
181 disassemble = print_insn_mn10300;
182 break;
183 #endif
184 #ifdef ARCH_powerpc
185 case bfd_arch_powerpc:
186 if (bfd_big_endian (abfd))
187 disassemble = print_insn_big_powerpc;
188 else
189 disassemble = print_insn_little_powerpc;
190 break;
191 #endif
192 #ifdef ARCH_rs6000
193 case bfd_arch_rs6000:
194 disassemble = print_insn_rs6000;
195 break;
196 #endif
197 #ifdef ARCH_sh
198 case bfd_arch_sh:
199 if (bfd_big_endian (abfd))
200 disassemble = print_insn_sh;
201 else
202 disassemble = print_insn_shl;
203 break;
204 #endif
205 #ifdef ARCH_sparc
206 case bfd_arch_sparc:
207 disassemble = print_insn_sparc;
208 break;
209 #endif
210 #ifdef ARCH_tic30
211 case bfd_arch_tic30:
212 disassemble = print_insn_tic30;
213 break;
214 #endif
215 #ifdef ARCH_tic80
216 case bfd_arch_tic80:
217 disassemble = print_insn_tic80;
218 break;
219 #endif
220 #ifdef ARCH_v850
221 case bfd_arch_v850:
222 disassemble = print_insn_v850;
223 break;
224 #endif
225 #ifdef ARCH_w65
226 case bfd_arch_w65:
227 disassemble = print_insn_w65;
228 break;
229 #endif
230 #ifdef ARCH_z8k
231 case bfd_arch_z8k:
232 if (bfd_get_mach(abfd) == bfd_mach_z8001)
233 disassemble = print_insn_z8001;
234 else
235 disassemble = print_insn_z8002;
236 break;
237 #endif
238 #ifdef ARCH_vax
239 case bfd_arch_vax:
240 disassemble = print_insn_vax;
241 break;
242 #endif
243 default:
244 return 0;
246 return disassemble;