1 /* Disassembler code for Renesas RX.
2 Copyright (C) 2008-2014 Free Software Foundation, Inc.
3 Contributed by Red Hat.
6 This file is part of the GNU opcodes library.
8 This library 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, or (at your option)
13 It is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16 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. */
28 #include "opcode/rx.h"
33 disassemble_info * dis;
37 rx_get_byte (void * vdata)
40 RX_Data *rx_data = (RX_Data *) vdata;
42 rx_data->dis->read_memory_func (rx_data->pc,
51 static char const * size_names[] =
53 "", ".b", ".ub", ".b", ".w", ".uw", ".w", ".a", ".l"
56 static char const * opsize_names[] =
58 "", ".b", ".b", ".b", ".w", ".w", ".w", ".a", ".l"
61 static char const * register_names[] =
63 /* general registers */
64 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
65 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
66 /* control register */
67 "psw", "pc", "usp", "fpsw", "", "", "", "wr",
68 "bpsw", "bpc", "isp", "fintv", "intb", "", "", "",
69 "pbp", "pben", "", "", "", "", "", "",
70 "bbpsw", "bbpc", "", "", "", "", "", ""
73 static char const * condition_names[] =
76 "eq", "ne", "c", "nc", "gtu", "leu", "pz", "n",
77 "ge", "lt", "gt", "le", "o", "no", "always", "never"
80 static const char * flag_names[] =
82 "c", "z", "s", "o", "", "", "", "",
83 "", "", "", "", "", "", "", "",
84 "i", "u", "", "", "", "", "", ""
85 "", "", "", "", "", "", "", "",
89 print_insn_rx (bfd_vma addr, disassemble_info * dis)
93 RX_Opcode_Decoded opcode;
99 rv = rx_decode_opcode (addr, &opcode, rx_get_byte, &rx_data);
101 dis->bytes_per_line = 10;
103 #define PR (dis->fprintf_func)
104 #define PS (dis->stream)
105 #define PC(c) PR (PS, "%c", c)
107 for (s = opcode.syntax; *s; s++)
115 RX_Opcode_Operand * oper;
145 PR (PS, "%s", opsize_names[opcode.size]);
151 oper = opcode.op + *s - '0';
154 if (oper->type == RX_Operand_Indirect)
155 PR (PS, "%s", size_names[oper->size]);
160 case RX_Operand_Immediate:
162 dis->print_address_func (oper->addend, dis);
164 || oper->addend > 999
165 || oper->addend < -999)
166 PR (PS, "%#x", oper->addend);
168 PR (PS, "%d", oper->addend);
170 case RX_Operand_Register:
171 case RX_Operand_TwoReg:
172 PR (PS, "%s", register_names[oper->reg]);
174 case RX_Operand_Indirect:
176 PR (PS, "%d[%s]", oper->addend, register_names[oper->reg]);
178 PR (PS, "[%s]", register_names[oper->reg]);
180 case RX_Operand_Postinc:
181 PR (PS, "[%s+]", register_names[oper->reg]);
183 case RX_Operand_Predec:
184 PR (PS, "[-%s]", register_names[oper->reg]);
186 case RX_Operand_Condition:
187 PR (PS, "%s", condition_names[oper->reg]);
189 case RX_Operand_Flag:
190 PR (PS, "%s", flag_names[oper->reg]);