| 1 | /* Select disassembly routine for specified architecture. | 
|---|
| 2 | Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 | 
|---|
| 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_dlx | 
|---|
| 32 | #define ARCH_h8300 | 
|---|
| 33 | #define ARCH_h8500 | 
|---|
| 34 | #define ARCH_hppa | 
|---|
| 35 | #define ARCH_i370 | 
|---|
| 36 | #define ARCH_i386 | 
|---|
| 37 | #define ARCH_i860 | 
|---|
| 38 | #define ARCH_i960 | 
|---|
| 39 | #define ARCH_ip2k | 
|---|
| 40 | #define ARCH_ia64 | 
|---|
| 41 | #define ARCH_fr30 | 
|---|
| 42 | #define ARCH_m32r | 
|---|
| 43 | #define ARCH_m68k | 
|---|
| 44 | #define ARCH_m68hc11 | 
|---|
| 45 | #define ARCH_m68hc12 | 
|---|
| 46 | #define ARCH_m88k | 
|---|
| 47 | #define ARCH_mcore | 
|---|
| 48 | #define ARCH_mips | 
|---|
| 49 | #define ARCH_mmix | 
|---|
| 50 | #define ARCH_mn10200 | 
|---|
| 51 | #define ARCH_mn10300 | 
|---|
| 52 | #define ARCH_msp430 | 
|---|
| 53 | #define ARCH_ns32k | 
|---|
| 54 | #define ARCH_openrisc | 
|---|
| 55 | #define ARCH_or32 | 
|---|
| 56 | #define ARCH_pdp11 | 
|---|
| 57 | #define ARCH_pj | 
|---|
| 58 | #define ARCH_powerpc | 
|---|
| 59 | #define ARCH_rs6000 | 
|---|
| 60 | #define ARCH_s390 | 
|---|
| 61 | #define ARCH_sh | 
|---|
| 62 | #define ARCH_sparc | 
|---|
| 63 | #define ARCH_tic30 | 
|---|
| 64 | #define ARCH_tic4x | 
|---|
| 65 | #define ARCH_tic54x | 
|---|
| 66 | #define ARCH_tic80 | 
|---|
| 67 | #define ARCH_v850 | 
|---|
| 68 | #define ARCH_vax | 
|---|
| 69 | #define ARCH_w65 | 
|---|
| 70 | #define ARCH_xstormy16 | 
|---|
| 71 | #define ARCH_xtensa | 
|---|
| 72 | #define ARCH_z8k | 
|---|
| 73 | #define ARCH_frv | 
|---|
| 74 | #define ARCH_iq2000 | 
|---|
| 75 | #define INCLUDE_SHMEDIA | 
|---|
| 76 | #endif | 
|---|
| 77 |  | 
|---|
| 78 |  | 
|---|
| 79 | disassembler_ftype | 
|---|
| 80 | disassembler (abfd) | 
|---|
| 81 | bfd *abfd; | 
|---|
| 82 | { | 
|---|
| 83 | enum bfd_architecture a = bfd_get_arch (abfd); | 
|---|
| 84 | disassembler_ftype disassemble; | 
|---|
| 85 |  | 
|---|
| 86 | switch (a) | 
|---|
| 87 | { | 
|---|
| 88 | /* If you add a case to this table, also add it to the | 
|---|
| 89 | ARCH_all definition right above this function.  */ | 
|---|
| 90 | #ifdef ARCH_a29k | 
|---|
| 91 | case bfd_arch_a29k: | 
|---|
| 92 | /* As far as I know we only handle big-endian 29k objects.  */ | 
|---|
| 93 | disassemble = print_insn_big_a29k; | 
|---|
| 94 | break; | 
|---|
| 95 | #endif | 
|---|
| 96 | #ifdef ARCH_alpha | 
|---|
| 97 | case bfd_arch_alpha: | 
|---|
| 98 | disassemble = print_insn_alpha; | 
|---|
| 99 | break; | 
|---|
| 100 | #endif | 
|---|
| 101 | #ifdef ARCH_arc | 
|---|
| 102 | case bfd_arch_arc: | 
|---|
| 103 | { | 
|---|
| 104 | disassemble = arc_get_disassembler (abfd); | 
|---|
| 105 | break; | 
|---|
| 106 | } | 
|---|
| 107 | #endif | 
|---|
| 108 | #ifdef ARCH_arm | 
|---|
| 109 | case bfd_arch_arm: | 
|---|
| 110 | if (bfd_big_endian (abfd)) | 
|---|
| 111 | disassemble = print_insn_big_arm; | 
|---|
| 112 | else | 
|---|
| 113 | disassemble = print_insn_little_arm; | 
|---|
| 114 | break; | 
|---|
| 115 | #endif | 
|---|
| 116 | #ifdef ARCH_avr | 
|---|
| 117 | case bfd_arch_avr: | 
|---|
| 118 | disassemble = print_insn_avr; | 
|---|
| 119 | break; | 
|---|
| 120 | #endif | 
|---|
| 121 | #ifdef ARCH_cris | 
|---|
| 122 | case bfd_arch_cris: | 
|---|
| 123 | disassemble = cris_get_disassembler (abfd); | 
|---|
| 124 | break; | 
|---|
| 125 | #endif | 
|---|
| 126 | #ifdef ARCH_d10v | 
|---|
| 127 | case bfd_arch_d10v: | 
|---|
| 128 | disassemble = print_insn_d10v; | 
|---|
| 129 | break; | 
|---|
| 130 | #endif | 
|---|
| 131 | #ifdef ARCH_d30v | 
|---|
| 132 | case bfd_arch_d30v: | 
|---|
| 133 | disassemble = print_insn_d30v; | 
|---|
| 134 | break; | 
|---|
| 135 | #endif | 
|---|
| 136 | #ifdef ARCH_dlx | 
|---|
| 137 | case bfd_arch_dlx: | 
|---|
| 138 | /* As far as I know we only handle big-endian DLX objects.  */ | 
|---|
| 139 | disassemble = print_insn_dlx; | 
|---|
| 140 | break; | 
|---|
| 141 | #endif | 
|---|
| 142 | #ifdef ARCH_h8300 | 
|---|
| 143 | case bfd_arch_h8300: | 
|---|
| 144 | if (bfd_get_mach(abfd) == bfd_mach_h8300h) | 
|---|
| 145 | disassemble = print_insn_h8300h; | 
|---|
| 146 | else if (bfd_get_mach(abfd) == bfd_mach_h8300s) | 
|---|
| 147 | disassemble = print_insn_h8300s; | 
|---|
| 148 | else | 
|---|
| 149 | disassemble = print_insn_h8300; | 
|---|
| 150 | break; | 
|---|
| 151 | #endif | 
|---|
| 152 | #ifdef ARCH_h8500 | 
|---|
| 153 | case bfd_arch_h8500: | 
|---|
| 154 | disassemble = print_insn_h8500; | 
|---|
| 155 | break; | 
|---|
| 156 | #endif | 
|---|
| 157 | #ifdef ARCH_hppa | 
|---|
| 158 | case bfd_arch_hppa: | 
|---|
| 159 | disassemble = print_insn_hppa; | 
|---|
| 160 | break; | 
|---|
| 161 | #endif | 
|---|
| 162 | #ifdef ARCH_i370 | 
|---|
| 163 | case bfd_arch_i370: | 
|---|
| 164 | disassemble = print_insn_i370; | 
|---|
| 165 | break; | 
|---|
| 166 | #endif | 
|---|
| 167 | #ifdef ARCH_i386 | 
|---|
| 168 | case bfd_arch_i386: | 
|---|
| 169 | disassemble = print_insn_i386; | 
|---|
| 170 | break; | 
|---|
| 171 | #endif | 
|---|
| 172 | #ifdef ARCH_i860 | 
|---|
| 173 | case bfd_arch_i860: | 
|---|
| 174 | disassemble = print_insn_i860; | 
|---|
| 175 | break; | 
|---|
| 176 | #endif | 
|---|
| 177 | #ifdef ARCH_i960 | 
|---|
| 178 | case bfd_arch_i960: | 
|---|
| 179 | disassemble = print_insn_i960; | 
|---|
| 180 | break; | 
|---|
| 181 | #endif | 
|---|
| 182 | #ifdef ARCH_ia64 | 
|---|
| 183 | case bfd_arch_ia64: | 
|---|
| 184 | disassemble = print_insn_ia64; | 
|---|
| 185 | break; | 
|---|
| 186 | #endif | 
|---|
| 187 | #ifdef ARCH_ip2k | 
|---|
| 188 | case bfd_arch_ip2k: | 
|---|
| 189 | disassemble = print_insn_ip2k; | 
|---|
| 190 | break; | 
|---|
| 191 | #endif | 
|---|
| 192 | #ifdef ARCH_fr30 | 
|---|
| 193 | case bfd_arch_fr30: | 
|---|
| 194 | disassemble = print_insn_fr30; | 
|---|
| 195 | break; | 
|---|
| 196 | #endif | 
|---|
| 197 | #ifdef ARCH_m32r | 
|---|
| 198 | case bfd_arch_m32r: | 
|---|
| 199 | disassemble = print_insn_m32r; | 
|---|
| 200 | break; | 
|---|
| 201 | #endif | 
|---|
| 202 | #if defined(ARCH_m68hc11) || defined(ARCH_m68hc12) | 
|---|
| 203 | case bfd_arch_m68hc11: | 
|---|
| 204 | disassemble = print_insn_m68hc11; | 
|---|
| 205 | break; | 
|---|
| 206 | case bfd_arch_m68hc12: | 
|---|
| 207 | disassemble = print_insn_m68hc12; | 
|---|
| 208 | break; | 
|---|
| 209 | #endif | 
|---|
| 210 | #ifdef ARCH_m68k | 
|---|
| 211 | case bfd_arch_m68k: | 
|---|
| 212 | disassemble = print_insn_m68k; | 
|---|
| 213 | break; | 
|---|
| 214 | #endif | 
|---|
| 215 | #ifdef ARCH_m88k | 
|---|
| 216 | case bfd_arch_m88k: | 
|---|
| 217 | disassemble = print_insn_m88k; | 
|---|
| 218 | break; | 
|---|
| 219 | #endif | 
|---|
| 220 | #ifdef ARCH_msp430 | 
|---|
| 221 | case bfd_arch_msp430: | 
|---|
| 222 | disassemble = print_insn_msp430; | 
|---|
| 223 | break; | 
|---|
| 224 | #endif | 
|---|
| 225 | #ifdef ARCH_ns32k | 
|---|
| 226 | case bfd_arch_ns32k: | 
|---|
| 227 | disassemble = print_insn_ns32k; | 
|---|
| 228 | break; | 
|---|
| 229 | #endif | 
|---|
| 230 | #ifdef ARCH_mcore | 
|---|
| 231 | case bfd_arch_mcore: | 
|---|
| 232 | disassemble = print_insn_mcore; | 
|---|
| 233 | break; | 
|---|
| 234 | #endif | 
|---|
| 235 | #ifdef ARCH_mips | 
|---|
| 236 | case bfd_arch_mips: | 
|---|
| 237 | if (bfd_big_endian (abfd)) | 
|---|
| 238 | disassemble = print_insn_big_mips; | 
|---|
| 239 | else | 
|---|
| 240 | disassemble = print_insn_little_mips; | 
|---|
| 241 | break; | 
|---|
| 242 | #endif | 
|---|
| 243 | #ifdef ARCH_mmix | 
|---|
| 244 | case bfd_arch_mmix: | 
|---|
| 245 | disassemble = print_insn_mmix; | 
|---|
| 246 | break; | 
|---|
| 247 | #endif | 
|---|
| 248 | #ifdef ARCH_mn10200 | 
|---|
| 249 | case bfd_arch_mn10200: | 
|---|
| 250 | disassemble = print_insn_mn10200; | 
|---|
| 251 | break; | 
|---|
| 252 | #endif | 
|---|
| 253 | #ifdef ARCH_mn10300 | 
|---|
| 254 | case bfd_arch_mn10300: | 
|---|
| 255 | disassemble = print_insn_mn10300; | 
|---|
| 256 | break; | 
|---|
| 257 | #endif | 
|---|
| 258 | #ifdef ARCH_openrisc | 
|---|
| 259 | case bfd_arch_openrisc: | 
|---|
| 260 | disassemble = print_insn_openrisc; | 
|---|
| 261 | break; | 
|---|
| 262 | #endif | 
|---|
| 263 | #ifdef ARCH_or32 | 
|---|
| 264 | case bfd_arch_or32: | 
|---|
| 265 | if (bfd_big_endian (abfd)) | 
|---|
| 266 | disassemble = print_insn_big_or32; | 
|---|
| 267 | else | 
|---|
| 268 | disassemble = print_insn_little_or32; | 
|---|
| 269 | break; | 
|---|
| 270 | #endif | 
|---|
| 271 | #ifdef ARCH_pdp11 | 
|---|
| 272 | case bfd_arch_pdp11: | 
|---|
| 273 | disassemble = print_insn_pdp11; | 
|---|
| 274 | break; | 
|---|
| 275 | #endif | 
|---|
| 276 | #ifdef ARCH_pj | 
|---|
| 277 | case bfd_arch_pj: | 
|---|
| 278 | disassemble = print_insn_pj; | 
|---|
| 279 | break; | 
|---|
| 280 | #endif | 
|---|
| 281 | #ifdef ARCH_powerpc | 
|---|
| 282 | case bfd_arch_powerpc: | 
|---|
| 283 | if (bfd_big_endian (abfd)) | 
|---|
| 284 | disassemble = print_insn_big_powerpc; | 
|---|
| 285 | else | 
|---|
| 286 | disassemble = print_insn_little_powerpc; | 
|---|
| 287 | break; | 
|---|
| 288 | #endif | 
|---|
| 289 | #ifdef ARCH_rs6000 | 
|---|
| 290 | case bfd_arch_rs6000: | 
|---|
| 291 | if (bfd_get_mach (abfd) == bfd_mach_ppc_620) | 
|---|
| 292 | disassemble = print_insn_big_powerpc; | 
|---|
| 293 | else | 
|---|
| 294 | disassemble = print_insn_rs6000; | 
|---|
| 295 | break; | 
|---|
| 296 | #endif | 
|---|
| 297 | #ifdef ARCH_s390 | 
|---|
| 298 | case bfd_arch_s390: | 
|---|
| 299 | disassemble = print_insn_s390; | 
|---|
| 300 | break; | 
|---|
| 301 | #endif | 
|---|
| 302 | #ifdef ARCH_sh | 
|---|
| 303 | case bfd_arch_sh: | 
|---|
| 304 | disassemble = print_insn_sh; | 
|---|
| 305 | break; | 
|---|
| 306 | #endif | 
|---|
| 307 | #ifdef ARCH_sparc | 
|---|
| 308 | case bfd_arch_sparc: | 
|---|
| 309 | disassemble = print_insn_sparc; | 
|---|
| 310 | break; | 
|---|
| 311 | #endif | 
|---|
| 312 | #ifdef ARCH_tic30 | 
|---|
| 313 | case bfd_arch_tic30: | 
|---|
| 314 | disassemble = print_insn_tic30; | 
|---|
| 315 | break; | 
|---|
| 316 | #endif | 
|---|
| 317 | #ifdef ARCH_tic4x | 
|---|
| 318 | case bfd_arch_tic4x: | 
|---|
| 319 | disassemble = print_insn_tic4x; | 
|---|
| 320 | break; | 
|---|
| 321 | #endif | 
|---|
| 322 | #ifdef ARCH_tic54x | 
|---|
| 323 | case bfd_arch_tic54x: | 
|---|
| 324 | disassemble = print_insn_tic54x; | 
|---|
| 325 | break; | 
|---|
| 326 | #endif | 
|---|
| 327 | #ifdef ARCH_tic80 | 
|---|
| 328 | case bfd_arch_tic80: | 
|---|
| 329 | disassemble = print_insn_tic80; | 
|---|
| 330 | break; | 
|---|
| 331 | #endif | 
|---|
| 332 | #ifdef ARCH_v850 | 
|---|
| 333 | case bfd_arch_v850: | 
|---|
| 334 | disassemble = print_insn_v850; | 
|---|
| 335 | break; | 
|---|
| 336 | #endif | 
|---|
| 337 | #ifdef ARCH_w65 | 
|---|
| 338 | case bfd_arch_w65: | 
|---|
| 339 | disassemble = print_insn_w65; | 
|---|
| 340 | break; | 
|---|
| 341 | #endif | 
|---|
| 342 | #ifdef ARCH_xstormy16 | 
|---|
| 343 | case bfd_arch_xstormy16: | 
|---|
| 344 | disassemble = print_insn_xstormy16; | 
|---|
| 345 | break; | 
|---|
| 346 | #endif | 
|---|
| 347 | #ifdef ARCH_xtensa | 
|---|
| 348 | case bfd_arch_xtensa: | 
|---|
| 349 | disassemble = print_insn_xtensa; | 
|---|
| 350 | break; | 
|---|
| 351 | #endif | 
|---|
| 352 | #ifdef ARCH_z8k | 
|---|
| 353 | case bfd_arch_z8k: | 
|---|
| 354 | if (bfd_get_mach(abfd) == bfd_mach_z8001) | 
|---|
| 355 | disassemble = print_insn_z8001; | 
|---|
| 356 | else | 
|---|
| 357 | disassemble = print_insn_z8002; | 
|---|
| 358 | break; | 
|---|
| 359 | #endif | 
|---|
| 360 | #ifdef ARCH_vax | 
|---|
| 361 | case bfd_arch_vax: | 
|---|
| 362 | disassemble = print_insn_vax; | 
|---|
| 363 | break; | 
|---|
| 364 | #endif | 
|---|
| 365 | #ifdef ARCH_frv | 
|---|
| 366 | case bfd_arch_frv: | 
|---|
| 367 | disassemble = print_insn_frv; | 
|---|
| 368 | break; | 
|---|
| 369 | #endif | 
|---|
| 370 | #ifdef ARCH_iq2000 | 
|---|
| 371 | case bfd_arch_iq2000: | 
|---|
| 372 | disassemble = print_insn_iq2000; | 
|---|
| 373 | break; | 
|---|
| 374 | #endif | 
|---|
| 375 | default: | 
|---|
| 376 | return 0; | 
|---|
| 377 | } | 
|---|
| 378 | return disassemble; | 
|---|
| 379 | } | 
|---|
| 380 |  | 
|---|
| 381 | void | 
|---|
| 382 | disassembler_usage (stream) | 
|---|
| 383 | FILE * stream ATTRIBUTE_UNUSED; | 
|---|
| 384 | { | 
|---|
| 385 | #ifdef ARCH_arm | 
|---|
| 386 | print_arm_disassembler_options (stream); | 
|---|
| 387 | #endif | 
|---|
| 388 | #ifdef ARCH_mips | 
|---|
| 389 | print_mips_disassembler_options (stream); | 
|---|
| 390 | #endif | 
|---|
| 391 | #ifdef ARCH_powerpc | 
|---|
| 392 | print_ppc_disassembler_options (stream); | 
|---|
| 393 | #endif | 
|---|
| 394 |  | 
|---|
| 395 | return; | 
|---|
| 396 | } | 
|---|