8d0d29595563f642264b4666989b5479812bc09f
[deliverable/binutils-gdb.git] / cpu / xc16x.opc
1 /* XC16X opcode support. -*- C -*-
2
3 Copyright 2006 Free Software Foundation, Inc.
4
5 Contributed by KPIT Cummins Infosystems Ltd.; developed under contract
6 from Infineon Systems, GMBH , Germany.
7
8 This file is part of the GNU Binutils.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
23 02110-1301, USA. */
24
25
26 /* This file is an addendum to xc16x.cpu. Heavy use of C code isn't
27 appropriate in .cpu files, so it resides here. This especially applies
28 to assembly/disassembly where parsing/printing can be quite involved.
29 Such things aren't really part of the specification of the cpu, per se,
30 so .cpu files provide the general framework and .opc files handle the
31 nitty-gritty details as necessary.
32
33 Each section is delimited with start and end markers.
34
35 <arch>-opc.h additions use: "-- opc.h"
36 <arch>-opc.c additions use: "-- opc.c"
37 <arch>-asm.c additions use: "-- asm.c"
38 <arch>-dis.c additions use: "-- dis.c"
39 <arch>-ibd.h additions use: "-- ibd.h" */
40 \f
41 /* -- opc.h */
42
43 #define CGEN_DIS_HASH_SIZE 8
44 #define CGEN_DIS_HASH(buf,value) (((* (unsigned char*) (buf)) >> 3) % CGEN_DIS_HASH_SIZE)
45
46 /* -- */
47 \f
48 /* -- opc.c */
49
50 /* -- */
51 \f
52 /* -- asm.c */
53 /* Handle '#' prefixes (i.e. skip over them). */
54
55 static const char *
56 parse_hash (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
57 const char **strp,
58 int opindex ATTRIBUTE_UNUSED,
59 long *valuep ATTRIBUTE_UNUSED)
60 {
61 if (**strp == '#')
62 ++*strp;
63 return NULL;
64 }
65
66 /* Handle '.' prefixes (i.e. skip over them). */
67
68 static const char *
69 parse_dot (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
70 const char **strp,
71 int opindex ATTRIBUTE_UNUSED,
72 long *valuep ATTRIBUTE_UNUSED)
73 {
74 if (**strp == '.')
75 ++*strp;
76 return NULL;
77 }
78
79 /* Handle '.' prefixes (i.e. skip over them). */
80
81 static const char *
82 parse_pof (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
83 const char **strp,
84 int opindex ATTRIBUTE_UNUSED,
85 long *valuep ATTRIBUTE_UNUSED)
86 {
87 if (!strncasecmp (*strp, "pof:", 4))
88 *strp += 4;
89 return NULL;
90 }
91
92 /* Handle '.' prefixes (i.e. skip over them). */
93
94 static const char *
95 parse_pag (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
96 const char **strp,
97 int opindex ATTRIBUTE_UNUSED,
98 long *valuep ATTRIBUTE_UNUSED)
99 {
100 if (!strncasecmp (*strp, "pag:", 4))
101 *strp += 4;
102 return NULL;
103 }
104
105 /* Handle 'sof' prefixes (i.e. skip over them). */
106 static const char *
107 parse_sof (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
108 const char **strp,
109 int opindex ATTRIBUTE_UNUSED,
110 long *valuep ATTRIBUTE_UNUSED)
111 {
112 if (!strncasecmp (*strp, "sof:", 4))
113 *strp += 4;
114 return NULL;
115 }
116
117 /* Handle 'seg' prefixes (i.e. skip over them). */
118 static const char *
119 parse_seg (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
120 const char **strp,
121 int opindex ATTRIBUTE_UNUSED,
122 long *valuep ATTRIBUTE_UNUSED)
123 {
124 if (!strncasecmp (*strp, "seg:", 4))
125 *strp += 4;
126 return NULL;
127 }
128 /* -- */
129 \f
130 /* -- dis.c */
131
132 #define CGEN_PRINT_NORMAL(cd, info, value, attrs, pc, length) \
133 do \
134 { \
135 if (CGEN_BOOL_ATTR ((attrs), CGEN_OPERAND_DOT_PREFIX)) \
136 info->fprintf_func (info->stream, "."); \
137 if (CGEN_BOOL_ATTR ((attrs), CGEN_OPERAND_POF_PREFIX)) \
138 info->fprintf_func (info->stream, "#pof:"); \
139 if (CGEN_BOOL_ATTR ((attrs), CGEN_OPERAND_PAG_PREFIX)) \
140 info->fprintf_func (info->stream, "#pag:"); \
141 } \
142 while (0)
143
144 /* Handle '.' prefixes as operands. */
145
146 static void
147 print_pof (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
148 void * dis_info ATTRIBUTE_UNUSED,
149 long value ATTRIBUTE_UNUSED,
150 unsigned int attrs ATTRIBUTE_UNUSED,
151 bfd_vma pc ATTRIBUTE_UNUSED,
152 int length ATTRIBUTE_UNUSED)
153 {
154 }
155
156 /* Handle '.' prefixes as operands. */
157
158 static void
159 print_pag (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
160 void * dis_info ATTRIBUTE_UNUSED,
161 long value ATTRIBUTE_UNUSED,
162 unsigned int attrs ATTRIBUTE_UNUSED,
163 bfd_vma pc ATTRIBUTE_UNUSED,
164 int length ATTRIBUTE_UNUSED)
165 {
166 }
167
168 /* Handle '.' prefixes as operands. */
169
170 static void
171 print_sof (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
172 void * dis_info,
173 long value ATTRIBUTE_UNUSED,
174 unsigned int attrs ATTRIBUTE_UNUSED,
175 bfd_vma pc ATTRIBUTE_UNUSED,
176 int length ATTRIBUTE_UNUSED)
177 {
178 disassemble_info *info = (disassemble_info *) dis_info;
179
180 info->fprintf_func (info->stream, "sof:");
181 }
182
183 /* Handle '.' prefixes as operands. */
184
185 static void
186 print_seg (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
187 void * dis_info,
188 long value ATTRIBUTE_UNUSED,
189 unsigned int attrs ATTRIBUTE_UNUSED,
190 bfd_vma pc ATTRIBUTE_UNUSED,
191 int length ATTRIBUTE_UNUSED)
192 {
193 disassemble_info *info = (disassemble_info *) dis_info;
194
195 info->fprintf_func (info->stream, "seg:");
196 }
197
198 /* Handle '#' prefixes as operands. */
199
200 static void
201 print_hash (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
202 void * dis_info,
203 long value ATTRIBUTE_UNUSED,
204 unsigned int attrs ATTRIBUTE_UNUSED,
205 bfd_vma pc ATTRIBUTE_UNUSED,
206 int length ATTRIBUTE_UNUSED)
207 {
208 disassemble_info *info = (disassemble_info *) dis_info;
209
210 info->fprintf_func (info->stream, "#");
211 }
212
213 /* Handle '.' prefixes as operands. */
214
215 static void
216 print_dot (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
217 void * dis_info ATTRIBUTE_UNUSED,
218 long value ATTRIBUTE_UNUSED,
219 unsigned int attrs ATTRIBUTE_UNUSED,
220 bfd_vma pc ATTRIBUTE_UNUSED,
221 int length ATTRIBUTE_UNUSED)
222 {
223 }
224
225 /* -- */
This page took 0.041176 seconds and 3 git commands to generate.