cpu-msp430.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /* BFD library support routines for the MSP architecture.
  2. Copyright (C) 2002-2022 Free Software Foundation, Inc.
  3. Contributed by Dmitry Diky <diwil@mail.ru>
  4. This file is part of BFD, the Binary File Descriptor library.
  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 3 of the License, or
  8. (at your option) any later version.
  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. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  16. MA 02110-1301, USA. */
  17. #include "sysdep.h"
  18. #include "bfd.h"
  19. #include "libbfd.h"
  20. /* This routine is provided two arch_infos and works out which MSP
  21. machine which would be compatible with both and returns a pointer
  22. to its info structure. */
  23. static const bfd_arch_info_type *
  24. compatible (const bfd_arch_info_type * a,
  25. const bfd_arch_info_type * b)
  26. {
  27. /* If a & b are for different architectures we can do nothing. */
  28. if (a->arch != b->arch)
  29. return NULL;
  30. if (a->mach <= b->mach)
  31. return b;
  32. return a;
  33. }
  34. #define N(addr_bits, machine, print, default, next) \
  35. { \
  36. 16, /* Bits in a word. */ \
  37. addr_bits, /* Bits in an address. */ \
  38. 8, /* Bits in a byte. */ \
  39. bfd_arch_msp430, \
  40. machine, /* Machine number. */ \
  41. "msp430", /* Architecture name. */ \
  42. print, /* Printable name. */ \
  43. 1, /* Section align power. */ \
  44. default, /* The default machine. */ \
  45. compatible, \
  46. bfd_default_scan, \
  47. bfd_arch_default_fill, \
  48. next, \
  49. 0 /* Maximum offset of a reloc from the start of an insn. */ \
  50. }
  51. static const bfd_arch_info_type arch_info_struct[] =
  52. {
  53. /* msp430x11x. */
  54. N (16, bfd_mach_msp11, "MSP430", false, & arch_info_struct[1]),
  55. /* msp430x11x1. */
  56. N (16, bfd_mach_msp110, "MSP430x11x1", false, & arch_info_struct[2]),
  57. /* msp430x12x. */
  58. N (16, bfd_mach_msp12, "MSP430x12", false, & arch_info_struct[3]),
  59. /* msp430x13x. */
  60. N (16, bfd_mach_msp13, "MSP430x13", false, & arch_info_struct[4]),
  61. /* msp430x14x. */
  62. N (16, bfd_mach_msp14, "MSP430x14", false, & arch_info_struct[5]),
  63. /* msp430x15x. */
  64. N (16, bfd_mach_msp15, "MSP430x15", false, & arch_info_struct[6]),
  65. /* msp430x16x. */
  66. N (16, bfd_mach_msp16, "MSP430x16", false, & arch_info_struct[7]),
  67. /* msp430x20x. */
  68. N (16, bfd_mach_msp20, "MSP430x20", false, & arch_info_struct[8]),
  69. /* msp430x21x. */
  70. N (16, bfd_mach_msp21, "MSP430x21", false, & arch_info_struct[9]),
  71. /* msp430x22x. */
  72. N (16, bfd_mach_msp22, "MSP430x22", false, & arch_info_struct[10]),
  73. /* msp430x23x. */
  74. N (16, bfd_mach_msp23, "MSP430x23", false, & arch_info_struct[11]),
  75. /* msp430x24x. */
  76. N (16, bfd_mach_msp24, "MSP430x24", false, & arch_info_struct[12]),
  77. /* msp430x26x. */
  78. N (16, bfd_mach_msp26, "MSP430x26", false, & arch_info_struct[13]),
  79. /* msp430x31x. */
  80. N (16, bfd_mach_msp31, "MSP430x31", false, & arch_info_struct[14]),
  81. /* msp430x32x. */
  82. N (16, bfd_mach_msp32, "MSP430x32", false, & arch_info_struct[15]),
  83. /* msp430x33x. */
  84. N (16, bfd_mach_msp33, "MSP430x33", false, & arch_info_struct[16]),
  85. /* msp430x41x. */
  86. N (16, bfd_mach_msp41, "MSP430x41", false, & arch_info_struct[17]),
  87. /* msp430x42x. */
  88. N (16, bfd_mach_msp42, "MSP430x42", false, & arch_info_struct[18]),
  89. /* msp430x43x. */
  90. N (16, bfd_mach_msp43, "MSP430x43", false, & arch_info_struct[19]),
  91. /* msp430x44x. */
  92. N (16, bfd_mach_msp43, "MSP430x44", false, & arch_info_struct[20]),
  93. /* msp430x46x. */
  94. N (16, bfd_mach_msp46, "MSP430x46", false, & arch_info_struct[21]),
  95. /* msp430x47x. */
  96. N (16, bfd_mach_msp47, "MSP430x47", false, & arch_info_struct[22]),
  97. /* msp430x54x. */
  98. N (16, bfd_mach_msp54, "MSP430x54", false, & arch_info_struct[23]),
  99. N (32, bfd_mach_msp430x, "MSP430X", false, NULL)
  100. };
  101. const bfd_arch_info_type bfd_msp430_arch =
  102. N (16, bfd_mach_msp14, "msp:14", true, & arch_info_struct[0]);