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

Subversion Repositories scarts

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 jlechner
/* SCARTS_32 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_32.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_32_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_32_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_32_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_32_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 if (strncasecmp(*strp, "3rd(", 4) == 0)
111
  {
112
    bfd_vma value;
113
 
114
    *strp += 4;
115
    errmsg = cgen_parse_address(cd, strp, opindex, BFD_RELOC_SCARTS_32_3RD, &result_type, &value);
116
 
117
    if (**strp != ')')
118
      return MISSING_CLOSING_PARENTHESIS;
119
 
120
    *strp += 1;
121
    if (errmsg == NULL && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
122
    {
123
      if (value & 0x1)
124
        return _("immediate value must be even");
125
 
126
      value >>= 17;
127
    }
128
 
129
    result = value;
130
  }
131
  else if (strncasecmp(*strp, "4th(", 4) == 0)
132
  {
133
    bfd_vma value;
134
 
135
    *strp += 4;
136
    errmsg = cgen_parse_address(cd, strp, opindex, BFD_RELOC_SCARTS_32_4TH, &result_type, &value);
137
 
138
    if (**strp != ')')
139
      return MISSING_CLOSING_PARENTHESIS;
140
 
141
    *strp += 1;
142
    if (errmsg == NULL && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
143
    {
144
      if (value & 0x1)
145
        return _("immediate value must be even");
146
 
147
      value >>= 25;
148
    }
149
 
150
    result = value;
151
  }
152
  else
153
  {
154
    if (**strp == '-')
155
    {
156
      long value;
157
 
158
      errmsg = cgen_parse_signed_integer(cd, strp, opindex, &value);
159
      result = value;
160
    }
161
    else
162
    {
163
      unsigned long value;
164
 
165
      errmsg = cgen_parse_unsigned_integer(cd, strp, opindex, &value);
166
      result = value;
167
    }
168
  }
169
 
170
  *valuep = ((result & 0xFF) ^ 0x80) - 0x80;
171
  return errmsg;
172
}
173
 
174
static const char *
175
parse_uimm8 (CGEN_CPU_DESC cd, const char **strp, int opindex, unsigned long *valuep)
176
{
177
  const char *errmsg;
178
  enum cgen_parse_operand_result result_type;
179
  unsigned long result;
180
 
181
  if (strncasecmp(*strp, "lo(", 3) == 0)
182
  {
183
    bfd_vma value;
184
 
185
    *strp += 3;
186
    errmsg = cgen_parse_address(cd, strp, opindex, BFD_RELOC_SCARTS_32_LO, &result_type, &value);
187
 
188
    if (**strp != ')')
189
      return MISSING_CLOSING_PARENTHESIS;
190
 
191
    *strp += 1;
192
    if (errmsg == NULL && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
193
    {
194
      if (value & 0x1)
195
        return _("immediate value must be even");
196
 
197
      value >>= 1;
198
    }
199
 
200
    result = value;
201
  }
202
  else if (strncasecmp(*strp, "hi(", 3) == 0)
203
  {
204
    bfd_vma value;
205
 
206
    *strp += 3;
207
    errmsg = cgen_parse_address(cd, strp, opindex, BFD_RELOC_SCARTS_32_HI, &result_type, &value);
208
 
209
    if (**strp != ')')
210
      return MISSING_CLOSING_PARENTHESIS;
211
 
212
    *strp += 1;
213
    if (errmsg == NULL && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
214
    {
215
      if (value & 0x1)
216
        return _("immediate value must be even");
217
 
218
      value >>= 9;
219
    }
220
 
221
    result = value;
222
  }
223
  else if (strncasecmp(*strp, "3rd(", 4) == 0)
224
  {
225
    bfd_vma value;
226
 
227
    *strp += 4;
228
    errmsg = cgen_parse_address(cd, strp, opindex, BFD_RELOC_SCARTS_32_3RD, &result_type, &value);
229
 
230
    if (**strp != ')')
231
      return MISSING_CLOSING_PARENTHESIS;
232
 
233
    *strp += 1;
234
    if (errmsg == NULL && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
235
    {
236
      if (value & 0x1)
237
        return _("immediate value must be even");
238
 
239
      value >>= 17;
240
    }
241
 
242
    result = value;
243
  }
244
  else if (strncasecmp(*strp, "4th(", 4) == 0)
245
  {
246
    bfd_vma value;
247
 
248
    *strp += 4;
249
    errmsg = cgen_parse_address(cd, strp, opindex, BFD_RELOC_SCARTS_32_4TH, &result_type, &value);
250
 
251
    if (**strp != ')')
252
      return MISSING_CLOSING_PARENTHESIS;
253
 
254
    *strp += 1;
255
    if (errmsg == NULL && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
256
    {
257
      if (value & 0x1)
258
        return _("immediate value must be even");
259
 
260
      value >>= 25;
261
    }
262
 
263
    result = value;
264
  }
265
  else
266
  {
267
    unsigned long value;
268
 
269
    errmsg = cgen_parse_unsigned_integer(cd, strp, opindex, &value);
270
    result = value;
271
  }
272
 
273
  *valuep = result & 0xFF;
274
  return errmsg;
275
}
276
 
277
static const char *
278
parse_saddr10_pcrel (CGEN_CPU_DESC cd, const char **strp, int opindex, long *valuep)
279
{
280
  const char *errmsg;
281
  enum cgen_parse_operand_result result_type;
282
  bfd_vma value;
283
 
284
  errmsg = cgen_parse_address(cd, strp, opindex, BFD_RELOC_SCARTS_32_PCREL_10, &result_type, &value);
285
  if (errmsg == NULL && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
286
  {
287
    if (value & 0x1)
288
      return _("immediate value must be even");
289
  }
290
 
291
  *valuep = ((value & 0x3FF) ^ 0x200) - 0x200;
292
  return errmsg;
293
}
294
/* -- */
295
 
296
/* -- dis.c */
297
/* -- */
298
 
299
/* -- ibd.h */
300
/* -- */

powered by: WebSVN 2.1.0

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