Tue Feb 18 17:43:43 1997 Martin M. Hunt <hunt@pizza.cygnus.com>
[external/binutils.git] / opcodes / disassemble.c
1 /* Select disassembly routine for specified architecture.
2    Copyright (C) 1994, 1995 Free Software Foundation, Inc.
3
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.
8
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.
13
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.  */
17
18 #include "ansidecl.h"
19 #include "dis-asm.h"
20
21 #ifdef ARCH_all
22 #define ARCH_a29k
23 #define ARCH_alpha
24 /* start-sanitize-arc */
25 #define ARCH_arc
26 /* end-sanitize-arc */
27 #define ARCH_arm
28 /* start-sanitize-d10v */
29 #define ARCH_d10v
30 /* end-sanitize-d10v */
31 /* start-sanitize-d30v */
32 #define ARCH_d30v
33 /* end-sanitize-d30v */
34 #define ARCH_h8300
35 #define ARCH_h8500
36 #define ARCH_hppa
37 #define ARCH_i386
38 #define ARCH_i960
39 #define ARCH_m68k
40 #define ARCH_m88k
41 #define ARCH_mips
42 #define ARCH_mn10200
43 #define ARCH_mn10300
44 #define ARCH_ns32k
45 #define ARCH_powerpc
46 #define ARCH_rs6000
47 #define ARCH_sh
48 #define ARCH_sparc
49 /* start-sanitize-tic80 */
50 #define ARCH_tic80
51 /* end-sanitize-tic80 */
52 /* start-sanitize-v850 */
53 #define ARCH_v850
54 /* end-sanitize-v850 */
55 #define ARCH_w65
56 #define ARCH_z8k
57 #endif
58
59 disassembler_ftype
60 disassembler (abfd)
61      bfd *abfd;
62 {
63   enum bfd_architecture a = bfd_get_arch (abfd);
64   disassembler_ftype disassemble;
65
66   switch (a)
67     {
68       /* If you add a case to this table, also add it to the
69          ARCH_all definition right above this function.  */
70 #ifdef ARCH_a29k
71     case bfd_arch_a29k:
72       /* As far as I know we only handle big-endian 29k objects.  */
73       disassemble = print_insn_big_a29k;
74       break;
75 #endif
76 #ifdef ARCH_alpha
77     case bfd_arch_alpha:
78       disassemble = print_insn_alpha;
79       break;
80 #endif
81 /* start-sanitize-arc */
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 /* end-sanitize-arc */
91 #ifdef ARCH_arm
92     case bfd_arch_arm:
93       if (bfd_big_endian (abfd))
94         disassemble = print_insn_big_arm;
95       else
96         disassemble = print_insn_little_arm;
97       break;
98 #endif
99 /* start-sanitize-d10v */
100 #ifdef ARCH_d10v
101     case bfd_arch_d10v:
102       disassemble = print_insn_d10v;
103       break;
104 #endif
105 /* end-sanitize-d10v */
106 /* start-sanitize-d30v */
107 #ifdef ARCH_d30v
108     case bfd_arch_d30v:
109       disassemble = print_insn_d30v;
110       break;
111 #endif
112 /* end-sanitize-d30v */
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_i386
134     case bfd_arch_i386:
135       disassemble = print_insn_i386;
136       break;
137 #endif
138 #ifdef ARCH_i960
139     case bfd_arch_i960:
140       disassemble = print_insn_i960;
141       break;
142 #endif
143 #ifdef ARCH_m68k
144     case bfd_arch_m68k:
145       disassemble = print_insn_m68k;
146       break;
147 #endif
148 #ifdef ARCH_m88k
149     case bfd_arch_m88k:
150       disassemble = print_insn_m88k;
151       break;
152 #endif
153 #ifdef ARCH_ns32k
154     case bfd_arch_ns32k:
155       disassemble = print_insn_ns32k;
156       break;
157 #endif
158 #ifdef ARCH_mips
159     case bfd_arch_mips:
160       if (bfd_big_endian (abfd))
161         disassemble = print_insn_big_mips;
162       else
163         disassemble = print_insn_little_mips;
164       break;
165 #endif
166 #ifdef ARCH_mn10200
167     case bfd_arch_mn10200:
168       disassemble = print_insn_mn10200;
169       break;
170 #endif
171 #ifdef ARCH_mn10300
172     case bfd_arch_mn10300:
173       disassemble = print_insn_mn10300;
174       break;
175 #endif
176 #ifdef ARCH_powerpc
177     case bfd_arch_powerpc:
178       if (bfd_big_endian (abfd))
179         disassemble = print_insn_big_powerpc;
180       else
181         disassemble = print_insn_little_powerpc;
182       break;
183 #endif
184 #ifdef ARCH_rs6000
185     case bfd_arch_rs6000:
186       disassemble = print_insn_rs6000;
187       break;
188 #endif
189 #ifdef ARCH_sh
190     case bfd_arch_sh:
191       if (bfd_big_endian (abfd))
192         disassemble = print_insn_sh;
193       else
194         disassemble = print_insn_shl;
195       break;
196 #endif
197 #ifdef ARCH_sparc
198     case bfd_arch_sparc:
199       disassemble = print_insn_sparc;
200       break;
201 #endif
202 /* start-sanitize-tic80 */
203 #ifdef ARCH_tic80
204     case bfd_arch_tic80:
205       disassemble = print_insn_tic80;
206       break;
207 #endif
208 /* end-sanitize-tic80 */
209 /* start-sanitize-v850 */
210 #ifdef ARCH_v850
211     case bfd_arch_v850:
212       disassemble = print_insn_v850;
213       break;
214 #endif
215 /* end-sanitize-v850 */
216 #ifdef ARCH_w65
217     case bfd_arch_w65:
218       disassemble = print_insn_w65;
219       break;
220 #endif
221 #ifdef ARCH_z8k
222     case bfd_arch_z8k:
223       if (bfd_get_mach(abfd) == bfd_mach_z8001)
224         disassemble = print_insn_z8001;
225       else 
226         disassemble = print_insn_z8002;
227       break;
228 #endif
229     default:
230       return 0;
231     }
232   return disassemble;
233 }