1 /* OpenRISC opcode support. -*- C -*-
2 Copyright 2000, 2001, 2003, 2005, 2011 Free Software Foundation, Inc.
4 Contributed by Red Hat Inc;
6 This file is part of the GNU Binutils.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 MA 02110-1301, USA. */
23 /* This file is an addendum to or32.cpu. Heavy use of C code isn't
24 appropriate in .cpu files, so it resides here. This especially applies
25 to assembly/disassembly where parsing/printing can be quite involved.
26 Such things aren't really part of the specification of the cpu, per se,
27 so .cpu files provide the general framework and .opc files handle the
28 nitty-gritty details as necessary.
30 Each section is delimited with start and end markers.
32 <arch>-opc.h additions use: "-- opc.h"
33 <arch>-opc.c additions use: "-- opc.c"
34 <arch>-asm.c additions use: "-- asm.c"
35 <arch>-dis.c additions use: "-- dis.c"
36 <arch>-ibd.h additions use: "-- ibd.h" */
39 #undef CGEN_DIS_HASH_SIZE
40 #define CGEN_DIS_HASH_SIZE 64
42 #define CGEN_DIS_HASH(buffer, value) (((unsigned char *) (buffer))[0] >> 2)
44 extern long openrisc_sign_extend_16bit (long);
52 static const char * MISSING_CLOSING_PARENTHESIS = N_("missing `)'");
54 #define CGEN_VERBOSE_ASSEMBLER_ERRORS
57 openrisc_sign_extend_16bit (long value)
59 return ((value & 0xffff) ^ 0x8000) - 0x8000;
65 parse_hi16 (CGEN_CPU_DESC cd, const char ** strp, int opindex, long * valuep)
68 enum cgen_parse_operand_result result_type;
74 if (strncasecmp (*strp, "hi(", 3) == 0)
79 errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_HI16,
80 & result_type, & value);
82 return MISSING_CLOSING_PARENTHESIS;
86 && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
96 errmsg = cgen_parse_signed_integer (cd, strp, opindex, &value);
103 errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, &value);
108 *valuep = ((ret & 0xffff) ^ 0x8000) - 0x8000;
115 parse_lo16 (CGEN_CPU_DESC cd, const char ** strp, int opindex, long * valuep)
118 enum cgen_parse_operand_result result_type;
124 if (strncasecmp (*strp, "lo(", 3) == 0)
129 errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_LO16,
130 & result_type, & value);
132 return MISSING_CLOSING_PARENTHESIS;
143 errmsg = cgen_parse_signed_integer (cd, strp, opindex, &value);
150 errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, &value);
155 *valuep = ((ret & 0xffff) ^ 0x8000) - 0x8000;
162 extern long openrisc_sign_extend_16bit (long);