1 /* Opcode decoder for the Renesas RX
2 Copyright 2008, 2009, 2010
3 Free Software Foundation, Inc.
4 Written by DJ Delorie <dj@redhat.com>
6 This file is part of GDB, the GNU Debugger and GAS, the GNU Assembler.
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, MA
23 /* The RX decoder in libopcodes is used by the simulator, gdb's
24 analyzer, and the disassembler. Given an opcode data source,
25 it decodes the next opcode into the following structures. */
30 RX_Byte
, /* undefined extension */
33 RX_Word
, /* undefined extension */
43 RX_Operand_Immediate
, /* #addend */
44 RX_Operand_Register
, /* Rn */
45 RX_Operand_Indirect
, /* [Rn + addend] */
46 RX_Operand_Postinc
, /* [Rn+] */
47 RX_Operand_Predec
, /* [-Rn] */
48 RX_Operand_Condition
, /* eq, gtu, etc */
49 RX_Operand_Flag
, /* [UIOSZC] */
50 RX_Operand_TwoReg
, /* [Rn + scale*R2] */
56 RXO_mov
, /* d = s (signed) */
57 RXO_movbi
, /* d = [s,s2] (signed) */
58 RXO_movbir
, /* [s,s2] = d (signed) */
59 RXO_pushm
, /* s..s2 */
61 RXO_xchg
, /* s <-> d */
62 RXO_stcc
, /* d = s if cond(s2) */
63 RXO_rtsd
, /* rtsd, 1=imm, 2-0 = reg if reg type */
65 /* These are all either d OP= s or, if s2 is set, d = s OP s2. Note
66 that d may be "None". */
79 RXO_adc
, /* d = d + s + carry */
80 RXO_sbb
, /* d = d - s - ~carry */
81 RXO_abs
, /* d = |s| */
82 RXO_max
, /* d = max(d,s) */
83 RXO_min
, /* d = min(d,s) */
84 RXO_emul
, /* d:64 = d:32 * s */
85 RXO_emulu
, /* d:64 = d:32 * s (unsigned) */
87 RXO_rolc
, /* d <<= 1 through carry */
88 RXO_rorc
, /* d >>= 1 through carry*/
89 RXO_rotl
, /* d <<= #s without carry */
90 RXO_rotr
, /* d >>= #s without carry*/
91 RXO_revw
, /* d = revw(s) */
92 RXO_revl
, /* d = revl(s) */
93 RXO_branch
, /* pc = d if cond(s) */
94 RXO_branchrel
,/* pc += d if cond(s) */
96 RXO_jsrrel
, /* pc += d */
122 RXO_sat
, /* sat(d) */
125 RXO_fadd
, /* d op= s */
134 RXO_bset
, /* d |= (1<<s) */
135 RXO_bclr
, /* d &= ~(1<<s) */
136 RXO_btst
, /* s & (1<<s2) */
137 RXO_bnot
, /* d ^= (1<<s) */
138 RXO_bmcc
, /* d<s> = cond(s2) */
140 RXO_clrpsw
, /* flag index in d */
141 RXO_setpsw
, /* flag index in d */
142 RXO_mvtipl
, /* new IPL in s */
146 RXO_rtd
, /* undocumented */
148 RXO_dbt
, /* undocumented */
149 RXO_int
, /* vector id in s */
153 RXO_sccnd
, /* d = cond(s) ? 1 : 0 */
156 /* Condition bitpatterns, as registers. */
173 #define RXC_always 14
178 RX_Operand_Type type
;
191 /* By convention, these are destination, source1, source2. */
192 RX_Opcode_Operand op
[3];
194 /* The logic here is:
195 newflags = (oldflags & ~(int)flags_0) | flags_1 | (op_flags & flags_s)
196 Only the O, S, Z, and C flags are affected. */
197 char flags_0
; /* This also clears out flags-to-be-set. */
202 /* Within the syntax, %c-style format specifiers are as follows:
205 %0 = operand[0] (destination)
206 %1 = operand[1] (source)
207 %2 = operand[2] (2nd source)
208 %s = operation size (b/w/l)
209 %SN = operand size [N] (N=0,1,2)
210 %aN = op[N] as an address (N=0,1,2)
212 Register numbers 0..15 are general registers. 16..31 are control
213 registers. 32..47 are condition codes. */
215 int rx_decode_opcode (unsigned long, RX_Opcode_Decoded
*, int (*)(void *), void *);