| 1 | /* Select disassembly routine for specified architecture. |
| 2 | Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 |
| 3 | Free Software Foundation, Inc. |
| 4 | |
| 5 | This program is free software; you can redistribute it and/or modify |
| 6 | it under the terms of the GNU General Public License as published by |
| 7 | the Free Software Foundation; either version 2 of the License, or |
| 8 | (at your option) any later version. |
| 9 | |
| 10 | This program is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | GNU General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU General Public License |
| 16 | along with this program; if not, write to the Free Software |
| 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
| 18 | |
| 19 | #include "sysdep.h" |
| 20 | #include "dis-asm.h" |
| 21 | |
| 22 | #ifdef ARCH_all |
| 23 | #define ARCH_a29k |
| 24 | #define ARCH_alpha |
| 25 | #define ARCH_arc |
| 26 | #define ARCH_arm |
| 27 | #define ARCH_avr |
| 28 | #define ARCH_cris |
| 29 | #define ARCH_d10v |
| 30 | #define ARCH_d30v |
| 31 | #define ARCH_h8300 |
| 32 | #define ARCH_h8500 |
| 33 | #define ARCH_hppa |
| 34 | #define ARCH_i370 |
| 35 | #define ARCH_i386 |
| 36 | #define ARCH_i860 |
| 37 | #define ARCH_i960 |
| 38 | #define ARCH_ia64 |
| 39 | #define ARCH_fr30 |
| 40 | #define ARCH_m32r |
| 41 | #define ARCH_m68k |
| 42 | #define ARCH_m68hc11 |
| 43 | #define ARCH_m68hc12 |
| 44 | #define ARCH_m88k |
| 45 | #define ARCH_mcore |
| 46 | #define ARCH_mips |
| 47 | #define ARCH_mn10200 |
| 48 | #define ARCH_mn10300 |
| 49 | #define ARCH_ns32k |
| 50 | #define ARCH_openrisc |
| 51 | #define ARCH_pdp11 |
| 52 | #define ARCH_pj |
| 53 | #define ARCH_powerpc |
| 54 | #define ARCH_rs6000 |
| 55 | #define ARCH_s390 |
| 56 | #define ARCH_sh |
| 57 | #define ARCH_sparc |
| 58 | #define ARCH_tic30 |
| 59 | #define ARCH_tic54x |
| 60 | #define ARCH_tic80 |
| 61 | #define ARCH_v850 |
| 62 | #define ARCH_vax |
| 63 | #define ARCH_w65 |
| 64 | #define ARCH_z8k |
| 65 | #endif |
| 66 | |
| 67 | |
| 68 | disassembler_ftype |
| 69 | disassembler (abfd) |
| 70 | bfd *abfd; |
| 71 | { |
| 72 | enum bfd_architecture a = bfd_get_arch (abfd); |
| 73 | disassembler_ftype disassemble; |
| 74 | |
| 75 | switch (a) |
| 76 | { |
| 77 | /* If you add a case to this table, also add it to the |
| 78 | ARCH_all definition right above this function. */ |
| 79 | #ifdef ARCH_a29k |
| 80 | case bfd_arch_a29k: |
| 81 | /* As far as I know we only handle big-endian 29k objects. */ |
| 82 | disassemble = print_insn_big_a29k; |
| 83 | break; |
| 84 | #endif |
| 85 | #ifdef ARCH_alpha |
| 86 | case bfd_arch_alpha: |
| 87 | disassemble = print_insn_alpha; |
| 88 | break; |
| 89 | #endif |
| 90 | #ifdef ARCH_arc |
| 91 | case bfd_arch_arc: |
| 92 | { |
| 93 | disassemble = arc_get_disassembler (abfd); |
| 94 | break; |
| 95 | } |
| 96 | #endif |
| 97 | #ifdef ARCH_arm |
| 98 | case bfd_arch_arm: |
| 99 | if (bfd_big_endian (abfd)) |
| 100 | disassemble = print_insn_big_arm; |
| 101 | else |
| 102 | disassemble = print_insn_little_arm; |
| 103 | break; |
| 104 | #endif |
| 105 | #ifdef ARCH_avr |
| 106 | case bfd_arch_avr: |
| 107 | disassemble = print_insn_avr; |
| 108 | break; |
| 109 | #endif |
| 110 | #ifdef ARCH_cris |
| 111 | case bfd_arch_cris: |
| 112 | disassemble = cris_get_disassembler (abfd); |
| 113 | break; |
| 114 | #endif |
| 115 | #ifdef ARCH_d10v |
| 116 | case bfd_arch_d10v: |
| 117 | disassemble = print_insn_d10v; |
| 118 | break; |
| 119 | #endif |
| 120 | #ifdef ARCH_d30v |
| 121 | case bfd_arch_d30v: |
| 122 | disassemble = print_insn_d30v; |
| 123 | break; |
| 124 | #endif |
| 125 | #ifdef ARCH_h8300 |
| 126 | case bfd_arch_h8300: |
| 127 | if (bfd_get_mach(abfd) == bfd_mach_h8300h) |
| 128 | disassemble = print_insn_h8300h; |
| 129 | else if (bfd_get_mach(abfd) == bfd_mach_h8300s) |
| 130 | disassemble = print_insn_h8300s; |
| 131 | else |
| 132 | disassemble = print_insn_h8300; |
| 133 | break; |
| 134 | #endif |
| 135 | #ifdef ARCH_h8500 |
| 136 | case bfd_arch_h8500: |
| 137 | disassemble = print_insn_h8500; |
| 138 | break; |
| 139 | #endif |
| 140 | #ifdef ARCH_hppa |
| 141 | case bfd_arch_hppa: |
| 142 | disassemble = print_insn_hppa; |
| 143 | break; |
| 144 | #endif |
| 145 | #ifdef ARCH_i370 |
| 146 | case bfd_arch_i370: |
| 147 | disassemble = print_insn_i370; |
| 148 | break; |
| 149 | #endif |
| 150 | #ifdef ARCH_i386 |
| 151 | case bfd_arch_i386: |
| 152 | if (bfd_get_mach (abfd) == bfd_mach_i386_i386_intel_syntax |
| 153 | || bfd_get_mach (abfd) == bfd_mach_x86_64_intel_syntax) |
| 154 | disassemble = print_insn_i386_intel; |
| 155 | else |
| 156 | disassemble = print_insn_i386_att; |
| 157 | break; |
| 158 | #endif |
| 159 | #ifdef ARCH_i860 |
| 160 | case bfd_arch_i860: |
| 161 | disassemble = print_insn_i860; |
| 162 | break; |
| 163 | #endif |
| 164 | #ifdef ARCH_i960 |
| 165 | case bfd_arch_i960: |
| 166 | disassemble = print_insn_i960; |
| 167 | break; |
| 168 | #endif |
| 169 | #ifdef ARCH_ia64 |
| 170 | case bfd_arch_ia64: |
| 171 | disassemble = print_insn_ia64; |
| 172 | break; |
| 173 | #endif |
| 174 | #ifdef ARCH_fr30 |
| 175 | case bfd_arch_fr30: |
| 176 | disassemble = print_insn_fr30; |
| 177 | break; |
| 178 | #endif |
| 179 | #ifdef ARCH_m32r |
| 180 | case bfd_arch_m32r: |
| 181 | disassemble = print_insn_m32r; |
| 182 | break; |
| 183 | #endif |
| 184 | #if defined(ARCH_m68hc11) || defined(ARCH_m68hc12) |
| 185 | case bfd_arch_m68hc11: |
| 186 | disassemble = print_insn_m68hc11; |
| 187 | break; |
| 188 | case bfd_arch_m68hc12: |
| 189 | disassemble = print_insn_m68hc12; |
| 190 | break; |
| 191 | #endif |
| 192 | #ifdef ARCH_m68k |
| 193 | case bfd_arch_m68k: |
| 194 | disassemble = print_insn_m68k; |
| 195 | break; |
| 196 | #endif |
| 197 | #ifdef ARCH_m88k |
| 198 | case bfd_arch_m88k: |
| 199 | disassemble = print_insn_m88k; |
| 200 | break; |
| 201 | #endif |
| 202 | #ifdef ARCH_ns32k |
| 203 | case bfd_arch_ns32k: |
| 204 | disassemble = print_insn_ns32k; |
| 205 | break; |
| 206 | #endif |
| 207 | #ifdef ARCH_mcore |
| 208 | case bfd_arch_mcore: |
| 209 | disassemble = print_insn_mcore; |
| 210 | break; |
| 211 | #endif |
| 212 | #ifdef ARCH_mips |
| 213 | case bfd_arch_mips: |
| 214 | if (bfd_big_endian (abfd)) |
| 215 | disassemble = print_insn_big_mips; |
| 216 | else |
| 217 | disassemble = print_insn_little_mips; |
| 218 | break; |
| 219 | #endif |
| 220 | #ifdef ARCH_mn10200 |
| 221 | case bfd_arch_mn10200: |
| 222 | disassemble = print_insn_mn10200; |
| 223 | break; |
| 224 | #endif |
| 225 | #ifdef ARCH_mn10300 |
| 226 | case bfd_arch_mn10300: |
| 227 | disassemble = print_insn_mn10300; |
| 228 | break; |
| 229 | #endif |
| 230 | #ifdef ARCH_openrisc |
| 231 | case bfd_arch_openrisc: |
| 232 | disassemble = print_insn_openrisc; |
| 233 | break; |
| 234 | #endif |
| 235 | #ifdef ARCH_pdp11 |
| 236 | case bfd_arch_pdp11: |
| 237 | disassemble = print_insn_pdp11; |
| 238 | break; |
| 239 | #endif |
| 240 | #ifdef ARCH_pj |
| 241 | case bfd_arch_pj: |
| 242 | disassemble = print_insn_pj; |
| 243 | break; |
| 244 | #endif |
| 245 | #ifdef ARCH_powerpc |
| 246 | case bfd_arch_powerpc: |
| 247 | if (bfd_big_endian (abfd)) |
| 248 | disassemble = print_insn_big_powerpc; |
| 249 | else |
| 250 | disassemble = print_insn_little_powerpc; |
| 251 | break; |
| 252 | #endif |
| 253 | #ifdef ARCH_rs6000 |
| 254 | case bfd_arch_rs6000: |
| 255 | if (bfd_get_mach (abfd) == bfd_mach_ppc_620) |
| 256 | disassemble = print_insn_big_powerpc; |
| 257 | else |
| 258 | disassemble = print_insn_rs6000; |
| 259 | break; |
| 260 | #endif |
| 261 | #ifdef ARCH_s390 |
| 262 | case bfd_arch_s390: |
| 263 | disassemble = print_insn_s390; |
| 264 | break; |
| 265 | #endif |
| 266 | #ifdef ARCH_sh |
| 267 | case bfd_arch_sh: |
| 268 | if (bfd_big_endian (abfd)) |
| 269 | disassemble = print_insn_sh; |
| 270 | else |
| 271 | disassemble = print_insn_shl; |
| 272 | break; |
| 273 | #endif |
| 274 | #ifdef ARCH_sparc |
| 275 | case bfd_arch_sparc: |
| 276 | disassemble = print_insn_sparc; |
| 277 | break; |
| 278 | #endif |
| 279 | #ifdef ARCH_tic30 |
| 280 | case bfd_arch_tic30: |
| 281 | disassemble = print_insn_tic30; |
| 282 | break; |
| 283 | #endif |
| 284 | #ifdef ARCH_tic54x |
| 285 | case bfd_arch_tic54x: |
| 286 | disassemble = print_insn_tic54x; |
| 287 | break; |
| 288 | #endif |
| 289 | #ifdef ARCH_tic80 |
| 290 | case bfd_arch_tic80: |
| 291 | disassemble = print_insn_tic80; |
| 292 | break; |
| 293 | #endif |
| 294 | #ifdef ARCH_v850 |
| 295 | case bfd_arch_v850: |
| 296 | disassemble = print_insn_v850; |
| 297 | break; |
| 298 | #endif |
| 299 | #ifdef ARCH_w65 |
| 300 | case bfd_arch_w65: |
| 301 | disassemble = print_insn_w65; |
| 302 | break; |
| 303 | #endif |
| 304 | #ifdef ARCH_z8k |
| 305 | case bfd_arch_z8k: |
| 306 | if (bfd_get_mach(abfd) == bfd_mach_z8001) |
| 307 | disassemble = print_insn_z8001; |
| 308 | else |
| 309 | disassemble = print_insn_z8002; |
| 310 | break; |
| 311 | #endif |
| 312 | #ifdef ARCH_vax |
| 313 | case bfd_arch_vax: |
| 314 | disassemble = print_insn_vax; |
| 315 | break; |
| 316 | #endif |
| 317 | default: |
| 318 | return 0; |
| 319 | } |
| 320 | return disassemble; |
| 321 | } |
| 322 | |
| 323 | void |
| 324 | disassembler_usage (stream) |
| 325 | FILE * stream ATTRIBUTE_UNUSED; |
| 326 | { |
| 327 | #ifdef ARCH_arm |
| 328 | print_arm_disassembler_options (stream); |
| 329 | #endif |
| 330 | |
| 331 | return; |
| 332 | } |