Coverage Report

Created: 2025-06-24 06:45

/src/binutils-gdb/bfd/cpu-z80.c
Line
Count
Source (jump to first uncovered line)
1
/* BFD library support routines for the Z80 architecture.
2
   Copyright (C) 2005-2025 Free Software Foundation, Inc.
3
   Contributed by Arnold Metselaar <arnold_m@operamail.com>
4
5
   This file is part of BFD, the Binary File Descriptor library.
6
7
   This program is free software; you can redistribute it and/or modify
8
   it under the terms of the GNU General Public License as published by
9
   the Free Software Foundation; either version 3 of the License, or
10
   (at your option) any later version.
11
12
   This program is distributed in the hope that it will be useful,
13
   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
   GNU General Public License for more details.
16
17
   You should have received a copy of the GNU General Public License
18
   along with this program; if not, write to the Free Software
19
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20
   MA 02110-1301, USA.  */
21
22
#include "sysdep.h"
23
#include "bfd.h"
24
#include "libbfd.h"
25
26
const bfd_arch_info_type bfd_z80_arch;
27
28
/* This routine is provided two arch_infos and
29
   returns whether they'd be compatible.  */
30
31
static const bfd_arch_info_type *
32
compatible (const bfd_arch_info_type *a, const bfd_arch_info_type *b)
33
0
{
34
0
  if (a->arch != b->arch || a->arch != bfd_arch_z80)
35
0
    return NULL;
36
37
0
  if (a->mach == b->mach)
38
0
    return a;
39
0
  switch (a->mach)
40
0
    {
41
0
    case bfd_mach_z80:
42
0
    case bfd_mach_z80full:
43
0
    case bfd_mach_z80strict:
44
0
      switch (b->mach)
45
0
  {
46
0
  case bfd_mach_z80:
47
0
  case bfd_mach_z80full:
48
0
  case bfd_mach_z80strict:
49
0
    return & bfd_z80_arch;
50
0
  case bfd_mach_z180:
51
0
  case bfd_mach_ez80_z80:
52
0
  case bfd_mach_ez80_adl:
53
0
  case bfd_mach_z80n:
54
0
  case bfd_mach_r800:
55
0
    return b;
56
0
  }
57
0
      break;
58
0
    case bfd_mach_z80n:
59
0
    case bfd_mach_r800:
60
0
      switch (b->mach)
61
0
  {
62
0
  case bfd_mach_z80:
63
0
  case bfd_mach_z80full:
64
0
  case bfd_mach_z80strict:
65
0
    return a;
66
0
  }
67
0
      break;
68
0
    case bfd_mach_z180:
69
0
      switch (b->mach)
70
0
  {
71
0
  case bfd_mach_z80:
72
0
  case bfd_mach_z80full:
73
0
  case bfd_mach_z80strict:
74
0
    return a;
75
0
  case bfd_mach_ez80_z80:
76
0
  case bfd_mach_ez80_adl:
77
0
    return b;
78
0
  }
79
0
      break;
80
0
    case bfd_mach_ez80_z80:
81
0
    case bfd_mach_ez80_adl:
82
0
      switch (b->mach)
83
0
  {
84
0
  case bfd_mach_z80:
85
0
  case bfd_mach_z80full:
86
0
  case bfd_mach_z80strict:
87
0
  case bfd_mach_z180:
88
0
  case bfd_mach_ez80_z80:
89
0
    return a;
90
0
  case bfd_mach_ez80_adl:
91
0
    return b;
92
0
  }
93
0
      break;
94
0
    case bfd_mach_gbz80:
95
0
       return NULL;
96
0
    }
97
98
0
  return NULL;
99
0
}
100
101
#define N(name,print,bits,default,next)  \
102
 { 16, bits, 8, bfd_arch_z80, name, "z80", print, 0, default, \
103
   compatible, bfd_default_scan, bfd_arch_default_fill, next, 0 }
104
105
#define M(n) &arch_info_struct[n]
106
107
static const bfd_arch_info_type arch_info_struct[] =
108
{
109
  N (bfd_mach_z80,   "z80",        16, true,  M(1)),
110
  N (bfd_mach_z80strict, "z80-strict", 16, false, M(2)),
111
  N (bfd_mach_z80full,   "z80-full",   16, false, M(3)),
112
  N (bfd_mach_r800,  "r800",       16, false, M(4)),
113
  N (bfd_mach_gbz80,   "gbz80",      16, false, M(5)),
114
  N (bfd_mach_z180,  "z180",       16, false, M(6)),
115
  N (bfd_mach_z80n,  "z80n",       16, false, M(7)),
116
  N (bfd_mach_ez80_z80,  "ez80-z80",   16, false, M(8)),
117
  N (bfd_mach_ez80_adl,  "ez80-adl",   24, false, NULL)
118
};
119
120
const bfd_arch_info_type bfd_z80_arch =
121
  N (bfd_mach_z80,   "z80",   16, true,  M(1));