cpu-z80.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /* BFD library support routines for the Z80 architecture.
  2. Copyright (C) 2005-2022 Free Software Foundation, Inc.
  3. Contributed by Arnold Metselaar <arnold_m@operamail.com>
  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. const bfd_arch_info_type bfd_z80_arch;
  21. /* This routine is provided two arch_infos and
  22. returns whether they'd be compatible. */
  23. static const bfd_arch_info_type *
  24. compatible (const bfd_arch_info_type *a, const bfd_arch_info_type *b)
  25. {
  26. if (a->arch != b->arch || a->arch != bfd_arch_z80)
  27. return NULL;
  28. if (a->mach == b->mach)
  29. return a;
  30. switch (a->mach)
  31. {
  32. case bfd_mach_z80:
  33. case bfd_mach_z80full:
  34. case bfd_mach_z80strict:
  35. switch (b->mach)
  36. {
  37. case bfd_mach_z80:
  38. case bfd_mach_z80full:
  39. case bfd_mach_z80strict:
  40. return & bfd_z80_arch;
  41. case bfd_mach_z180:
  42. case bfd_mach_ez80_z80:
  43. case bfd_mach_ez80_adl:
  44. case bfd_mach_z80n:
  45. case bfd_mach_r800:
  46. return b;
  47. }
  48. break;
  49. case bfd_mach_z80n:
  50. case bfd_mach_r800:
  51. switch (b->mach)
  52. {
  53. case bfd_mach_z80:
  54. case bfd_mach_z80full:
  55. case bfd_mach_z80strict:
  56. return a;
  57. }
  58. break;
  59. case bfd_mach_z180:
  60. switch (b->mach)
  61. {
  62. case bfd_mach_z80:
  63. case bfd_mach_z80full:
  64. case bfd_mach_z80strict:
  65. return a;
  66. case bfd_mach_ez80_z80:
  67. case bfd_mach_ez80_adl:
  68. return b;
  69. }
  70. break;
  71. case bfd_mach_ez80_z80:
  72. case bfd_mach_ez80_adl:
  73. switch (b->mach)
  74. {
  75. case bfd_mach_z80:
  76. case bfd_mach_z80full:
  77. case bfd_mach_z80strict:
  78. case bfd_mach_z180:
  79. case bfd_mach_ez80_z80:
  80. return a;
  81. case bfd_mach_ez80_adl:
  82. return b;
  83. }
  84. break;
  85. case bfd_mach_gbz80:
  86. return NULL;
  87. }
  88. return NULL;
  89. }
  90. #define N(name,print,bits,default,next) \
  91. { 16, bits, 8, bfd_arch_z80, name, "z80", print, 0, default, \
  92. compatible, bfd_default_scan, bfd_arch_default_fill, next, 0 }
  93. #define M(n) &arch_info_struct[n]
  94. static const bfd_arch_info_type arch_info_struct[] =
  95. {
  96. N (bfd_mach_z80, "z80", 16, true, M(1)),
  97. N (bfd_mach_z80strict, "z80-strict", 16, false, M(2)),
  98. N (bfd_mach_z80full, "z80-full", 16, false, M(3)),
  99. N (bfd_mach_r800, "r800", 16, false, M(4)),
  100. N (bfd_mach_gbz80, "gbz80", 16, false, M(5)),
  101. N (bfd_mach_z180, "z180", 16, false, M(6)),
  102. N (bfd_mach_z80n, "z80n", 16, false, M(7)),
  103. N (bfd_mach_ez80_z80, "ez80-z80", 16, false, M(8)),
  104. N (bfd_mach_ez80_adl, "ez80-adl", 24, false, NULL)
  105. };
  106. const bfd_arch_info_type bfd_z80_arch =
  107. N (bfd_mach_z80, "z80", 16, true, M(1));