Mon Jul 22 13:17:06 1996 Richard Henderson <rth@tamu.edu>
[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 #define ARCH_h8300
32 #define ARCH_h8500
33 #define ARCH_hppa
34 #define ARCH_i386
35 #define ARCH_i960
36 #define ARCH_m68k
37 #define ARCH_m88k
38 #define ARCH_mips
39 #define ARCH_ns32k
40 #define ARCH_powerpc
41 #define ARCH_rs6000
42 #define ARCH_sh
43 #define ARCH_sparc
44 #define ARCH_w65
45 #define ARCH_z8k
46 #endif
47
48 disassembler_ftype
49 disassembler (abfd)
50      bfd *abfd;
51 {
52   enum bfd_architecture a = bfd_get_arch (abfd);
53   disassembler_ftype disassemble;
54
55   switch (a)
56     {
57       /* If you add a case to this table, also add it to the
58          ARCH_all definition right above this function.  */
59 #ifdef ARCH_a29k
60     case bfd_arch_a29k:
61       /* As far as I know we only handle big-endian 29k objects.  */
62       disassemble = print_insn_big_a29k;
63       break;
64 #endif
65 #ifdef ARCH_alpha
66     case bfd_arch_alpha:
67       switch (bfd_get_flavour (abfd))
68         {
69         case bfd_target_ecoff_flavour:
70         case bfd_target_elf_flavour:
71         default:
72           disassemble = print_insn_alpha_osf;
73           break;
74         case bfd_target_evax_flavour:
75           disassemble = print_insn_alpha_vms;
76           break;
77         }
78       break;
79 #endif
80 /* start-sanitize-arc */
81 #ifdef ARCH_arc
82     case bfd_arch_arc:
83       {
84         disassemble = arc_get_disassembler (bfd_get_mach (abfd),
85                                             bfd_big_endian (abfd));
86         break;
87       }
88 #endif
89 /* end-sanitize-arc */
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 /* start-sanitize-d10v */
99 #ifdef ARCH_d10v
100     case bfd_arch_d10v:
101       disassemble = print_insn_d10v;
102       break;
103 #endif
104 /* end-sanitize-d10v */
105 #ifdef ARCH_h8300
106     case bfd_arch_h8300:
107       if (bfd_get_mach(abfd) == bfd_mach_h8300h)
108         disassemble = print_insn_h8300h;
109       else if (bfd_get_mach(abfd) == bfd_mach_h8300s)
110         disassemble = print_insn_h8300s;
111       else 
112         disassemble = print_insn_h8300;
113       break;
114 #endif
115 #ifdef ARCH_h8500
116     case bfd_arch_h8500:
117       disassemble = print_insn_h8500;
118       break;
119 #endif
120 #ifdef ARCH_hppa
121     case bfd_arch_hppa:
122       disassemble = print_insn_hppa;
123       break;
124 #endif
125 #ifdef ARCH_i386
126     case bfd_arch_i386:
127       disassemble = print_insn_i386;
128       break;
129 #endif
130 #ifdef ARCH_i960
131     case bfd_arch_i960:
132       disassemble = print_insn_i960;
133       break;
134 #endif
135 #ifdef ARCH_m68k
136     case bfd_arch_m68k:
137       disassemble = print_insn_m68k;
138       break;
139 #endif
140 #ifdef ARCH_m88k
141     case bfd_arch_m88k:
142       disassemble = print_insn_m88k;
143       break;
144 #endif
145 #ifdef ARCH_ns32k
146     case bfd_arch_ns32k:
147       disassemble = print_insn_ns32k;
148       break;
149 #endif
150 #ifdef ARCH_mips
151     case bfd_arch_mips:
152       if (bfd_big_endian (abfd))
153         disassemble = print_insn_big_mips;
154       else
155         disassemble = print_insn_little_mips;
156       break;
157 #endif
158 #ifdef ARCH_powerpc
159     case bfd_arch_powerpc:
160       if (bfd_big_endian (abfd))
161         disassemble = print_insn_big_powerpc;
162       else
163         disassemble = print_insn_little_powerpc;
164       break;
165 #endif
166 #ifdef ARCH_rs6000
167     case bfd_arch_rs6000:
168       disassemble = print_insn_rs6000;
169       break;
170 #endif
171 #ifdef ARCH_sh
172     case bfd_arch_sh:
173       if (bfd_big_endian (abfd))
174         disassemble = print_insn_sh;
175       else
176         disassemble = print_insn_shl;
177       break;
178 #endif
179 #ifdef ARCH_sparc
180     case bfd_arch_sparc:
181       disassemble = print_insn_sparc;
182       break;
183 #endif
184 #ifdef ARCH_w65
185     case bfd_arch_w65:
186       disassemble = print_insn_w65;
187       break;
188 #endif
189 #ifdef ARCH_z8k
190     case bfd_arch_z8k:
191       if (bfd_get_mach(abfd) == bfd_mach_z8001)
192         disassemble = print_insn_z8001;
193       else 
194         disassemble = print_insn_z8002;
195       break;
196 #endif
197     default:
198       return 0;
199     }
200   return disassemble;
201 }