* bucomm.c (make_tempname): Stop memory leak.
[binutils.git] / cpu / xc16x.opc
blob47b7c690e433f382e16515ac43372a8754a251ed
1 /* XC16X opcode support.  -*- C -*-
3    Copyright 2006, 2007, 2009 Free Software Foundation, Inc.
5    Contributed by KPIT Cummins Infosystems Ltd.; developed under contract 
6    from Infineon Systems, GMBH , Germany.
8    This file is part of the GNU Binutils.
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 3 of the License, or
13    (at your option) any later version.
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.
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.  */
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.
33    Each section is delimited with start and end markers.
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"  */
41 /* -- opc.h */
43 #define CGEN_DIS_HASH_SIZE 8
44 #define CGEN_DIS_HASH(buf,value) (((* (unsigned char*) (buf)) >> 3) % CGEN_DIS_HASH_SIZE)
46 /* -- */
48 /* -- opc.c */
49                                                                                 
50 /* -- */
52 /* -- asm.c */
53 /* Handle '#' prefixes (i.e. skip over them).  */
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)
61   if (**strp == '#')
62     {
63       ++*strp;
64       return NULL;
65     }
66   return _("Missing '#' prefix");
69 /* Handle '.' prefixes (i.e. skip over them).  */
71 static const char *
72 parse_dot (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
73            const char **strp,
74            int opindex ATTRIBUTE_UNUSED,
75            long *valuep ATTRIBUTE_UNUSED)
77   if (**strp == '.')
78     {
79       ++*strp;
80       return NULL;
81     }
82   return _("Missing '.' prefix");
85 /* Handle 'pof:' prefixes (i.e. skip over them).  */
87 static const char *
88 parse_pof (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
89            const char **strp,
90            int opindex ATTRIBUTE_UNUSED,
91            long *valuep ATTRIBUTE_UNUSED)
93   if (strncasecmp (*strp, "pof:", 4) == 0)
94     {
95       *strp += 4;
96       return NULL;
97     }
98   return _("Missing 'pof:' prefix");  
101 /* Handle 'pag:' prefixes (i.e. skip over them).  */
103 static const char *
104 parse_pag (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
105            const char **strp,
106            int opindex ATTRIBUTE_UNUSED,
107            long *valuep ATTRIBUTE_UNUSED)
109   if (strncasecmp (*strp, "pag:", 4) == 0)
110     {
111       *strp += 4;
112       return NULL;
113     }
114   return _("Missing 'pag:' prefix");
117 /* Handle 'sof' prefixes (i.e. skip over them).  */
119 static const char *
120 parse_sof (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
121            const char **strp,
122            int opindex ATTRIBUTE_UNUSED,
123            long *valuep ATTRIBUTE_UNUSED)
125   if (strncasecmp (*strp, "sof:", 4) == 0)
126     {
127       *strp += 4;
128       return NULL;
129     }
130   return _("Missing 'sof:' prefix");
133 /* Handle 'seg' prefixes (i.e. skip over them).  */
135 static const char *
136 parse_seg (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
137            const char **strp,
138            int opindex ATTRIBUTE_UNUSED,
139            long *valuep ATTRIBUTE_UNUSED)
141   if (strncasecmp (*strp, "seg:", 4) == 0)
142     {
143       *strp += 4;
144       return NULL;
145     }
146   return _("Missing 'seg:' prefix");
148 /* -- */
150 /* -- dis.c */
152 /* Print an operand with a "." prefix.
153    NOTE: This prints the operand in hex.
154    ??? This exists to maintain disassembler compatibility with previous
155    versions.  Ideally we'd print the "." in print_dot.  */
157 static void
158 print_with_dot_prefix (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
159                        void * dis_info,
160                        long value,
161                        unsigned attrs ATTRIBUTE_UNUSED,
162                        bfd_vma pc ATTRIBUTE_UNUSED,
163                        int length ATTRIBUTE_UNUSED)
165   disassemble_info *info = (disassemble_info *) dis_info;
167   info->fprintf_func (info->stream, ".");
168   info->fprintf_func (info->stream, "0x%lx", value);
171 /* Print an operand with a "#pof:" prefix.
172    NOTE: This prints the operand as an address.
173    ??? This exists to maintain disassembler compatibility with previous
174    versions.  Ideally we'd print "#pof:" in print_pof.  */
176 static void
177 print_with_pof_prefix (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
178                        void * dis_info,
179                        bfd_vma value,
180                        unsigned attrs ATTRIBUTE_UNUSED,
181                        bfd_vma pc ATTRIBUTE_UNUSED,
182                        int length ATTRIBUTE_UNUSED)
184   disassemble_info *info = (disassemble_info *) dis_info;
186   info->fprintf_func (info->stream, "#pof:");
187   info->fprintf_func (info->stream, "0x%lx", (long) value);
190 /* Print an operand with a "#pag:" prefix.
191    NOTE: This prints the operand in hex.
192    ??? This exists to maintain disassembler compatibility with previous
193    versions.  Ideally we'd print "#pag:" in print_pag.  */
195 static void
196 print_with_pag_prefix (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
197                        void * dis_info,
198                        long value,
199                        unsigned attrs ATTRIBUTE_UNUSED,
200                        bfd_vma pc ATTRIBUTE_UNUSED,
201                        int length ATTRIBUTE_UNUSED)
203   disassemble_info *info = (disassemble_info *) dis_info;
205   info->fprintf_func (info->stream, "#pag:");
206   info->fprintf_func (info->stream, "0x%lx", value);
209 /* Print a 'pof:' prefix to an operand.  */
211 static void
212 print_pof (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
213            void * dis_info ATTRIBUTE_UNUSED,
214            long value ATTRIBUTE_UNUSED,
215            unsigned int attrs ATTRIBUTE_UNUSED,
216            bfd_vma pc ATTRIBUTE_UNUSED,
217            int length ATTRIBUTE_UNUSED)
221 /* Print a 'pag:' prefix to an operand.  */
223 static void
224 print_pag (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
225            void * dis_info ATTRIBUTE_UNUSED,
226            long value ATTRIBUTE_UNUSED,
227            unsigned int attrs ATTRIBUTE_UNUSED,
228            bfd_vma pc ATTRIBUTE_UNUSED,
229            int length ATTRIBUTE_UNUSED)
233 /* Print a 'sof:' prefix to an operand.  */
235 static void
236 print_sof (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
237            void * dis_info,
238            long value ATTRIBUTE_UNUSED,
239            unsigned int attrs ATTRIBUTE_UNUSED,
240            bfd_vma pc ATTRIBUTE_UNUSED,
241            int length ATTRIBUTE_UNUSED)
243   disassemble_info *info = (disassemble_info *) dis_info;
245   info->fprintf_func (info->stream, "sof:");
248 /* Print a 'seg:' prefix to an operand.  */
250 static void
251 print_seg (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
252            void * dis_info,
253            long value ATTRIBUTE_UNUSED,
254            unsigned int attrs ATTRIBUTE_UNUSED,
255            bfd_vma pc ATTRIBUTE_UNUSED,
256            int length ATTRIBUTE_UNUSED)
258   disassemble_info *info = (disassemble_info *) dis_info;
260   info->fprintf_func (info->stream, "seg:");
263 /* Print a '#' prefix to an operand.  */
265 static void
266 print_hash (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
267             void * dis_info,
268             long value ATTRIBUTE_UNUSED,
269             unsigned int attrs ATTRIBUTE_UNUSED,
270             bfd_vma pc ATTRIBUTE_UNUSED,
271             int length ATTRIBUTE_UNUSED)
273   disassemble_info *info = (disassemble_info *) dis_info;
275   info->fprintf_func (info->stream, "#");
278 /* Print a '.' prefix to an operand.  */
280 static void
281 print_dot (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
282            void * dis_info ATTRIBUTE_UNUSED,
283            long value ATTRIBUTE_UNUSED,
284            unsigned int attrs ATTRIBUTE_UNUSED,
285            bfd_vma pc ATTRIBUTE_UNUSED,
286            int length ATTRIBUTE_UNUSED)
290 /* -- */