OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-binutils/] [binutils-2.19.1/] [cpu/] [scarts_16.opc] - Blame information for rev 13

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 jlechner
/* SCARTS_16 architecture description.  -*- Scheme -*-
2
   Copyright 2000, 2001 Free Software Foundation, Inc.
3
   Contributed by Martin Walter 
4
 
5
   This file is part of the GNU Binutils.
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 2 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
*/
21
 
22
/* This file is an addendum to scarts_16.cpu. Heavy use of C code isn't
23
   appropriate in .cpu files, so it resides here. This especially applies
24
   to assembly/disassembly where parsing/printing can be quite involved.
25
   Such things aren't really part of the specification of the cpu, per se,
26
   so .cpu files provide the general framework and .opc files handle the
27
   nitty-gritty details as necessary.
28
 
29
   Each section is delimited with start and end markers.
30
 
31
   -opc.h additions use: "-- opc.h"
32
   -opc.c additions use: "-- opc.c"
33
   -asm.c additions use: "-- asm.c"
34
   -dis.c additions use: "-- dis.c"
35
   -ibd.h additions use: "-- ibd.h".
36
*/
37
 
38
/* -- opc.h */
39
#define CGEN_DIS_HASH_SIZE 1
40
#define CGEN_DIS_HASH(buffer, value) 0
41
 
42
#define CGEN_VALIDATE_INSN_SUPPORTED
43
#define CGEN_VERBOSE_ASSEMBLER_ERRORS
44
 
45
extern int scarts_16_cgen_insn_supported(CGEN_CPU_DESC, const CGEN_INSN *);
46
 
47
/* -- */
48
 
49
/* -- opc.c */
50
/* -- */
51
 
52
/* -- asm.c */
53
static const char * MISSING_CLOSING_PARENTHESIS = N_("missing `)'");
54
 
55
int
56
scarts_16_cgen_insn_supported (CGEN_CPU_DESC cd, const CGEN_INSN *insn)
57
{
58
  return (CGEN_INSN_ATTR_VALUE(insn, CGEN_INSN_MACH) & cd->machs) != 0;
59
}
60
 
61
static const char *
62
parse_simm8 (CGEN_CPU_DESC cd, const char **strp, int opindex, long *valuep)
63
{
64
  const char *errmsg;
65
  enum cgen_parse_operand_result result_type;
66
  unsigned long result;
67
 
68
  if (strncasecmp(*strp, "lo(", 3) == 0)
69
  {
70
    bfd_vma value;
71
 
72
    *strp += 3;
73
    errmsg = cgen_parse_address(cd, strp, opindex, BFD_RELOC_SCARTS_16_LO, &result_type, &value);
74
 
75
    if (**strp != ')')
76
      return MISSING_CLOSING_PARENTHESIS;
77
 
78
    *strp += 1;
79
    if (errmsg == NULL && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
80
    {
81
      if (value & 0x1)
82
        return _("immediate value must be even");
83
 
84
      value >>= 1;
85
    }
86
 
87
    result = value;
88
  }
89
  else if (strncasecmp(*strp, "hi(", 3) == 0)
90
  {
91
    bfd_vma value;
92
 
93
    *strp += 3;
94
    errmsg = cgen_parse_address(cd, strp, opindex, BFD_RELOC_SCARTS_16_HI, &result_type, &value);
95
 
96
    if (**strp != ')')
97
      return MISSING_CLOSING_PARENTHESIS;
98
 
99
    *strp += 1;
100
    if (errmsg == NULL && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
101
    {
102
      if (value & 0x1)
103
        return _("immediate value must be even");
104
 
105
      value >>= 9;
106
    }
107
 
108
    result = value;
109
  }
110
  else
111
  {
112
    if (**strp == '-')
113
    {
114
      long value;
115
 
116
      errmsg = cgen_parse_signed_integer(cd, strp, opindex, &value);
117
      result = value;
118
    }
119
    else
120
    {
121
      unsigned long value;
122
 
123
      errmsg = cgen_parse_unsigned_integer(cd, strp, opindex, &value);
124
      result = value;
125
    }
126
  }
127
 
128
  *valuep = ((result & 0xFF) ^ 0x80) - 0x80;
129
  return errmsg;
130
}
131
 
132
static const char *
133
parse_uimm8 (CGEN_CPU_DESC cd, const char **strp, int opindex, unsigned long *valuep)
134
{
135
  const char *errmsg;
136
  enum cgen_parse_operand_result result_type;
137
  unsigned long result;
138
 
139
  if (strncasecmp(*strp, "lo(", 3) == 0)
140
  {
141
    bfd_vma value;
142
 
143
    *strp += 3;
144
    errmsg = cgen_parse_address(cd, strp, opindex, BFD_RELOC_SCARTS_16_LO, &result_type, &value);
145
 
146
    if (**strp != ')')
147
      return MISSING_CLOSING_PARENTHESIS;
148
 
149
    *strp += 1;
150
    if (errmsg == NULL && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
151
    {
152
      if (value & 0x1)
153
        return _("immediate value must be even");
154
 
155
      value >>= 1;
156
    }
157
 
158
    result = value;
159
  }
160
  else if (strncasecmp(*strp, "hi(", 3) == 0)
161
  {
162
    bfd_vma value;
163
 
164
    *strp += 3;
165
    errmsg = cgen_parse_address(cd, strp, opindex, BFD_RELOC_SCARTS_16_HI, &result_type, &value);
166
 
167
    if (**strp != ')')
168
      return MISSING_CLOSING_PARENTHESIS;
169
 
170
    *strp += 1;
171
    if (errmsg == NULL && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
172
    {
173
      if (value & 0x1)
174
        return _("immediate value must be even");
175
 
176
      value >>= 9;
177
    }
178
 
179
    result = value;
180
  }
181
  else
182
  {
183
    unsigned long value;
184
 
185
    errmsg = cgen_parse_unsigned_integer(cd, strp, opindex, &value);
186
    result = value;
187
  }
188
 
189
  *valuep = result & 0xFF;
190
  return errmsg;
191
}
192
 
193
static const char *
194
parse_saddr10_pcrel (CGEN_CPU_DESC cd, const char **strp, int opindex, long *valuep)
195
{
196
  const char *errmsg;
197
  enum cgen_parse_operand_result result_type;
198
  bfd_vma value;
199
 
200
  errmsg = cgen_parse_address(cd, strp, opindex, BFD_RELOC_SCARTS_16_PCREL_10, &result_type, &value);
201
  if (errmsg == NULL && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
202
  {
203
    if (value & 0x1)
204
      return _("immediate value must be even");
205
  }
206
 
207
  *valuep = ((value & 0x3FF) ^ 0x200) - 0x200;
208
  return errmsg;
209
}
210
/* -- */
211
 
212
/* -- dis.c */
213
/* -- */
214
 
215
/* -- ibd.h */
216
/* -- */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.