root / microblaze-dis.c @ 109819e0
History | View | Annotate | Download (39.8 kB)
1 | e90e390c | Edgar E. Iglesias | /* Disassemble Xilinx microblaze instructions.
|
---|---|---|---|
2 | e90e390c | Edgar E. Iglesias | Copyright (C) 1993, 1999, 2000 Free Software Foundation, Inc.
|
3 | e90e390c | Edgar E. Iglesias | |
4 | e90e390c | Edgar E. Iglesias | This program is free software; you can redistribute it and/or modify
|
5 | e90e390c | Edgar E. Iglesias | it under the terms of the GNU General Public License as published by
|
6 | e90e390c | Edgar E. Iglesias | the Free Software Foundation; either version 2 of the License, or
|
7 | e90e390c | Edgar E. Iglesias | (at your option) any later version.
|
8 | e90e390c | Edgar E. Iglesias | |
9 | e90e390c | Edgar E. Iglesias | This program is distributed in the hope that it will be useful,
|
10 | e90e390c | Edgar E. Iglesias | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 | e90e390c | Edgar E. Iglesias | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12 | e90e390c | Edgar E. Iglesias | GNU General Public License for more details.
|
13 | e90e390c | Edgar E. Iglesias | |
14 | e90e390c | Edgar E. Iglesias | You should have received a copy of the GNU General Public License
|
15 | 8167ee88 | Blue Swirl | along with this program; if not, see <http://www.gnu.org/licenses/>. */
|
16 | e90e390c | Edgar E. Iglesias | |
17 | e90e390c | Edgar E. Iglesias | /*
|
18 | e90e390c | Edgar E. Iglesias | * Copyright (c) 2001 Xilinx, Inc. All rights reserved.
|
19 | e90e390c | Edgar E. Iglesias | *
|
20 | e90e390c | Edgar E. Iglesias | * Redistribution and use in source and binary forms are permitted
|
21 | e90e390c | Edgar E. Iglesias | * provided that the above copyright notice and this paragraph are
|
22 | e90e390c | Edgar E. Iglesias | * duplicated in all such forms and that any documentation,
|
23 | e90e390c | Edgar E. Iglesias | * advertising materials, and other materials related to such
|
24 | e90e390c | Edgar E. Iglesias | * distribution and use acknowledge that the software was developed
|
25 | e90e390c | Edgar E. Iglesias | * by Xilinx, Inc. The name of the Company may not be used to endorse
|
26 | e90e390c | Edgar E. Iglesias | * or promote products derived from this software without specific prior
|
27 | e90e390c | Edgar E. Iglesias | * written permission.
|
28 | e90e390c | Edgar E. Iglesias | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
29 | e90e390c | Edgar E. Iglesias | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
30 | e90e390c | Edgar E. Iglesias | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
31 | e90e390c | Edgar E. Iglesias | *
|
32 | e90e390c | Edgar E. Iglesias | * Xilinx, Inc.
|
33 | e90e390c | Edgar E. Iglesias | */
|
34 | e90e390c | Edgar E. Iglesias | |
35 | e90e390c | Edgar E. Iglesias | |
36 | e90e390c | Edgar E. Iglesias | #include <stdio.h> |
37 | e90e390c | Edgar E. Iglesias | #define STATIC_TABLE
|
38 | e90e390c | Edgar E. Iglesias | #define DEFINE_TABLE
|
39 | e90e390c | Edgar E. Iglesias | |
40 | e90e390c | Edgar E. Iglesias | #ifndef MICROBLAZE_OPC
|
41 | e90e390c | Edgar E. Iglesias | #define MICROBLAZE_OPC
|
42 | e90e390c | Edgar E. Iglesias | /* Assembler instructions for Xilinx's microblaze processor
|
43 | e90e390c | Edgar E. Iglesias | Copyright (C) 1999, 2000 Free Software Foundation, Inc.
|
44 | e90e390c | Edgar E. Iglesias | |
45 | e90e390c | Edgar E. Iglesias |
|
46 | e90e390c | Edgar E. Iglesias | This program is free software; you can redistribute it and/or modify
|
47 | e90e390c | Edgar E. Iglesias | it under the terms of the GNU General Public License as published by
|
48 | e90e390c | Edgar E. Iglesias | the Free Software Foundation; either version 2 of the License, or
|
49 | e90e390c | Edgar E. Iglesias | (at your option) any later version.
|
50 | e90e390c | Edgar E. Iglesias | |
51 | e90e390c | Edgar E. Iglesias | This program is distributed in the hope that it will be useful,
|
52 | e90e390c | Edgar E. Iglesias | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
53 | e90e390c | Edgar E. Iglesias | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
54 | e90e390c | Edgar E. Iglesias | GNU General Public License for more details.
|
55 | e90e390c | Edgar E. Iglesias | |
56 | e90e390c | Edgar E. Iglesias | You should have received a copy of the GNU General Public License
|
57 | 8167ee88 | Blue Swirl | along with this program; if not, see <http://www.gnu.org/licenses/>. */
|
58 | e90e390c | Edgar E. Iglesias | |
59 | e90e390c | Edgar E. Iglesias | /*
|
60 | e90e390c | Edgar E. Iglesias | * Copyright (c) 2001 Xilinx, Inc. All rights reserved.
|
61 | e90e390c | Edgar E. Iglesias | *
|
62 | e90e390c | Edgar E. Iglesias | * Redistribution and use in source and binary forms are permitted
|
63 | e90e390c | Edgar E. Iglesias | * provided that the above copyright notice and this paragraph are
|
64 | e90e390c | Edgar E. Iglesias | * duplicated in all such forms and that any documentation,
|
65 | e90e390c | Edgar E. Iglesias | * advertising materials, and other materials related to such
|
66 | e90e390c | Edgar E. Iglesias | * distribution and use acknowledge that the software was developed
|
67 | e90e390c | Edgar E. Iglesias | * by Xilinx, Inc. The name of the Company may not be used to endorse
|
68 | e90e390c | Edgar E. Iglesias | * or promote products derived from this software without specific prior
|
69 | e90e390c | Edgar E. Iglesias | * written permission.
|
70 | e90e390c | Edgar E. Iglesias | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
71 | e90e390c | Edgar E. Iglesias | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
72 | e90e390c | Edgar E. Iglesias | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
73 | e90e390c | Edgar E. Iglesias | *
|
74 | e90e390c | Edgar E. Iglesias | * Xilinx, Inc.
|
75 | e90e390c | Edgar E. Iglesias | */
|
76 | e90e390c | Edgar E. Iglesias | |
77 | e90e390c | Edgar E. Iglesias | |
78 | e90e390c | Edgar E. Iglesias | #ifndef MICROBLAZE_OPCM
|
79 | e90e390c | Edgar E. Iglesias | #define MICROBLAZE_OPCM
|
80 | e90e390c | Edgar E. Iglesias | |
81 | e90e390c | Edgar E. Iglesias | /*
|
82 | e90e390c | Edgar E. Iglesias | * Copyright (c) 2001 Xilinx, Inc. All rights reserved.
|
83 | e90e390c | Edgar E. Iglesias | *
|
84 | e90e390c | Edgar E. Iglesias | * Redistribution and use in source and binary forms are permitted
|
85 | e90e390c | Edgar E. Iglesias | * provided that the above copyright notice and this paragraph are
|
86 | e90e390c | Edgar E. Iglesias | * duplicated in all such forms and that any documentation,
|
87 | e90e390c | Edgar E. Iglesias | * advertising materials, and other materials related to such
|
88 | e90e390c | Edgar E. Iglesias | * distribution and use acknowledge that the software was developed
|
89 | e90e390c | Edgar E. Iglesias | * by Xilinx, Inc. The name of the Company may not be used to endorse
|
90 | e90e390c | Edgar E. Iglesias | * or promote products derived from this software without specific prior
|
91 | e90e390c | Edgar E. Iglesias | * written permission.
|
92 | e90e390c | Edgar E. Iglesias | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
93 | e90e390c | Edgar E. Iglesias | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
94 | e90e390c | Edgar E. Iglesias | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
95 | e90e390c | Edgar E. Iglesias | *
|
96 | e90e390c | Edgar E. Iglesias | * Xilinx, Inc.
|
97 | e90e390c | Edgar E. Iglesias | * $Header:
|
98 | e90e390c | Edgar E. Iglesias | */
|
99 | e90e390c | Edgar E. Iglesias | |
100 | e90e390c | Edgar E. Iglesias | enum microblaze_instr {
|
101 | e90e390c | Edgar E. Iglesias | add, rsub, addc, rsubc, addk, rsubk, addkc, rsubkc, cmp, cmpu, |
102 | e90e390c | Edgar E. Iglesias | addi, rsubi, addic, rsubic, addik, rsubik, addikc, rsubikc, mul, |
103 | e90e390c | Edgar E. Iglesias | idiv, idivu, bsll, bsra, bsrl, get, put, nget, nput, cget, cput, |
104 | e90e390c | Edgar E. Iglesias | ncget, ncput, muli, bslli, bsrai, bsrli, mului, or, and, xor, |
105 | e90e390c | Edgar E. Iglesias | andn, pcmpbf, pcmpbc, pcmpeq, pcmpne, sra, src, srl, sext8, sext16, wic, wdc, mts, mfs, br, brd, |
106 | e90e390c | Edgar E. Iglesias | brld, bra, brad, brald, microblaze_brk, beq, beqd, bne, bned, blt, |
107 | e90e390c | Edgar E. Iglesias | bltd, ble, bled, bgt, bgtd, bge, bged, ori, andi, xori, andni, |
108 | e90e390c | Edgar E. Iglesias | imm, rtsd, rtid, rtbd, rted, bri, brid, brlid, brai, braid, bralid, |
109 | e90e390c | Edgar E. Iglesias | brki, beqi, beqid, bnei, bneid, blti, bltid, blei, bleid, bgti, |
110 | e90e390c | Edgar E. Iglesias | bgtid, bgei, bgeid, lbu, lhu, lw, sb, sh, sw, lbui, lhui, lwi, |
111 | e90e390c | Edgar E. Iglesias | sbi, shi, swi, msrset, msrclr, tuqula, fadd, frsub, fmul, fdiv, |
112 | e90e390c | Edgar E. Iglesias | fcmp_lt, fcmp_eq, fcmp_le, fcmp_gt, fcmp_ne, fcmp_ge, fcmp_un, invalid_inst } ; |
113 | e90e390c | Edgar E. Iglesias | |
114 | e90e390c | Edgar E. Iglesias | enum microblaze_instr_type {
|
115 | e90e390c | Edgar E. Iglesias | arithmetic_inst, logical_inst, mult_inst, div_inst, branch_inst, |
116 | e90e390c | Edgar E. Iglesias | return_inst, immediate_inst, special_inst, memory_load_inst, |
117 | e90e390c | Edgar E. Iglesias | memory_store_inst, barrel_shift_inst, anyware_inst }; |
118 | e90e390c | Edgar E. Iglesias | |
119 | e90e390c | Edgar E. Iglesias | #define INST_WORD_SIZE 4 |
120 | e90e390c | Edgar E. Iglesias | |
121 | e90e390c | Edgar E. Iglesias | /* gen purpose regs go from 0 to 31 */
|
122 | e90e390c | Edgar E. Iglesias | /* mask is reg num - max_reg_num, ie reg_num - 32 in this case */
|
123 | e90e390c | Edgar E. Iglesias | |
124 | e90e390c | Edgar E. Iglesias | #define REG_PC_MASK 0x8000 |
125 | e90e390c | Edgar E. Iglesias | #define REG_MSR_MASK 0x8001 |
126 | e90e390c | Edgar E. Iglesias | #define REG_EAR_MASK 0x8003 |
127 | e90e390c | Edgar E. Iglesias | #define REG_ESR_MASK 0x8005 |
128 | e90e390c | Edgar E. Iglesias | #define REG_FSR_MASK 0x8007 |
129 | e90e390c | Edgar E. Iglesias | |
130 | e90e390c | Edgar E. Iglesias | #define MIN_REGNUM 0 |
131 | e90e390c | Edgar E. Iglesias | #define MAX_REGNUM 31 |
132 | e90e390c | Edgar E. Iglesias | |
133 | e90e390c | Edgar E. Iglesias | #define REG_PC 32 /* PC */ |
134 | e90e390c | Edgar E. Iglesias | #define REG_MSR 33 /* machine status reg */ |
135 | e90e390c | Edgar E. Iglesias | #define REG_EAR 35 /* Exception reg */ |
136 | e90e390c | Edgar E. Iglesias | #define REG_ESR 37 /* Exception reg */ |
137 | e90e390c | Edgar E. Iglesias | #define REG_FSR 39 /* FPU Status reg */ |
138 | e90e390c | Edgar E. Iglesias | |
139 | e90e390c | Edgar E. Iglesias | /* alternate names for gen purpose regs */
|
140 | e90e390c | Edgar E. Iglesias | #define REG_SP 1 /* stack pointer */ |
141 | e90e390c | Edgar E. Iglesias | #define REG_ROSDP 2 /* read-only small data pointer */ |
142 | e90e390c | Edgar E. Iglesias | #define REG_RWSDP 13 /* read-write small data pointer */ |
143 | e90e390c | Edgar E. Iglesias | |
144 | e90e390c | Edgar E. Iglesias | /* Assembler Register - Used in Delay Slot Optimization */
|
145 | e90e390c | Edgar E. Iglesias | #define REG_AS 18 |
146 | e90e390c | Edgar E. Iglesias | #define REG_ZERO 0 |
147 | e90e390c | Edgar E. Iglesias | |
148 | e90e390c | Edgar E. Iglesias | #define RD_LOW 21 /* low bit for RD */ |
149 | e90e390c | Edgar E. Iglesias | #define RA_LOW 16 /* low bit for RA */ |
150 | e90e390c | Edgar E. Iglesias | #define RB_LOW 11 /* low bit for RB */ |
151 | e90e390c | Edgar E. Iglesias | #define IMM_LOW 0 /* low bit for immediate */ |
152 | e90e390c | Edgar E. Iglesias | |
153 | e90e390c | Edgar E. Iglesias | #define RD_MASK 0x03E00000 |
154 | e90e390c | Edgar E. Iglesias | #define RA_MASK 0x001F0000 |
155 | e90e390c | Edgar E. Iglesias | #define RB_MASK 0x0000F800 |
156 | e90e390c | Edgar E. Iglesias | #define IMM_MASK 0x0000FFFF |
157 | e90e390c | Edgar E. Iglesias | |
158 | e90e390c | Edgar E. Iglesias | // imm mask for barrel shifts
|
159 | e90e390c | Edgar E. Iglesias | #define IMM5_MASK 0x0000001F |
160 | e90e390c | Edgar E. Iglesias | |
161 | e90e390c | Edgar E. Iglesias | |
162 | e90e390c | Edgar E. Iglesias | // imm mask for get, put instructions
|
163 | e90e390c | Edgar E. Iglesias | #define IMM12_MASK 0x00000FFF |
164 | e90e390c | Edgar E. Iglesias | |
165 | e90e390c | Edgar E. Iglesias | // imm mask for msrset, msrclr instructions
|
166 | e90e390c | Edgar E. Iglesias | #define IMM14_MASK 0x00003FFF |
167 | e90e390c | Edgar E. Iglesias | |
168 | e90e390c | Edgar E. Iglesias | #endif /* MICROBLAZE-OPCM */ |
169 | e90e390c | Edgar E. Iglesias | |
170 | e90e390c | Edgar E. Iglesias | #define INST_TYPE_RD_R1_R2 0 |
171 | e90e390c | Edgar E. Iglesias | #define INST_TYPE_RD_R1_IMM 1 |
172 | e90e390c | Edgar E. Iglesias | #define INST_TYPE_RD_R1_UNSIGNED_IMM 2 |
173 | e90e390c | Edgar E. Iglesias | #define INST_TYPE_RD_R1 3 |
174 | e90e390c | Edgar E. Iglesias | #define INST_TYPE_RD_R2 4 |
175 | e90e390c | Edgar E. Iglesias | #define INST_TYPE_RD_IMM 5 |
176 | e90e390c | Edgar E. Iglesias | #define INST_TYPE_R2 6 |
177 | e90e390c | Edgar E. Iglesias | #define INST_TYPE_R1_R2 7 |
178 | e90e390c | Edgar E. Iglesias | #define INST_TYPE_R1_IMM 8 |
179 | e90e390c | Edgar E. Iglesias | #define INST_TYPE_IMM 9 |
180 | e90e390c | Edgar E. Iglesias | #define INST_TYPE_SPECIAL_R1 10 |
181 | e90e390c | Edgar E. Iglesias | #define INST_TYPE_RD_SPECIAL 11 |
182 | e90e390c | Edgar E. Iglesias | #define INST_TYPE_R1 12 |
183 | e90e390c | Edgar E. Iglesias | // new instn type for barrel shift imms
|
184 | e90e390c | Edgar E. Iglesias | #define INST_TYPE_RD_R1_IMM5 13 |
185 | e90e390c | Edgar E. Iglesias | #define INST_TYPE_RD_IMM12 14 |
186 | e90e390c | Edgar E. Iglesias | #define INST_TYPE_R1_IMM12 15 |
187 | e90e390c | Edgar E. Iglesias | |
188 | e90e390c | Edgar E. Iglesias | // new insn type for insn cache
|
189 | e90e390c | Edgar E. Iglesias | #define INST_TYPE_RD_R1_SPECIAL 16 |
190 | e90e390c | Edgar E. Iglesias | |
191 | e90e390c | Edgar E. Iglesias | // new insn type for msrclr, msrset insns.
|
192 | e90e390c | Edgar E. Iglesias | #define INST_TYPE_RD_IMM14 17 |
193 | e90e390c | Edgar E. Iglesias | |
194 | e90e390c | Edgar E. Iglesias | // new insn type for tuqula rd - addik rd, r0, 42
|
195 | e90e390c | Edgar E. Iglesias | #define INST_TYPE_RD 18 |
196 | e90e390c | Edgar E. Iglesias | |
197 | e90e390c | Edgar E. Iglesias | #define INST_TYPE_NONE 25 |
198 | e90e390c | Edgar E. Iglesias | |
199 | e90e390c | Edgar E. Iglesias | |
200 | e90e390c | Edgar E. Iglesias | |
201 | e90e390c | Edgar E. Iglesias | #define INST_PC_OFFSET 1 /* instructions where the label address is resolved as a PC offset (for branch label)*/ |
202 | e90e390c | Edgar E. Iglesias | #define INST_NO_OFFSET 0 /* instructions where the label address is resolved as an absolute value (for data mem or abs address)*/ |
203 | e90e390c | Edgar E. Iglesias | |
204 | e90e390c | Edgar E. Iglesias | #define IMMVAL_MASK_NON_SPECIAL 0x0000 |
205 | e90e390c | Edgar E. Iglesias | #define IMMVAL_MASK_MTS 0x4000 |
206 | e90e390c | Edgar E. Iglesias | #define IMMVAL_MASK_MFS 0x0000 |
207 | e90e390c | Edgar E. Iglesias | |
208 | e90e390c | Edgar E. Iglesias | #define OPCODE_MASK_H 0xFC000000 /* High 6 bits only */ |
209 | e90e390c | Edgar E. Iglesias | #define OPCODE_MASK_H1 0xFFE00000 /* High 11 bits */ |
210 | e90e390c | Edgar E. Iglesias | #define OPCODE_MASK_H2 0xFC1F0000 /* High 6 and bits 20-16 */ |
211 | e90e390c | Edgar E. Iglesias | #define OPCODE_MASK_H12 0xFFFF0000 /* High 16 */ |
212 | e90e390c | Edgar E. Iglesias | #define OPCODE_MASK_H4 0xFC0007FF /* High 6 and low 11 bits */ |
213 | e90e390c | Edgar E. Iglesias | #define OPCODE_MASK_H13S 0xFFE0FFF0 /* High 11 and 15:1 bits and last nibble of last byte for spr */ |
214 | e90e390c | Edgar E. Iglesias | #define OPCODE_MASK_H23S 0xFC1FFFF0 /* High 6, 20-16 and 15:1 bits and last nibble of last byte for spr */ |
215 | e90e390c | Edgar E. Iglesias | #define OPCODE_MASK_H34 0xFC00FFFF /* High 6 and low 16 bits */ |
216 | e90e390c | Edgar E. Iglesias | #define OPCODE_MASK_H14 0xFFE007FF /* High 11 and low 11 bits */ |
217 | e90e390c | Edgar E. Iglesias | #define OPCODE_MASK_H24 0xFC1F07FF /* High 6, bits 20-16 and low 11 bits */ |
218 | e90e390c | Edgar E. Iglesias | #define OPCODE_MASK_H124 0xFFFF07FF /* High 16, and low 11 bits */ |
219 | e90e390c | Edgar E. Iglesias | #define OPCODE_MASK_H1234 0xFFFFFFFF /* All 32 bits */ |
220 | e90e390c | Edgar E. Iglesias | #define OPCODE_MASK_H3 0xFC000600 /* High 6 bits and bits 21, 22 */ |
221 | e90e390c | Edgar E. Iglesias | #define OPCODE_MASK_H32 0xFC00F000 /* High 6 bits and bit 16, 17, 18 and 19*/ |
222 | e90e390c | Edgar E. Iglesias | #define OPCODE_MASK_H34B 0xFC0000FF /* High 6 bits and low 8 bits */ |
223 | e90e390c | Edgar E. Iglesias | |
224 | e90e390c | Edgar E. Iglesias | // New Mask for msrset, msrclr insns.
|
225 | e90e390c | Edgar E. Iglesias | #define OPCODE_MASK_H23N 0xFC1FC000 /* High 6 and bits 12 - 18 */ |
226 | e90e390c | Edgar E. Iglesias | |
227 | e90e390c | Edgar E. Iglesias | #define DELAY_SLOT 1 |
228 | e90e390c | Edgar E. Iglesias | #define NO_DELAY_SLOT 0 |
229 | e90e390c | Edgar E. Iglesias | |
230 | e90e390c | Edgar E. Iglesias | #define MAX_OPCODES 149 |
231 | e90e390c | Edgar E. Iglesias | |
232 | e90e390c | Edgar E. Iglesias | struct op_code_struct {
|
233 | e90e390c | Edgar E. Iglesias | const char *name; |
234 | e90e390c | Edgar E. Iglesias | short inst_type; /* registers and immediate values involved */ |
235 | e90e390c | Edgar E. Iglesias | short inst_offset_type; /* immediate vals offset from PC? (= 1 for branches) */ |
236 | e90e390c | Edgar E. Iglesias | short delay_slots; /* info about delay slots needed after this instr. */ |
237 | e90e390c | Edgar E. Iglesias | short immval_mask;
|
238 | e90e390c | Edgar E. Iglesias | unsigned long bit_sequence; /* all the fixed bits for the op are set and all the variable bits (reg names, imm vals) are set to 0 */ |
239 | e90e390c | Edgar E. Iglesias | unsigned long opcode_mask; /* which bits define the opcode */ |
240 | e90e390c | Edgar E. Iglesias | enum microblaze_instr instr;
|
241 | e90e390c | Edgar E. Iglesias | enum microblaze_instr_type instr_type;
|
242 | e90e390c | Edgar E. Iglesias | /* more info about output format here */
|
243 | e90e390c | Edgar E. Iglesias | } opcodes[MAX_OPCODES] = |
244 | e90e390c | Edgar E. Iglesias | |
245 | e90e390c | Edgar E. Iglesias | { |
246 | e90e390c | Edgar E. Iglesias | {"add", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x00000000, OPCODE_MASK_H4, add, arithmetic_inst }, |
247 | e90e390c | Edgar E. Iglesias | {"rsub", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x04000000, OPCODE_MASK_H4, rsub, arithmetic_inst }, |
248 | e90e390c | Edgar E. Iglesias | {"addc", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x08000000, OPCODE_MASK_H4, addc, arithmetic_inst }, |
249 | e90e390c | Edgar E. Iglesias | {"rsubc", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x0C000000, OPCODE_MASK_H4, rsubc, arithmetic_inst }, |
250 | e90e390c | Edgar E. Iglesias | {"addk", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x10000000, OPCODE_MASK_H4, addk, arithmetic_inst }, |
251 | e90e390c | Edgar E. Iglesias | {"rsubk", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x14000000, OPCODE_MASK_H4, rsubk, arithmetic_inst }, |
252 | e90e390c | Edgar E. Iglesias | {"cmp", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x14000001, OPCODE_MASK_H4, cmp, arithmetic_inst }, |
253 | e90e390c | Edgar E. Iglesias | {"cmpu", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x14000003, OPCODE_MASK_H4, cmpu, arithmetic_inst }, |
254 | e90e390c | Edgar E. Iglesias | {"addkc", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x18000000, OPCODE_MASK_H4, addkc, arithmetic_inst }, |
255 | e90e390c | Edgar E. Iglesias | {"rsubkc",INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x1C000000, OPCODE_MASK_H4, rsubkc, arithmetic_inst }, |
256 | e90e390c | Edgar E. Iglesias | {"addi", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x20000000, OPCODE_MASK_H, addi, arithmetic_inst }, |
257 | e90e390c | Edgar E. Iglesias | {"rsubi", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x24000000, OPCODE_MASK_H, rsubi, arithmetic_inst }, |
258 | e90e390c | Edgar E. Iglesias | {"addic", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x28000000, OPCODE_MASK_H, addic, arithmetic_inst }, |
259 | e90e390c | Edgar E. Iglesias | {"rsubic",INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x2C000000, OPCODE_MASK_H, rsubic, arithmetic_inst }, |
260 | e90e390c | Edgar E. Iglesias | {"addik", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x30000000, OPCODE_MASK_H, addik, arithmetic_inst }, |
261 | e90e390c | Edgar E. Iglesias | {"rsubik",INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x34000000, OPCODE_MASK_H, rsubik, arithmetic_inst }, |
262 | e90e390c | Edgar E. Iglesias | {"addikc",INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x38000000, OPCODE_MASK_H, addikc, arithmetic_inst }, |
263 | e90e390c | Edgar E. Iglesias | {"rsubikc",INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x3C000000, OPCODE_MASK_H, rsubikc, arithmetic_inst }, |
264 | e90e390c | Edgar E. Iglesias | {"mul", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x40000000, OPCODE_MASK_H4, mul, mult_inst }, |
265 | e90e390c | Edgar E. Iglesias | {"idiv", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x48000000, OPCODE_MASK_H4, idiv, div_inst }, |
266 | e90e390c | Edgar E. Iglesias | {"idivu", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x48000002, OPCODE_MASK_H4, idivu, div_inst }, |
267 | e90e390c | Edgar E. Iglesias | {"bsll", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x44000400, OPCODE_MASK_H3, bsll, barrel_shift_inst }, |
268 | e90e390c | Edgar E. Iglesias | {"bsra", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x44000200, OPCODE_MASK_H3, bsra, barrel_shift_inst }, |
269 | e90e390c | Edgar E. Iglesias | {"bsrl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x44000000, OPCODE_MASK_H3, bsrl, barrel_shift_inst }, |
270 | e90e390c | Edgar E. Iglesias | {"get", INST_TYPE_RD_IMM12, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x6C000000, OPCODE_MASK_H32, get, anyware_inst }, |
271 | e90e390c | Edgar E. Iglesias | {"put", INST_TYPE_R1_IMM12, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x6C008000, OPCODE_MASK_H32, put, anyware_inst }, |
272 | e90e390c | Edgar E. Iglesias | {"nget", INST_TYPE_RD_IMM12, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x6C004000, OPCODE_MASK_H32, nget, anyware_inst }, |
273 | e90e390c | Edgar E. Iglesias | {"nput", INST_TYPE_R1_IMM12, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x6C00C000, OPCODE_MASK_H32, nput, anyware_inst }, |
274 | e90e390c | Edgar E. Iglesias | {"cget", INST_TYPE_RD_IMM12, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x6C002000, OPCODE_MASK_H32, cget, anyware_inst }, |
275 | e90e390c | Edgar E. Iglesias | {"cput", INST_TYPE_R1_IMM12, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x6C00A000, OPCODE_MASK_H32, cput, anyware_inst }, |
276 | e90e390c | Edgar E. Iglesias | {"ncget", INST_TYPE_RD_IMM12, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x6C006000, OPCODE_MASK_H32, ncget, anyware_inst }, |
277 | e90e390c | Edgar E. Iglesias | {"ncput", INST_TYPE_R1_IMM12, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x6C00E000, OPCODE_MASK_H32, ncput, anyware_inst }, |
278 | e90e390c | Edgar E. Iglesias | {"muli", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x60000000, OPCODE_MASK_H, muli, mult_inst }, |
279 | e90e390c | Edgar E. Iglesias | {"bslli", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000400, OPCODE_MASK_H3, bslli, barrel_shift_inst }, |
280 | e90e390c | Edgar E. Iglesias | {"bsrai", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000200, OPCODE_MASK_H3, bsrai, barrel_shift_inst }, |
281 | e90e390c | Edgar E. Iglesias | {"bsrli", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000000, OPCODE_MASK_H3, bsrli, barrel_shift_inst }, |
282 | e90e390c | Edgar E. Iglesias | {"or", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x80000000, OPCODE_MASK_H4, or, logical_inst }, |
283 | e90e390c | Edgar E. Iglesias | {"and", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x84000000, OPCODE_MASK_H4, and, logical_inst }, |
284 | e90e390c | Edgar E. Iglesias | {"xor", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x88000000, OPCODE_MASK_H4, xor, logical_inst }, |
285 | e90e390c | Edgar E. Iglesias | {"andn", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x8C000000, OPCODE_MASK_H4, andn, logical_inst }, |
286 | e90e390c | Edgar E. Iglesias | {"pcmpbf",INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x80000400, OPCODE_MASK_H4, pcmpbf, logical_inst }, |
287 | e90e390c | Edgar E. Iglesias | {"pcmpbc",INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x84000400, OPCODE_MASK_H4, pcmpbc, logical_inst }, |
288 | e90e390c | Edgar E. Iglesias | {"pcmpeq",INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x88000400, OPCODE_MASK_H4, pcmpeq, logical_inst }, |
289 | e90e390c | Edgar E. Iglesias | {"pcmpne",INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x8C000400, OPCODE_MASK_H4, pcmpne, logical_inst }, |
290 | e90e390c | Edgar E. Iglesias | {"sra", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000001, OPCODE_MASK_H34, sra, logical_inst }, |
291 | e90e390c | Edgar E. Iglesias | {"src", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000021, OPCODE_MASK_H34, src, logical_inst }, |
292 | e90e390c | Edgar E. Iglesias | {"srl", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000041, OPCODE_MASK_H34, srl, logical_inst }, |
293 | e90e390c | Edgar E. Iglesias | {"sext8", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000060, OPCODE_MASK_H34, sext8, logical_inst }, |
294 | e90e390c | Edgar E. Iglesias | {"sext16",INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000061, OPCODE_MASK_H34, sext16, logical_inst }, |
295 | e90e390c | Edgar E. Iglesias | {"wic", INST_TYPE_RD_R1_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000068, OPCODE_MASK_H34B, wic, special_inst }, |
296 | e90e390c | Edgar E. Iglesias | {"wdc", INST_TYPE_RD_R1_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000064, OPCODE_MASK_H34B, wdc, special_inst }, |
297 | e90e390c | Edgar E. Iglesias | {"mts", INST_TYPE_SPECIAL_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_MTS, 0x9400C000, OPCODE_MASK_H13S, mts, special_inst }, |
298 | e90e390c | Edgar E. Iglesias | {"mfs", INST_TYPE_RD_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_MFS, 0x94008000, OPCODE_MASK_H23S, mfs, special_inst }, |
299 | e90e390c | Edgar E. Iglesias | {"br", INST_TYPE_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x98000000, OPCODE_MASK_H124, br, branch_inst }, |
300 | e90e390c | Edgar E. Iglesias | {"brd", INST_TYPE_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x98100000, OPCODE_MASK_H124, brd, branch_inst }, |
301 | e90e390c | Edgar E. Iglesias | {"brld", INST_TYPE_RD_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x98140000, OPCODE_MASK_H24, brld, branch_inst }, |
302 | e90e390c | Edgar E. Iglesias | {"bra", INST_TYPE_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x98080000, OPCODE_MASK_H124, bra, branch_inst }, |
303 | e90e390c | Edgar E. Iglesias | {"brad", INST_TYPE_R2, INST_NO_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x98180000, OPCODE_MASK_H124, brad, branch_inst }, |
304 | e90e390c | Edgar E. Iglesias | {"brald", INST_TYPE_RD_R2, INST_NO_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x981C0000, OPCODE_MASK_H24, brald, branch_inst }, |
305 | e90e390c | Edgar E. Iglesias | {"brk", INST_TYPE_RD_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x980C0000, OPCODE_MASK_H24, microblaze_brk, branch_inst }, |
306 | e90e390c | Edgar E. Iglesias | {"beq", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9C000000, OPCODE_MASK_H14, beq, branch_inst }, |
307 | e90e390c | Edgar E. Iglesias | {"beqd", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9E000000, OPCODE_MASK_H14, beqd, branch_inst }, |
308 | e90e390c | Edgar E. Iglesias | {"bne", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9C200000, OPCODE_MASK_H14, bne, branch_inst }, |
309 | e90e390c | Edgar E. Iglesias | {"bned", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9E200000, OPCODE_MASK_H14, bned, branch_inst }, |
310 | e90e390c | Edgar E. Iglesias | {"blt", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9C400000, OPCODE_MASK_H14, blt, branch_inst }, |
311 | e90e390c | Edgar E. Iglesias | {"bltd", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9E400000, OPCODE_MASK_H14, bltd, branch_inst }, |
312 | e90e390c | Edgar E. Iglesias | {"ble", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9C600000, OPCODE_MASK_H14, ble, branch_inst }, |
313 | e90e390c | Edgar E. Iglesias | {"bled", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9E600000, OPCODE_MASK_H14, bled, branch_inst }, |
314 | e90e390c | Edgar E. Iglesias | {"bgt", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9C800000, OPCODE_MASK_H14, bgt, branch_inst }, |
315 | e90e390c | Edgar E. Iglesias | {"bgtd", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9E800000, OPCODE_MASK_H14, bgtd, branch_inst }, |
316 | e90e390c | Edgar E. Iglesias | {"bge", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9CA00000, OPCODE_MASK_H14, bge, branch_inst }, |
317 | e90e390c | Edgar E. Iglesias | {"bged", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9EA00000, OPCODE_MASK_H14, bged, branch_inst }, |
318 | e90e390c | Edgar E. Iglesias | {"ori", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xA0000000, OPCODE_MASK_H, ori, logical_inst }, |
319 | e90e390c | Edgar E. Iglesias | {"andi", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xA4000000, OPCODE_MASK_H, andi, logical_inst }, |
320 | e90e390c | Edgar E. Iglesias | {"xori", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xA8000000, OPCODE_MASK_H, xori, logical_inst }, |
321 | e90e390c | Edgar E. Iglesias | {"andni", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xAC000000, OPCODE_MASK_H, andni, logical_inst }, |
322 | e90e390c | Edgar E. Iglesias | {"imm", INST_TYPE_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB0000000, OPCODE_MASK_H12, imm, immediate_inst }, |
323 | e90e390c | Edgar E. Iglesias | {"rtsd", INST_TYPE_R1_IMM, INST_NO_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB6000000, OPCODE_MASK_H1, rtsd, return_inst }, |
324 | e90e390c | Edgar E. Iglesias | {"rtid", INST_TYPE_R1_IMM, INST_NO_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB6200000, OPCODE_MASK_H1, rtid, return_inst }, |
325 | e90e390c | Edgar E. Iglesias | {"rtbd", INST_TYPE_R1_IMM, INST_NO_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB6400000, OPCODE_MASK_H1, rtbd, return_inst }, |
326 | e90e390c | Edgar E. Iglesias | {"rted", INST_TYPE_R1_IMM, INST_NO_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB6800000, OPCODE_MASK_H1, rted, return_inst }, |
327 | e90e390c | Edgar E. Iglesias | {"bri", INST_TYPE_IMM, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB8000000, OPCODE_MASK_H12, bri, branch_inst }, |
328 | e90e390c | Edgar E. Iglesias | {"brid", INST_TYPE_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB8100000, OPCODE_MASK_H12, brid, branch_inst }, |
329 | e90e390c | Edgar E. Iglesias | {"brlid", INST_TYPE_RD_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB8140000, OPCODE_MASK_H2, brlid, branch_inst }, |
330 | e90e390c | Edgar E. Iglesias | {"brai", INST_TYPE_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB8080000, OPCODE_MASK_H12, brai, branch_inst }, |
331 | e90e390c | Edgar E. Iglesias | {"braid", INST_TYPE_IMM, INST_NO_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB8180000, OPCODE_MASK_H12, braid, branch_inst }, |
332 | e90e390c | Edgar E. Iglesias | {"bralid",INST_TYPE_RD_IMM, INST_NO_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB81C0000, OPCODE_MASK_H2, bralid, branch_inst }, |
333 | e90e390c | Edgar E. Iglesias | {"brki", INST_TYPE_RD_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB80C0000, OPCODE_MASK_H2, brki, branch_inst }, |
334 | e90e390c | Edgar E. Iglesias | {"beqi", INST_TYPE_R1_IMM, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBC000000, OPCODE_MASK_H1, beqi, branch_inst }, |
335 | e90e390c | Edgar E. Iglesias | {"beqid", INST_TYPE_R1_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBE000000, OPCODE_MASK_H1, beqid, branch_inst }, |
336 | e90e390c | Edgar E. Iglesias | {"bnei", INST_TYPE_R1_IMM, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBC200000, OPCODE_MASK_H1, bnei, branch_inst }, |
337 | e90e390c | Edgar E. Iglesias | {"bneid", INST_TYPE_R1_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBE200000, OPCODE_MASK_H1, bneid, branch_inst }, |
338 | e90e390c | Edgar E. Iglesias | {"blti", INST_TYPE_R1_IMM, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBC400000, OPCODE_MASK_H1, blti, branch_inst }, |
339 | e90e390c | Edgar E. Iglesias | {"bltid", INST_TYPE_R1_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBE400000, OPCODE_MASK_H1, bltid, branch_inst }, |
340 | e90e390c | Edgar E. Iglesias | {"blei", INST_TYPE_R1_IMM, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBC600000, OPCODE_MASK_H1, blei, branch_inst }, |
341 | e90e390c | Edgar E. Iglesias | {"bleid", INST_TYPE_R1_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBE600000, OPCODE_MASK_H1, bleid, branch_inst }, |
342 | e90e390c | Edgar E. Iglesias | {"bgti", INST_TYPE_R1_IMM, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBC800000, OPCODE_MASK_H1, bgti, branch_inst }, |
343 | e90e390c | Edgar E. Iglesias | {"bgtid", INST_TYPE_R1_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBE800000, OPCODE_MASK_H1, bgtid, branch_inst }, |
344 | e90e390c | Edgar E. Iglesias | {"bgei", INST_TYPE_R1_IMM, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBCA00000, OPCODE_MASK_H1, bgei, branch_inst }, |
345 | e90e390c | Edgar E. Iglesias | {"bgeid", INST_TYPE_R1_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBEA00000, OPCODE_MASK_H1, bgeid, branch_inst }, |
346 | e90e390c | Edgar E. Iglesias | {"lbu", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC0000000, OPCODE_MASK_H4, lbu, memory_load_inst }, |
347 | e90e390c | Edgar E. Iglesias | {"lhu", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC4000000, OPCODE_MASK_H4, lhu, memory_load_inst }, |
348 | e90e390c | Edgar E. Iglesias | {"lw", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC8000000, OPCODE_MASK_H4, lw, memory_load_inst }, |
349 | e90e390c | Edgar E. Iglesias | {"sb", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD0000000, OPCODE_MASK_H4, sb, memory_store_inst }, |
350 | e90e390c | Edgar E. Iglesias | {"sh", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD4000000, OPCODE_MASK_H4, sh, memory_store_inst }, |
351 | e90e390c | Edgar E. Iglesias | {"sw", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD8000000, OPCODE_MASK_H4, sw, memory_store_inst }, |
352 | e90e390c | Edgar E. Iglesias | {"lbui", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xE0000000, OPCODE_MASK_H, lbui, memory_load_inst }, |
353 | e90e390c | Edgar E. Iglesias | {"lhui", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xE4000000, OPCODE_MASK_H, lhui, memory_load_inst }, |
354 | e90e390c | Edgar E. Iglesias | {"lwi", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xE8000000, OPCODE_MASK_H, lwi, memory_load_inst }, |
355 | e90e390c | Edgar E. Iglesias | {"sbi", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xF0000000, OPCODE_MASK_H, sbi, memory_store_inst }, |
356 | e90e390c | Edgar E. Iglesias | {"shi", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xF4000000, OPCODE_MASK_H, shi, memory_store_inst }, |
357 | e90e390c | Edgar E. Iglesias | {"swi", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xF8000000, OPCODE_MASK_H, swi, memory_store_inst }, |
358 | e90e390c | Edgar E. Iglesias | {"nop", INST_TYPE_NONE, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x80000000, OPCODE_MASK_H1234, invalid_inst, logical_inst }, /* translates to or r0, r0, r0 */ |
359 | e90e390c | Edgar E. Iglesias | {"la", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x30000000, OPCODE_MASK_H, invalid_inst, arithmetic_inst }, /* la translates to addik */ |
360 | e90e390c | Edgar E. Iglesias | {"tuqula",INST_TYPE_RD, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x3000002A, OPCODE_MASK_H, invalid_inst, arithmetic_inst }, /* tuqula rd translates to addik rd, r0, 42 */ |
361 | e90e390c | Edgar E. Iglesias | {"not", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xA800FFFF, OPCODE_MASK_H34, invalid_inst, logical_inst }, /* not translates to xori rd,ra,-1 */ |
362 | e90e390c | Edgar E. Iglesias | {"neg", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x04000000, OPCODE_MASK_H, invalid_inst, arithmetic_inst }, /* neg translates to rsub rd, ra, r0 */ |
363 | e90e390c | Edgar E. Iglesias | {"rtb", INST_TYPE_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB6000004, OPCODE_MASK_H1, invalid_inst, return_inst }, /* rtb translates to rts rd, 4 */ |
364 | e90e390c | Edgar E. Iglesias | {"sub", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x04000000, OPCODE_MASK_H, invalid_inst, arithmetic_inst }, /* sub translates to rsub rd, rb, ra */ |
365 | e90e390c | Edgar E. Iglesias | {"lmi", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xE8000000, OPCODE_MASK_H, invalid_inst, memory_load_inst }, |
366 | e90e390c | Edgar E. Iglesias | {"smi", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xF8000000, OPCODE_MASK_H, invalid_inst, memory_store_inst }, |
367 | e90e390c | Edgar E. Iglesias | {"msrset",INST_TYPE_RD_IMM14, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x94100000, OPCODE_MASK_H23N, msrset, special_inst }, |
368 | e90e390c | Edgar E. Iglesias | {"msrclr",INST_TYPE_RD_IMM14, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x94110000, OPCODE_MASK_H23N, msrclr, special_inst }, |
369 | e90e390c | Edgar E. Iglesias | {"fadd", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000000, OPCODE_MASK_H4, fadd, arithmetic_inst }, |
370 | e90e390c | Edgar E. Iglesias | {"frsub", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000080, OPCODE_MASK_H4, frsub, arithmetic_inst }, |
371 | e90e390c | Edgar E. Iglesias | {"fmul", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000100, OPCODE_MASK_H4, fmul, arithmetic_inst }, |
372 | e90e390c | Edgar E. Iglesias | {"fdiv", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000180, OPCODE_MASK_H4, fdiv, arithmetic_inst }, |
373 | e90e390c | Edgar E. Iglesias | {"fcmp.lt", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000210, OPCODE_MASK_H4, fcmp_lt, arithmetic_inst }, |
374 | e90e390c | Edgar E. Iglesias | {"fcmp.eq", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000220, OPCODE_MASK_H4, fcmp_eq, arithmetic_inst }, |
375 | e90e390c | Edgar E. Iglesias | {"fcmp.le", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000230, OPCODE_MASK_H4, fcmp_le, arithmetic_inst }, |
376 | e90e390c | Edgar E. Iglesias | {"fcmp.gt", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000240, OPCODE_MASK_H4, fcmp_gt, arithmetic_inst }, |
377 | e90e390c | Edgar E. Iglesias | {"fcmp.ne", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000250, OPCODE_MASK_H4, fcmp_ne, arithmetic_inst }, |
378 | e90e390c | Edgar E. Iglesias | {"fcmp.ge", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000260, OPCODE_MASK_H4, fcmp_ge, arithmetic_inst }, |
379 | e90e390c | Edgar E. Iglesias | {"fcmp.un", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000200, OPCODE_MASK_H4, fcmp_un, arithmetic_inst }, |
380 | e90e390c | Edgar E. Iglesias | {""}
|
381 | e90e390c | Edgar E. Iglesias | }; |
382 | e90e390c | Edgar E. Iglesias | |
383 | e90e390c | Edgar E. Iglesias | /* prefix for register names */
|
384 | e90e390c | Edgar E. Iglesias | char register_prefix[] = "r"; |
385 | e90e390c | Edgar E. Iglesias | char special_register_prefix[] = "spr"; |
386 | e90e390c | Edgar E. Iglesias | char fsl_register_prefix[] = "rfsl"; |
387 | e90e390c | Edgar E. Iglesias | |
388 | e90e390c | Edgar E. Iglesias | |
389 | e90e390c | Edgar E. Iglesias | /* #defines for valid immediate range */
|
390 | e90e390c | Edgar E. Iglesias | #define MIN_IMM 0x80000000 |
391 | e90e390c | Edgar E. Iglesias | #define MAX_IMM 0x7fffffff |
392 | e90e390c | Edgar E. Iglesias | |
393 | e90e390c | Edgar E. Iglesias | #define MIN_IMM12 0x000 |
394 | e90e390c | Edgar E. Iglesias | #define MAX_IMM12 0x7ff |
395 | e90e390c | Edgar E. Iglesias | |
396 | e90e390c | Edgar E. Iglesias | #define MIN_IMM14 0x0000 |
397 | e90e390c | Edgar E. Iglesias | #define MAX_IMM14 0x1fff |
398 | e90e390c | Edgar E. Iglesias | |
399 | e90e390c | Edgar E. Iglesias | #endif /* MICROBLAZE_OPC */ |
400 | e90e390c | Edgar E. Iglesias | |
401 | e90e390c | Edgar E. Iglesias | #include "dis-asm.h" |
402 | e90e390c | Edgar E. Iglesias | #include <strings.h> |
403 | e90e390c | Edgar E. Iglesias | |
404 | e90e390c | Edgar E. Iglesias | #define get_field_rd(instr) get_field(instr, RD_MASK, RD_LOW)
|
405 | e90e390c | Edgar E. Iglesias | #define get_field_r1(instr) get_field(instr, RA_MASK, RA_LOW)
|
406 | e90e390c | Edgar E. Iglesias | #define get_field_r2(instr) get_field(instr, RB_MASK, RB_LOW)
|
407 | e90e390c | Edgar E. Iglesias | #define get_int_field_imm(instr) ((instr & IMM_MASK) >> IMM_LOW)
|
408 | e90e390c | Edgar E. Iglesias | #define get_int_field_r1(instr) ((instr & RA_MASK) >> RA_LOW)
|
409 | e90e390c | Edgar E. Iglesias | |
410 | e90e390c | Edgar E. Iglesias | static char * |
411 | e90e390c | Edgar E. Iglesias | get_field (long instr, long mask, unsigned short low) |
412 | e90e390c | Edgar E. Iglesias | { |
413 | e90e390c | Edgar E. Iglesias | char tmpstr[25]; |
414 | e90e390c | Edgar E. Iglesias | sprintf(tmpstr, "%s%d", register_prefix, (int)((instr & mask) >> low)); |
415 | e90e390c | Edgar E. Iglesias | return(strdup(tmpstr));
|
416 | e90e390c | Edgar E. Iglesias | } |
417 | e90e390c | Edgar E. Iglesias | |
418 | e90e390c | Edgar E. Iglesias | static char * |
419 | e90e390c | Edgar E. Iglesias | get_field_imm (long instr)
|
420 | e90e390c | Edgar E. Iglesias | { |
421 | e90e390c | Edgar E. Iglesias | char tmpstr[25]; |
422 | e90e390c | Edgar E. Iglesias | sprintf(tmpstr, "%d", (short)((instr & IMM_MASK) >> IMM_LOW)); |
423 | e90e390c | Edgar E. Iglesias | return(strdup(tmpstr));
|
424 | e90e390c | Edgar E. Iglesias | } |
425 | e90e390c | Edgar E. Iglesias | |
426 | e90e390c | Edgar E. Iglesias | static char * |
427 | e90e390c | Edgar E. Iglesias | get_field_imm5 (long instr)
|
428 | e90e390c | Edgar E. Iglesias | { |
429 | e90e390c | Edgar E. Iglesias | char tmpstr[25]; |
430 | e90e390c | Edgar E. Iglesias | sprintf(tmpstr, "%d", (short)((instr & IMM5_MASK) >> IMM_LOW)); |
431 | e90e390c | Edgar E. Iglesias | return(strdup(tmpstr));
|
432 | e90e390c | Edgar E. Iglesias | } |
433 | e90e390c | Edgar E. Iglesias | |
434 | e90e390c | Edgar E. Iglesias | static char * |
435 | e90e390c | Edgar E. Iglesias | get_field_imm12 (long instr)
|
436 | e90e390c | Edgar E. Iglesias | { |
437 | e90e390c | Edgar E. Iglesias | char tmpstr[25]; |
438 | e90e390c | Edgar E. Iglesias | sprintf(tmpstr, "%s%d", fsl_register_prefix, (short)((instr & IMM12_MASK) >> IMM_LOW)); |
439 | e90e390c | Edgar E. Iglesias | return(strdup(tmpstr));
|
440 | e90e390c | Edgar E. Iglesias | } |
441 | e90e390c | Edgar E. Iglesias | |
442 | e90e390c | Edgar E. Iglesias | static char * |
443 | e90e390c | Edgar E. Iglesias | get_field_imm14 (long instr)
|
444 | e90e390c | Edgar E. Iglesias | { |
445 | e90e390c | Edgar E. Iglesias | char tmpstr[25]; |
446 | e90e390c | Edgar E. Iglesias | sprintf(tmpstr, "%d", (short)((instr & IMM14_MASK) >> IMM_LOW)); |
447 | e90e390c | Edgar E. Iglesias | return(strdup(tmpstr));
|
448 | e90e390c | Edgar E. Iglesias | } |
449 | e90e390c | Edgar E. Iglesias | |
450 | e90e390c | Edgar E. Iglesias | #if 0
|
451 | e90e390c | Edgar E. Iglesias | static char *
|
452 | e90e390c | Edgar E. Iglesias | get_field_unsigned_imm (long instr)
|
453 | e90e390c | Edgar E. Iglesias | {
|
454 | e90e390c | Edgar E. Iglesias | char tmpstr[25];
|
455 | e90e390c | Edgar E. Iglesias | sprintf(tmpstr, "%d", (int)((instr & IMM_MASK) >> IMM_LOW));
|
456 | e90e390c | Edgar E. Iglesias | return(strdup(tmpstr));
|
457 | e90e390c | Edgar E. Iglesias | }
|
458 | e90e390c | Edgar E. Iglesias | #endif
|
459 | e90e390c | Edgar E. Iglesias | |
460 | e90e390c | Edgar E. Iglesias | /*
|
461 | e90e390c | Edgar E. Iglesias | char *
|
462 | e90e390c | Edgar E. Iglesias | get_field_special (instr)
|
463 | e90e390c | Edgar E. Iglesias | long instr;
|
464 | e90e390c | Edgar E. Iglesias | {
|
465 | e90e390c | Edgar E. Iglesias | char tmpstr[25];
|
466 | e90e390c | Edgar E. Iglesias |
|
467 | e90e390c | Edgar E. Iglesias | sprintf(tmpstr, "%s%s", register_prefix, (((instr & IMM_MASK) >> IMM_LOW) & REG_MSR_MASK) == 0 ? "pc" : "msr");
|
468 | e90e390c | Edgar E. Iglesias |
|
469 | e90e390c | Edgar E. Iglesias | return(strdup(tmpstr));
|
470 | e90e390c | Edgar E. Iglesias | }
|
471 | e90e390c | Edgar E. Iglesias | */
|
472 | e90e390c | Edgar E. Iglesias | |
473 | e90e390c | Edgar E. Iglesias | static char * |
474 | e90e390c | Edgar E. Iglesias | get_field_special (long instr, struct op_code_struct * op) |
475 | e90e390c | Edgar E. Iglesias | { |
476 | e90e390c | Edgar E. Iglesias | char tmpstr[25]; |
477 | e90e390c | Edgar E. Iglesias | char spr[5]; |
478 | e90e390c | Edgar E. Iglesias | |
479 | e90e390c | Edgar E. Iglesias | switch ( (((instr & IMM_MASK) >> IMM_LOW) ^ op->immval_mask) ) {
|
480 | e90e390c | Edgar E. Iglesias | case REG_MSR_MASK :
|
481 | e90e390c | Edgar E. Iglesias | strcpy(spr, "msr");
|
482 | e90e390c | Edgar E. Iglesias | break;
|
483 | e90e390c | Edgar E. Iglesias | case REG_PC_MASK :
|
484 | e90e390c | Edgar E. Iglesias | strcpy(spr, "pc");
|
485 | e90e390c | Edgar E. Iglesias | break;
|
486 | e90e390c | Edgar E. Iglesias | case REG_EAR_MASK :
|
487 | e90e390c | Edgar E. Iglesias | strcpy(spr, "ear");
|
488 | e90e390c | Edgar E. Iglesias | break;
|
489 | e90e390c | Edgar E. Iglesias | case REG_ESR_MASK :
|
490 | e90e390c | Edgar E. Iglesias | strcpy(spr, "esr");
|
491 | e90e390c | Edgar E. Iglesias | break;
|
492 | e90e390c | Edgar E. Iglesias | case REG_FSR_MASK :
|
493 | e90e390c | Edgar E. Iglesias | strcpy(spr, "fsr");
|
494 | e90e390c | Edgar E. Iglesias | break;
|
495 | e90e390c | Edgar E. Iglesias | default :
|
496 | e90e390c | Edgar E. Iglesias | strcpy(spr, "pc");
|
497 | e90e390c | Edgar E. Iglesias | break;
|
498 | e90e390c | Edgar E. Iglesias | } |
499 | e90e390c | Edgar E. Iglesias | |
500 | e90e390c | Edgar E. Iglesias | sprintf(tmpstr, "%s%s", register_prefix, spr);
|
501 | e90e390c | Edgar E. Iglesias | return(strdup(tmpstr));
|
502 | e90e390c | Edgar E. Iglesias | } |
503 | e90e390c | Edgar E. Iglesias | |
504 | e90e390c | Edgar E. Iglesias | static unsigned long |
505 | e90e390c | Edgar E. Iglesias | read_insn_microblaze(bfd_vma memaddr, struct disassemble_info *info,
|
506 | e90e390c | Edgar E. Iglesias | struct op_code_struct ** opr)
|
507 | e90e390c | Edgar E. Iglesias | { |
508 | e90e390c | Edgar E. Iglesias | unsigned char ibytes[4]; |
509 | e90e390c | Edgar E. Iglesias | int status;
|
510 | e90e390c | Edgar E. Iglesias | struct op_code_struct * op;
|
511 | e90e390c | Edgar E. Iglesias | unsigned long inst; |
512 | e90e390c | Edgar E. Iglesias | |
513 | e90e390c | Edgar E. Iglesias | status = info->read_memory_func (memaddr, ibytes, 4, info);
|
514 | e90e390c | Edgar E. Iglesias | |
515 | e90e390c | Edgar E. Iglesias | if (status != 0) |
516 | e90e390c | Edgar E. Iglesias | { |
517 | e90e390c | Edgar E. Iglesias | info->memory_error_func (status, memaddr, info); |
518 | e90e390c | Edgar E. Iglesias | return 0; |
519 | e90e390c | Edgar E. Iglesias | } |
520 | e90e390c | Edgar E. Iglesias | |
521 | e90e390c | Edgar E. Iglesias | if (info->endian == BFD_ENDIAN_BIG)
|
522 | e90e390c | Edgar E. Iglesias | inst = (ibytes[0] << 24) | (ibytes[1] << 16) | (ibytes[2] << 8) | ibytes[3]; |
523 | e90e390c | Edgar E. Iglesias | else if (info->endian == BFD_ENDIAN_LITTLE) |
524 | e90e390c | Edgar E. Iglesias | inst = (ibytes[3] << 24) | (ibytes[2] << 16) | (ibytes[1] << 8) | ibytes[0]; |
525 | e90e390c | Edgar E. Iglesias | else
|
526 | e90e390c | Edgar E. Iglesias | abort (); |
527 | e90e390c | Edgar E. Iglesias | |
528 | e90e390c | Edgar E. Iglesias | /* Just a linear search of the table. */
|
529 | e90e390c | Edgar E. Iglesias | for (op = opcodes; op->name != 0; op ++) |
530 | e90e390c | Edgar E. Iglesias | if (op->bit_sequence == (inst & op->opcode_mask))
|
531 | e90e390c | Edgar E. Iglesias | break;
|
532 | e90e390c | Edgar E. Iglesias | |
533 | e90e390c | Edgar E. Iglesias | *opr = op; |
534 | e90e390c | Edgar E. Iglesias | return inst;
|
535 | e90e390c | Edgar E. Iglesias | } |
536 | e90e390c | Edgar E. Iglesias | |
537 | e90e390c | Edgar E. Iglesias | |
538 | e90e390c | Edgar E. Iglesias | int
|
539 | e90e390c | Edgar E. Iglesias | print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info)
|
540 | e90e390c | Edgar E. Iglesias | { |
541 | e90e390c | Edgar E. Iglesias | fprintf_ftype fprintf = info->fprintf_func; |
542 | e90e390c | Edgar E. Iglesias | void * stream = info->stream;
|
543 | e90e390c | Edgar E. Iglesias | unsigned long inst, prev_inst; |
544 | e90e390c | Edgar E. Iglesias | struct op_code_struct * op, *pop;
|
545 | e90e390c | Edgar E. Iglesias | int immval = 0; |
546 | e90e390c | Edgar E. Iglesias | boolean immfound = false;
|
547 | e90e390c | Edgar E. Iglesias | static bfd_vma prev_insn_addr = -1; /*init the prev insn addr */ |
548 | e90e390c | Edgar E. Iglesias | static int prev_insn_vma = -1; /*init the prev insn vma */ |
549 | e90e390c | Edgar E. Iglesias | int curr_insn_vma = info->buffer_vma;
|
550 | e90e390c | Edgar E. Iglesias | |
551 | e90e390c | Edgar E. Iglesias | info->bytes_per_chunk = 4;
|
552 | e90e390c | Edgar E. Iglesias | |
553 | e90e390c | Edgar E. Iglesias | inst = read_insn_microblaze (memaddr, info, &op); |
554 | e90e390c | Edgar E. Iglesias | if (inst == 0) |
555 | e90e390c | Edgar E. Iglesias | return -1; |
556 | e90e390c | Edgar E. Iglesias | |
557 | e90e390c | Edgar E. Iglesias | if (prev_insn_vma == curr_insn_vma) {
|
558 | e90e390c | Edgar E. Iglesias | if (memaddr-(info->bytes_per_chunk) == prev_insn_addr) {
|
559 | e90e390c | Edgar E. Iglesias | prev_inst = read_insn_microblaze (prev_insn_addr, info, &pop); |
560 | e90e390c | Edgar E. Iglesias | if (prev_inst == 0) |
561 | e90e390c | Edgar E. Iglesias | return -1; |
562 | e90e390c | Edgar E. Iglesias | if (pop->instr == imm) {
|
563 | e90e390c | Edgar E. Iglesias | immval = (get_int_field_imm(prev_inst) << 16) & 0xffff0000; |
564 | e90e390c | Edgar E. Iglesias | immfound = true;
|
565 | e90e390c | Edgar E. Iglesias | } |
566 | e90e390c | Edgar E. Iglesias | else {
|
567 | e90e390c | Edgar E. Iglesias | immval = 0;
|
568 | e90e390c | Edgar E. Iglesias | immfound = false;
|
569 | e90e390c | Edgar E. Iglesias | } |
570 | e90e390c | Edgar E. Iglesias | } |
571 | e90e390c | Edgar E. Iglesias | } |
572 | e90e390c | Edgar E. Iglesias | /* make curr insn as prev insn */
|
573 | e90e390c | Edgar E. Iglesias | prev_insn_addr = memaddr; |
574 | e90e390c | Edgar E. Iglesias | prev_insn_vma = curr_insn_vma; |
575 | e90e390c | Edgar E. Iglesias | |
576 | e90e390c | Edgar E. Iglesias | if (op->name == 0) |
577 | e90e390c | Edgar E. Iglesias | fprintf (stream, ".short 0x%04x", inst);
|
578 | e90e390c | Edgar E. Iglesias | else
|
579 | e90e390c | Edgar E. Iglesias | { |
580 | e90e390c | Edgar E. Iglesias | fprintf (stream, "%s", op->name);
|
581 | e90e390c | Edgar E. Iglesias | |
582 | e90e390c | Edgar E. Iglesias | switch (op->inst_type)
|
583 | e90e390c | Edgar E. Iglesias | { |
584 | e90e390c | Edgar E. Iglesias | case INST_TYPE_RD_R1_R2:
|
585 | e90e390c | Edgar E. Iglesias | fprintf(stream, "\t%s, %s, %s", get_field_rd(inst), get_field_r1(inst), get_field_r2(inst));
|
586 | e90e390c | Edgar E. Iglesias | break;
|
587 | e90e390c | Edgar E. Iglesias | case INST_TYPE_RD_R1_IMM:
|
588 | e90e390c | Edgar E. Iglesias | fprintf(stream, "\t%s, %s, %s", get_field_rd(inst), get_field_r1(inst), get_field_imm(inst));
|
589 | e90e390c | Edgar E. Iglesias | if (info->print_address_func && get_int_field_r1(inst) == 0 && info->symbol_at_address_func) { |
590 | e90e390c | Edgar E. Iglesias | if (immfound)
|
591 | e90e390c | Edgar E. Iglesias | immval |= (get_int_field_imm(inst) & 0x0000ffff);
|
592 | e90e390c | Edgar E. Iglesias | else {
|
593 | e90e390c | Edgar E. Iglesias | immval = get_int_field_imm(inst); |
594 | e90e390c | Edgar E. Iglesias | if (immval & 0x8000) |
595 | e90e390c | Edgar E. Iglesias | immval |= 0xFFFF0000;
|
596 | e90e390c | Edgar E. Iglesias | } |
597 | e90e390c | Edgar E. Iglesias | if (immval > 0 && info->symbol_at_address_func(immval, info)) { |
598 | e90e390c | Edgar E. Iglesias | fprintf (stream, "\t// ");
|
599 | e90e390c | Edgar E. Iglesias | info->print_address_func (immval, info); |
600 | e90e390c | Edgar E. Iglesias | } |
601 | e90e390c | Edgar E. Iglesias | } |
602 | e90e390c | Edgar E. Iglesias | break;
|
603 | e90e390c | Edgar E. Iglesias | case INST_TYPE_RD_R1_IMM5:
|
604 | e90e390c | Edgar E. Iglesias | fprintf(stream, "\t%s, %s, %s", get_field_rd(inst), get_field_r1(inst), get_field_imm5(inst));
|
605 | e90e390c | Edgar E. Iglesias | break;
|
606 | e90e390c | Edgar E. Iglesias | case INST_TYPE_RD_IMM12:
|
607 | e90e390c | Edgar E. Iglesias | fprintf(stream, "\t%s, %s", get_field_rd(inst), get_field_imm12(inst));
|
608 | e90e390c | Edgar E. Iglesias | break;
|
609 | e90e390c | Edgar E. Iglesias | case INST_TYPE_R1_IMM12:
|
610 | e90e390c | Edgar E. Iglesias | fprintf(stream, "\t%s, %s", get_field_r1(inst), get_field_imm12(inst));
|
611 | e90e390c | Edgar E. Iglesias | break;
|
612 | e90e390c | Edgar E. Iglesias | case INST_TYPE_RD_SPECIAL:
|
613 | e90e390c | Edgar E. Iglesias | fprintf(stream, "\t%s, %s", get_field_rd(inst), get_field_special(inst, op));
|
614 | e90e390c | Edgar E. Iglesias | break;
|
615 | e90e390c | Edgar E. Iglesias | case INST_TYPE_SPECIAL_R1:
|
616 | e90e390c | Edgar E. Iglesias | fprintf(stream, "\t%s, %s", get_field_special(inst, op), get_field_r1(inst));
|
617 | e90e390c | Edgar E. Iglesias | break;
|
618 | e90e390c | Edgar E. Iglesias | case INST_TYPE_RD_R1:
|
619 | e90e390c | Edgar E. Iglesias | fprintf(stream, "\t%s, %s", get_field_rd(inst), get_field_r1(inst));
|
620 | e90e390c | Edgar E. Iglesias | break;
|
621 | e90e390c | Edgar E. Iglesias | case INST_TYPE_R1_R2:
|
622 | e90e390c | Edgar E. Iglesias | fprintf(stream, "\t%s, %s", get_field_r1(inst), get_field_r2(inst));
|
623 | e90e390c | Edgar E. Iglesias | break;
|
624 | e90e390c | Edgar E. Iglesias | case INST_TYPE_R1_IMM:
|
625 | e90e390c | Edgar E. Iglesias | fprintf(stream, "\t%s, %s", get_field_r1(inst), get_field_imm(inst));
|
626 | e90e390c | Edgar E. Iglesias | /* The non-pc relative instructions are returns, which shouldn't
|
627 | e90e390c | Edgar E. Iglesias | have a label printed */
|
628 | e90e390c | Edgar E. Iglesias | if (info->print_address_func && op->inst_offset_type == INST_PC_OFFSET && info->symbol_at_address_func) {
|
629 | e90e390c | Edgar E. Iglesias | if (immfound)
|
630 | e90e390c | Edgar E. Iglesias | immval |= (get_int_field_imm(inst) & 0x0000ffff);
|
631 | e90e390c | Edgar E. Iglesias | else {
|
632 | e90e390c | Edgar E. Iglesias | immval = get_int_field_imm(inst); |
633 | e90e390c | Edgar E. Iglesias | if (immval & 0x8000) |
634 | e90e390c | Edgar E. Iglesias | immval |= 0xFFFF0000;
|
635 | e90e390c | Edgar E. Iglesias | } |
636 | e90e390c | Edgar E. Iglesias | immval += memaddr; |
637 | e90e390c | Edgar E. Iglesias | if (immval > 0 && info->symbol_at_address_func(immval, info)) { |
638 | e90e390c | Edgar E. Iglesias | fprintf (stream, "\t// ");
|
639 | e90e390c | Edgar E. Iglesias | info->print_address_func (immval, info); |
640 | e90e390c | Edgar E. Iglesias | } else {
|
641 | e90e390c | Edgar E. Iglesias | fprintf (stream, "\t\t// ");
|
642 | e90e390c | Edgar E. Iglesias | fprintf (stream, "%x", immval);
|
643 | e90e390c | Edgar E. Iglesias | } |
644 | e90e390c | Edgar E. Iglesias | } |
645 | e90e390c | Edgar E. Iglesias | break;
|
646 | e90e390c | Edgar E. Iglesias | case INST_TYPE_RD_IMM:
|
647 | e90e390c | Edgar E. Iglesias | fprintf(stream, "\t%s, %s", get_field_rd(inst), get_field_imm(inst));
|
648 | e90e390c | Edgar E. Iglesias | if (info->print_address_func && info->symbol_at_address_func) {
|
649 | e90e390c | Edgar E. Iglesias | if (immfound)
|
650 | e90e390c | Edgar E. Iglesias | immval |= (get_int_field_imm(inst) & 0x0000ffff);
|
651 | e90e390c | Edgar E. Iglesias | else {
|
652 | e90e390c | Edgar E. Iglesias | immval = get_int_field_imm(inst); |
653 | e90e390c | Edgar E. Iglesias | if (immval & 0x8000) |
654 | e90e390c | Edgar E. Iglesias | immval |= 0xFFFF0000;
|
655 | e90e390c | Edgar E. Iglesias | } |
656 | e90e390c | Edgar E. Iglesias | if (op->inst_offset_type == INST_PC_OFFSET)
|
657 | e90e390c | Edgar E. Iglesias | immval += (int) memaddr;
|
658 | e90e390c | Edgar E. Iglesias | if (info->symbol_at_address_func(immval, info)) {
|
659 | e90e390c | Edgar E. Iglesias | fprintf (stream, "\t// ");
|
660 | e90e390c | Edgar E. Iglesias | info->print_address_func (immval, info); |
661 | e90e390c | Edgar E. Iglesias | } |
662 | e90e390c | Edgar E. Iglesias | } |
663 | e90e390c | Edgar E. Iglesias | break;
|
664 | e90e390c | Edgar E. Iglesias | case INST_TYPE_IMM:
|
665 | e90e390c | Edgar E. Iglesias | fprintf(stream, "\t%s", get_field_imm(inst));
|
666 | e90e390c | Edgar E. Iglesias | if (info->print_address_func && info->symbol_at_address_func && op->instr != imm) {
|
667 | e90e390c | Edgar E. Iglesias | if (immfound)
|
668 | e90e390c | Edgar E. Iglesias | immval |= (get_int_field_imm(inst) & 0x0000ffff);
|
669 | e90e390c | Edgar E. Iglesias | else {
|
670 | e90e390c | Edgar E. Iglesias | immval = get_int_field_imm(inst); |
671 | e90e390c | Edgar E. Iglesias | if (immval & 0x8000) |
672 | e90e390c | Edgar E. Iglesias | immval |= 0xFFFF0000;
|
673 | e90e390c | Edgar E. Iglesias | } |
674 | e90e390c | Edgar E. Iglesias | if (op->inst_offset_type == INST_PC_OFFSET)
|
675 | e90e390c | Edgar E. Iglesias | immval += (int) memaddr;
|
676 | e90e390c | Edgar E. Iglesias | if (immval > 0 && info->symbol_at_address_func(immval, info)) { |
677 | e90e390c | Edgar E. Iglesias | fprintf (stream, "\t// ");
|
678 | e90e390c | Edgar E. Iglesias | info->print_address_func (immval, info); |
679 | e90e390c | Edgar E. Iglesias | } else if (op->inst_offset_type == INST_PC_OFFSET) { |
680 | e90e390c | Edgar E. Iglesias | fprintf (stream, "\t\t// ");
|
681 | e90e390c | Edgar E. Iglesias | fprintf (stream, "%x", immval);
|
682 | e90e390c | Edgar E. Iglesias | } |
683 | e90e390c | Edgar E. Iglesias | } |
684 | e90e390c | Edgar E. Iglesias | break;
|
685 | e90e390c | Edgar E. Iglesias | case INST_TYPE_RD_R2:
|
686 | e90e390c | Edgar E. Iglesias | fprintf(stream, "\t%s, %s", get_field_rd(inst), get_field_r2(inst));
|
687 | e90e390c | Edgar E. Iglesias | break;
|
688 | e90e390c | Edgar E. Iglesias | case INST_TYPE_R2:
|
689 | e90e390c | Edgar E. Iglesias | fprintf(stream, "\t%s", get_field_r2(inst));
|
690 | e90e390c | Edgar E. Iglesias | break;
|
691 | e90e390c | Edgar E. Iglesias | case INST_TYPE_R1:
|
692 | e90e390c | Edgar E. Iglesias | fprintf(stream, "\t%s", get_field_r1(inst));
|
693 | e90e390c | Edgar E. Iglesias | break;
|
694 | e90e390c | Edgar E. Iglesias | case INST_TYPE_RD_R1_SPECIAL:
|
695 | e90e390c | Edgar E. Iglesias | fprintf(stream, "\t%s, %s", get_field_rd(inst), get_field_r2(inst));
|
696 | e90e390c | Edgar E. Iglesias | break;
|
697 | e90e390c | Edgar E. Iglesias | case INST_TYPE_RD_IMM14:
|
698 | e90e390c | Edgar E. Iglesias | fprintf(stream, "\t%s, %s", get_field_rd(inst), get_field_imm14(inst));
|
699 | e90e390c | Edgar E. Iglesias | break;
|
700 | e90e390c | Edgar E. Iglesias | /* For tuqula instruction */
|
701 | e90e390c | Edgar E. Iglesias | case INST_TYPE_RD:
|
702 | e90e390c | Edgar E. Iglesias | fprintf(stream, "\t%s", get_field_rd(inst));
|
703 | e90e390c | Edgar E. Iglesias | break;
|
704 | e90e390c | Edgar E. Iglesias | |
705 | e90e390c | Edgar E. Iglesias | default:
|
706 | e90e390c | Edgar E. Iglesias | /* if the disassembler lags the instruction set */
|
707 | e90e390c | Edgar E. Iglesias | fprintf (stream, "\tundecoded operands, inst is 0x%04x", inst);
|
708 | e90e390c | Edgar E. Iglesias | break;
|
709 | e90e390c | Edgar E. Iglesias | } |
710 | e90e390c | Edgar E. Iglesias | } |
711 | e90e390c | Edgar E. Iglesias | |
712 | e90e390c | Edgar E. Iglesias | /* Say how many bytes we consumed? */
|
713 | e90e390c | Edgar E. Iglesias | return 4; |
714 | e90e390c | Edgar E. Iglesias | } |
715 | e90e390c | Edgar E. Iglesias | |
716 | e90e390c | Edgar E. Iglesias | #if 0
|
717 | e90e390c | Edgar E. Iglesias | static enum microblaze_instr
|
718 | e90e390c | Edgar E. Iglesias | get_insn_microblaze (long inst, boolean *isunsignedimm,
|
719 | e90e390c | Edgar E. Iglesias | enum microblaze_instr_type *insn_type,
|
720 | e90e390c | Edgar E. Iglesias | short *delay_slots )
|
721 | e90e390c | Edgar E. Iglesias | {
|
722 | e90e390c | Edgar E. Iglesias | struct op_code_struct * op;
|
723 | e90e390c | Edgar E. Iglesias | *isunsignedimm = false;
|
724 | e90e390c | Edgar E. Iglesias | |
725 | e90e390c | Edgar E. Iglesias | /* Just a linear search of the table. */
|
726 | e90e390c | Edgar E. Iglesias | for (op = opcodes; op->name != 0; op ++)
|
727 | e90e390c | Edgar E. Iglesias | if (op->bit_sequence == (inst & op->opcode_mask))
|
728 | e90e390c | Edgar E. Iglesias | break;
|
729 | e90e390c | Edgar E. Iglesias | |
730 | e90e390c | Edgar E. Iglesias | if (op->name == 0)
|
731 | e90e390c | Edgar E. Iglesias | return invalid_inst;
|
732 | e90e390c | Edgar E. Iglesias | else {
|
733 | e90e390c | Edgar E. Iglesias | *isunsignedimm = (op->inst_type == INST_TYPE_RD_R1_UNSIGNED_IMM);
|
734 | e90e390c | Edgar E. Iglesias | *insn_type = op->instr_type;
|
735 | e90e390c | Edgar E. Iglesias | *delay_slots = op->delay_slots;
|
736 | e90e390c | Edgar E. Iglesias | return op->instr;
|
737 | e90e390c | Edgar E. Iglesias | }
|
738 | e90e390c | Edgar E. Iglesias | }
|
739 | e90e390c | Edgar E. Iglesias | #endif
|
740 | e90e390c | Edgar E. Iglesias | |
741 | e90e390c | Edgar E. Iglesias | #if 0
|
742 | e90e390c | Edgar E. Iglesias | static short
|
743 | e90e390c | Edgar E. Iglesias | get_delay_slots_microblaze ( long inst )
|
744 | e90e390c | Edgar E. Iglesias | {
|
745 | e90e390c | Edgar E. Iglesias | boolean isunsignedimm;
|
746 | e90e390c | Edgar E. Iglesias | enum microblaze_instr_type insn_type;
|
747 | e90e390c | Edgar E. Iglesias | enum microblaze_instr op;
|
748 | e90e390c | Edgar E. Iglesias | short delay_slots;
|
749 | e90e390c | Edgar E. Iglesias | |
750 | e90e390c | Edgar E. Iglesias | op = get_insn_microblaze( inst, &isunsignedimm, &insn_type, &delay_slots);
|
751 | e90e390c | Edgar E. Iglesias | if (op == invalid_inst)
|
752 | e90e390c | Edgar E. Iglesias | return 0;
|
753 | e90e390c | Edgar E. Iglesias | else
|
754 | e90e390c | Edgar E. Iglesias | return delay_slots;
|
755 | e90e390c | Edgar E. Iglesias | }
|
756 | e90e390c | Edgar E. Iglesias | #endif
|
757 | e90e390c | Edgar E. Iglesias | |
758 | e90e390c | Edgar E. Iglesias | #if 0
|
759 | e90e390c | Edgar E. Iglesias | static enum microblaze_instr
|
760 | e90e390c | Edgar E. Iglesias | microblaze_decode_insn (long insn, int *rd, int *ra, int *rb, int *imm)
|
761 | e90e390c | Edgar E. Iglesias | {
|
762 | e90e390c | Edgar E. Iglesias | enum microblaze_instr op;
|
763 | e90e390c | Edgar E. Iglesias | boolean t1;
|
764 | e90e390c | Edgar E. Iglesias | enum microblaze_instr_type t2;
|
765 | e90e390c | Edgar E. Iglesias | short t3;
|
766 | e90e390c | Edgar E. Iglesias | |
767 | e90e390c | Edgar E. Iglesias | op = get_insn_microblaze(insn, &t1, &t2, &t3);
|
768 | e90e390c | Edgar E. Iglesias | *rd = (insn & RD_MASK) >> RD_LOW;
|
769 | e90e390c | Edgar E. Iglesias | *ra = (insn & RA_MASK) >> RA_LOW;
|
770 | e90e390c | Edgar E. Iglesias | *rb = (insn & RB_MASK) >> RB_LOW;
|
771 | e90e390c | Edgar E. Iglesias | t3 = (insn & IMM_MASK) >> IMM_LOW;
|
772 | e90e390c | Edgar E. Iglesias | *imm = (int) t3;
|
773 | e90e390c | Edgar E. Iglesias | return (op);
|
774 | e90e390c | Edgar E. Iglesias | }
|
775 | e90e390c | Edgar E. Iglesias | #endif
|
776 | e90e390c | Edgar E. Iglesias | |
777 | e90e390c | Edgar E. Iglesias | #if 0
|
778 | e90e390c | Edgar E. Iglesias | static unsigned long
|
779 | e90e390c | Edgar E. Iglesias | microblaze_get_target_address (long inst, boolean immfound, int immval,
|
780 | e90e390c | Edgar E. Iglesias | long pcval, long r1val, long r2val,
|
781 | e90e390c | Edgar E. Iglesias | boolean *targetvalid,
|
782 | e90e390c | Edgar E. Iglesias | boolean *unconditionalbranch)
|
783 | e90e390c | Edgar E. Iglesias | {
|
784 | e90e390c | Edgar E. Iglesias | struct op_code_struct * op;
|
785 | e90e390c | Edgar E. Iglesias | long targetaddr = 0;
|
786 | e90e390c | Edgar E. Iglesias | |
787 | e90e390c | Edgar E. Iglesias | *unconditionalbranch = false;
|
788 | e90e390c | Edgar E. Iglesias | /* Just a linear search of the table. */
|
789 | e90e390c | Edgar E. Iglesias | for (op = opcodes; op->name != 0; op ++)
|
790 | e90e390c | Edgar E. Iglesias | if (op->bit_sequence == (inst & op->opcode_mask))
|
791 | e90e390c | Edgar E. Iglesias | break;
|
792 | e90e390c | Edgar E. Iglesias | |
793 | e90e390c | Edgar E. Iglesias | if (op->name == 0) {
|
794 | e90e390c | Edgar E. Iglesias | *targetvalid = false;
|
795 | e90e390c | Edgar E. Iglesias | } else if (op->instr_type == branch_inst) {
|
796 | e90e390c | Edgar E. Iglesias | switch (op->inst_type) {
|
797 | e90e390c | Edgar E. Iglesias | case INST_TYPE_R2:
|
798 | e90e390c | Edgar E. Iglesias | *unconditionalbranch = true;
|
799 | e90e390c | Edgar E. Iglesias | /* fallthru */
|
800 | e90e390c | Edgar E. Iglesias | case INST_TYPE_RD_R2:
|
801 | e90e390c | Edgar E. Iglesias | case INST_TYPE_R1_R2:
|
802 | e90e390c | Edgar E. Iglesias | targetaddr = r2val;
|
803 | e90e390c | Edgar E. Iglesias | *targetvalid = true;
|
804 | e90e390c | Edgar E. Iglesias | if (op->inst_offset_type == INST_PC_OFFSET)
|
805 | e90e390c | Edgar E. Iglesias | targetaddr += pcval;
|
806 | e90e390c | Edgar E. Iglesias | break;
|
807 | e90e390c | Edgar E. Iglesias | case INST_TYPE_IMM:
|
808 | e90e390c | Edgar E. Iglesias | *unconditionalbranch = true;
|
809 | e90e390c | Edgar E. Iglesias | /* fallthru */
|
810 | e90e390c | Edgar E. Iglesias | case INST_TYPE_RD_IMM:
|
811 | e90e390c | Edgar E. Iglesias | case INST_TYPE_R1_IMM:
|
812 | e90e390c | Edgar E. Iglesias | if (immfound) {
|
813 | e90e390c | Edgar E. Iglesias | targetaddr = (immval << 16) & 0xffff0000;
|
814 | e90e390c | Edgar E. Iglesias | targetaddr |= (get_int_field_imm(inst) & 0x0000ffff);
|
815 | e90e390c | Edgar E. Iglesias | } else {
|
816 | e90e390c | Edgar E. Iglesias | targetaddr = get_int_field_imm(inst);
|
817 | e90e390c | Edgar E. Iglesias | if (targetaddr & 0x8000)
|
818 | e90e390c | Edgar E. Iglesias | targetaddr |= 0xFFFF0000;
|
819 | e90e390c | Edgar E. Iglesias | }
|
820 | e90e390c | Edgar E. Iglesias | if (op->inst_offset_type == INST_PC_OFFSET)
|
821 | e90e390c | Edgar E. Iglesias | targetaddr += pcval;
|
822 | e90e390c | Edgar E. Iglesias | *targetvalid = true;
|
823 | e90e390c | Edgar E. Iglesias | break;
|
824 | e90e390c | Edgar E. Iglesias | default:
|
825 | e90e390c | Edgar E. Iglesias | *targetvalid = false;
|
826 | e90e390c | Edgar E. Iglesias | break;
|
827 | e90e390c | Edgar E. Iglesias | }
|
828 | e90e390c | Edgar E. Iglesias | } else if (op->instr_type == return_inst) {
|
829 | e90e390c | Edgar E. Iglesias | if (immfound) {
|
830 | e90e390c | Edgar E. Iglesias | targetaddr = (immval << 16) & 0xffff0000;
|
831 | e90e390c | Edgar E. Iglesias | targetaddr |= (get_int_field_imm(inst) & 0x0000ffff);
|
832 | e90e390c | Edgar E. Iglesias | } else {
|
833 | e90e390c | Edgar E. Iglesias | targetaddr = get_int_field_imm(inst);
|
834 | e90e390c | Edgar E. Iglesias | if (targetaddr & 0x8000)
|
835 | e90e390c | Edgar E. Iglesias | targetaddr |= 0xFFFF0000;
|
836 | e90e390c | Edgar E. Iglesias | }
|
837 | e90e390c | Edgar E. Iglesias | targetaddr += r1val;
|
838 | e90e390c | Edgar E. Iglesias | *targetvalid = true;
|
839 | e90e390c | Edgar E. Iglesias | } else {
|
840 | e90e390c | Edgar E. Iglesias | *targetvalid = false;
|
841 | e90e390c | Edgar E. Iglesias | }
|
842 | e90e390c | Edgar E. Iglesias | return targetaddr;
|
843 | e90e390c | Edgar E. Iglesias | }
|
844 | e90e390c | Edgar E. Iglesias | #endif |