]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/binutils/opcodes/disassemble.c
Initial import of GNU binutils version 2.8.1. Believe it or not,
[FreeBSD/FreeBSD.git] / contrib / binutils / opcodes / disassemble.c
1 /* Select disassembly routine for specified architecture.
2    Copyright (C) 1994, 1995, 1996, 1997 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 #define ARCH_arm
25 #define ARCH_d10v
26 #define ARCH_h8300
27 #define ARCH_h8500
28 #define ARCH_hppa
29 #define ARCH_i386
30 #define ARCH_i960
31 #define ARCH_m32r
32 #define ARCH_m68k
33 #define ARCH_m88k
34 #define ARCH_mips
35 #define ARCH_mn10200
36 #define ARCH_mn10300
37 #define ARCH_ns32k
38 #define ARCH_powerpc
39 #define ARCH_rs6000
40 #define ARCH_sh
41 #define ARCH_sparc
42 #define ARCH_w65
43 #define ARCH_z8k
44 #endif
45
46 disassembler_ftype
47 disassembler (abfd)
48      bfd *abfd;
49 {
50   enum bfd_architecture a = bfd_get_arch (abfd);
51   disassembler_ftype disassemble;
52
53   switch (a)
54     {
55       /* If you add a case to this table, also add it to the
56          ARCH_all definition right above this function.  */
57 #ifdef ARCH_a29k
58     case bfd_arch_a29k:
59       /* As far as I know we only handle big-endian 29k objects.  */
60       disassemble = print_insn_big_a29k;
61       break;
62 #endif
63 #ifdef ARCH_alpha
64     case bfd_arch_alpha:
65       disassemble = print_insn_alpha;
66       break;
67 #endif
68 #ifdef ARCH_arm
69     case bfd_arch_arm:
70       if (bfd_big_endian (abfd))
71         disassemble = print_insn_big_arm;
72       else
73         disassemble = print_insn_little_arm;
74       break;
75 #endif
76 #ifdef ARCH_d10v
77     case bfd_arch_d10v:
78       disassemble = print_insn_d10v;
79       break;
80 #endif
81 #ifdef ARCH_h8300
82     case bfd_arch_h8300:
83       if (bfd_get_mach(abfd) == bfd_mach_h8300h)
84         disassemble = print_insn_h8300h;
85       else if (bfd_get_mach(abfd) == bfd_mach_h8300s)
86         disassemble = print_insn_h8300s;
87       else 
88         disassemble = print_insn_h8300;
89       break;
90 #endif
91 #ifdef ARCH_h8500
92     case bfd_arch_h8500:
93       disassemble = print_insn_h8500;
94       break;
95 #endif
96 #ifdef ARCH_hppa
97     case bfd_arch_hppa:
98       disassemble = print_insn_hppa;
99       break;
100 #endif
101 #ifdef ARCH_i386
102     case bfd_arch_i386:
103       disassemble = print_insn_i386;
104       break;
105 #endif
106 #ifdef ARCH_i960
107     case bfd_arch_i960:
108       disassemble = print_insn_i960;
109       break;
110 #endif
111 #ifdef ARCH_m32r
112     case bfd_arch_m32r:
113       disassemble = print_insn_m32r;
114       break;
115 #endif
116 #ifdef ARCH_m68k
117     case bfd_arch_m68k:
118       disassemble = print_insn_m68k;
119       break;
120 #endif
121 #ifdef ARCH_m88k
122     case bfd_arch_m88k:
123       disassemble = print_insn_m88k;
124       break;
125 #endif
126 #ifdef ARCH_ns32k
127     case bfd_arch_ns32k:
128       disassemble = print_insn_ns32k;
129       break;
130 #endif
131 #ifdef ARCH_mips
132     case bfd_arch_mips:
133       if (bfd_big_endian (abfd))
134         disassemble = print_insn_big_mips;
135       else
136         disassemble = print_insn_little_mips;
137       break;
138 #endif
139 #ifdef ARCH_mn10200
140     case bfd_arch_mn10200:
141       disassemble = print_insn_mn10200;
142       break;
143 #endif
144 #ifdef ARCH_mn10300
145     case bfd_arch_mn10300:
146       disassemble = print_insn_mn10300;
147       break;
148 #endif
149 #ifdef ARCH_powerpc
150     case bfd_arch_powerpc:
151       if (bfd_big_endian (abfd))
152         disassemble = print_insn_big_powerpc;
153       else
154         disassemble = print_insn_little_powerpc;
155       break;
156 #endif
157 #ifdef ARCH_rs6000
158     case bfd_arch_rs6000:
159       disassemble = print_insn_rs6000;
160       break;
161 #endif
162 #ifdef ARCH_sh
163     case bfd_arch_sh:
164       if (bfd_big_endian (abfd))
165         disassemble = print_insn_sh;
166       else
167         disassemble = print_insn_shl;
168       break;
169 #endif
170 #ifdef ARCH_sparc
171     case bfd_arch_sparc:
172       disassemble = print_insn_sparc;
173       break;
174 #endif
175 #ifdef ARCH_w65
176     case bfd_arch_w65:
177       disassemble = print_insn_w65;
178       break;
179 #endif
180 #ifdef ARCH_z8k
181     case bfd_arch_z8k:
182       if (bfd_get_mach(abfd) == bfd_mach_z8001)
183         disassemble = print_insn_z8001;
184       else 
185         disassemble = print_insn_z8002;
186       break;
187 #endif
188     default:
189       return 0;
190     }
191   return disassemble;
192 }