Rizin
unix-like reverse engineering framework and cli tools
or1k_disas.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2019 v3l0c1r4pt0r <v3l0c1r4pt0r@gmail.com>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include <rz_analysis.h>
5 #include "or1k_disas.h"
6 
8  [INSN_X] = { INSN_X, "%s",
9  { { 0 } } },
10  /* ------KKKKKAAAAABBBBBKKKKKKKKKKK */
11  [INSN_KABK] = { INSN_KABK, "%s r%d, r%d, 0x%x",
16  /* ------IIIIIAAAAABBBBBIIIIIIIIIII */
17  [INSN_IABI] = { INSN_IABI, "%s r%d, r%d, 0x%x",
22  /* ------NNNNNNNNNNNNNNNNNNNNNNNNNN */
23  [INSN_N] = { INSN_N, "%s 0x%x",
25  /* ----------------KKKKKKKKKKKKKKKK */
26  [INSN_K] = { INSN_K, "%s 0x%x",
28  /* ------DDDDD-----KKKKKKKKKKKKKKKK */
29  [INSN_DK] = { INSN_DK, "%s r%d, 0x%x",
32  /* ------DDDDDNNNNNNNNNNNNNNNNNNNNN */
33  [INSN_DN] = { INSN_DN, "%s r%d, 0x%x",
36  /* ----------------BBBBB----------- */
37  [INSN_B] = { INSN_B, "%s r%d",
39  /* ------DDDDD--------------------- */
40  [INSN_D] = { INSN_D, "%s r%d",
42  /* -----------AAAAAIIIIIIIIIIIIIIII */
43  [INSN_AI] = { INSN_AI, "%s r%d, 0x%x",
46  /* ------DDDDDAAAAAIIIIIIIIIIIIIIII */
47  [INSN_DAI] = { INSN_DAI, "%s r%d, r%d, 0x%x",
51  /* ------DDDDDAAAAAKKKKKKKKKKKKKKKK */
52  [INSN_DAK] = { INSN_DAK, "%s r%d, r%d, 0x%x",
56  /* ------DDDDDAAAAA----------LLLLLL */
57  [INSN_DAL] = { INSN_DAL, "%s r%d, r%d, 0x%x",
61  /* ------DDDDDAAAAA---------------- */
62  [INSN_DA] = { INSN_DA, "%s r%d, r%d",
65  /* ------DDDDDAAAAABBBBB----------- */
66  [INSN_DAB] = { INSN_DAB, "%s r%d, r%d, r%d",
70  /* -----------AAAAABBBBB----------- */
71  [INSN_AB] = { INSN_AB, "%s r%d, r%d",
74 };
75 
76 size_t types_count = sizeof(types) / sizeof(insn_type_descr_t);
77 
79  { (0x05 << 26) | (0x1 << 24), "l.nop", INSN_K, INSN_OPCODE_MASK | (0x3 << 24), RZ_ANALYSIS_OP_TYPE_NOP },
80  { 0 }
81 };
82 
84  { (0x06 << 26) | (0 << 16), "l.movhi", INSN_DK, INSN_OPCODE_MASK | (1 << 16) },
85  { (0x06 << 26) | (1 << 16), "l.macrc", INSN_D, INSN_OPCODE_MASK | (1 << 16) },
86  { 0 }
87 };
88 
90  { (0x08 << 26) | (0x0), "l.sys", INSN_K, INSN_OPCODE_MASK | 0x3ff << 16 },
91  { (0x08 << 26) | (0x100), "l.trap", INSN_K, INSN_OPCODE_MASK | 0x3ff << 16 },
92  { (0x08 << 26) | (0x2000000), "l.msync", INSN_X, INSN_OPCODE_MASK | 0x3ffffff },
93  { (0x08 << 26) | (0x2800000), "l.psync", INSN_X, INSN_OPCODE_MASK | 0x3ffffff },
94  { (0x08 << 26) | (0x3000000), "l.csync", INSN_X, INSN_OPCODE_MASK | 0x3ffffff },
95  { 0 }
96 };
97 
99  { (0x2e << 26) | (0x0 << 6), "l.slli", INSN_DAL, INSN_OPCODE_MASK | (0x3 << 6) },
100  { (0x2e << 26) | (0x1 << 6), "l.srli", INSN_DAL, INSN_OPCODE_MASK | (0x3 << 6) },
101  { (0x2e << 26) | (0x2 << 6), "l.srai", INSN_DAL, INSN_OPCODE_MASK | (0x3 << 6) },
102  { (0x2e << 26) | (0x3 << 6), "l.rori", INSN_DAL, INSN_OPCODE_MASK | (0x3 << 6) },
103  { 0 }
104 };
105 
107  { (0x2f << 26) | (0x0 << 21), "l.sfeqi", INSN_AI, INSN_OPCODE_MASK | (0x1f << 21) },
108  { (0x2f << 26) | (0x1 << 21), "l.sfnei", INSN_AI, INSN_OPCODE_MASK | (0x1f << 21) },
109  { (0x2f << 26) | (0x2 << 21), "l.sfgtui", INSN_AI, INSN_OPCODE_MASK | (0x1f << 21) },
110  { (0x2f << 26) | (0x3 << 21), "l.sfgeui", INSN_AI, INSN_OPCODE_MASK | (0x1f << 21) },
111  { (0x2f << 26) | (0x4 << 21), "l.sfltui", INSN_AI, INSN_OPCODE_MASK | (0x1f << 21) },
112  { (0x2f << 26) | (0x5 << 21), "l.sfleui", INSN_AI, INSN_OPCODE_MASK | (0x1f << 21) },
113  { (0x2f << 26) | (0xa << 21), "l.sfgtsi", INSN_AI, INSN_OPCODE_MASK | (0x1f << 21) }, /* FIXME: signed */
114  { (0x2f << 26) | (0xb << 21), "l.sfgesi", INSN_AI, INSN_OPCODE_MASK | (0x1f << 21) }, /* FIXME: signed */
115  { (0x2f << 26) | (0xc << 21), "l.sfltsi", INSN_AI, INSN_OPCODE_MASK | (0x1f << 21) }, /* FIXME: signed */
116  { (0x2f << 26) | (0xd << 21), "l.sflesi", INSN_AI, INSN_OPCODE_MASK | (0x1f << 21) }, /* FIXME: signed */
117  { 0 }
118 };
119 
121  { (0x31 << 26) | (0x1), "l.mac", INSN_AB, INSN_OPCODE_MASK | (0xf) },
122  { (0x31 << 26) | (0x3), "l.macu", INSN_AB, INSN_OPCODE_MASK | (0xf) },
123  { (0x31 << 26) | (0x2), "l.msb", INSN_AB, INSN_OPCODE_MASK | (0xf) },
124  { (0x31 << 26) | (0x4), "l.msbu", INSN_AB, INSN_OPCODE_MASK | (0xf) },
125  { 0 }
126 };
127 
129  { (0x32 << 26) | (0x8), "lf.sfeq.s", INSN_AB, INSN_OPCODE_MASK | (0xff) },
130  { (0x32 << 26) | (0x9), "lf.sfne.s", INSN_AB, INSN_OPCODE_MASK | (0xff) },
131  { (0x32 << 26) | (0xa), "lf.sfgt.s", INSN_AB, INSN_OPCODE_MASK | (0xff) },
132  { (0x32 << 26) | (0xb), "lf.sfge.s", INSN_AB, INSN_OPCODE_MASK | (0xff) },
133  { (0x32 << 26) | (0xc), "lf.sflt.s", INSN_AB, INSN_OPCODE_MASK | (0xff) },
134  { (0x32 << 26) | (0xd), "lf.sfle.s", INSN_AB, INSN_OPCODE_MASK | (0xff) },
135  { (0x32 << 26) | (0x18), "lf.sfeq.d", INSN_AB, INSN_OPCODE_MASK | (0xff) },
136  { (0x32 << 26) | (0x19), "lf.sfne.d", INSN_AB, INSN_OPCODE_MASK | (0xff) },
137  { (0x32 << 26) | (0x1a), "lf.sfgt.d", INSN_AB, INSN_OPCODE_MASK | (0xff) },
138  { (0x32 << 26) | (0x1b), "lf.sfge.d", INSN_AB, INSN_OPCODE_MASK | (0xff) },
139  { (0x32 << 26) | (0x1c), "lf.sflt.d", INSN_AB, INSN_OPCODE_MASK | (0xff) },
140  { (0x32 << 26) | (0x1d), "lf.sfle.d", INSN_AB, INSN_OPCODE_MASK | (0xff) },
141  { (0x32 << 26) | (0x28), "lf.sfueq.s", INSN_AB, INSN_OPCODE_MASK | (0xff) },
142  { (0x32 << 26) | (0x29), "lf.sfune.s", INSN_AB, INSN_OPCODE_MASK | (0xff) },
143  { (0x32 << 26) | (0x2a), "lf.sfugt.s", INSN_AB, INSN_OPCODE_MASK | (0xff) },
144  { (0x32 << 26) | (0x2b), "lf.sfuge.s", INSN_AB, INSN_OPCODE_MASK | (0xff) },
145  { (0x32 << 26) | (0x2c), "lf.sfult.s", INSN_AB, INSN_OPCODE_MASK | (0xff) },
146  { (0x32 << 26) | (0x2d), "lf.sfule.s", INSN_AB, INSN_OPCODE_MASK | (0xff) },
147  { (0x32 << 26) | (0x2e), "lf.sfun.s", INSN_AB, INSN_OPCODE_MASK | (0xff) },
148  { (0x32 << 26) | (0x34), "lf.stod.d", INSN_AB, INSN_OPCODE_MASK | (0xff) },
149  { (0x32 << 26) | (0x35), "lf.dtos.d", INSN_AB, INSN_OPCODE_MASK | (0xff) },
150  { (0x32 << 26) | (0x38), "lf.sfueq.d", INSN_AB, INSN_OPCODE_MASK | (0xff) },
151  { (0x32 << 26) | (0x39), "lf.sfune.d", INSN_AB, INSN_OPCODE_MASK | (0xff) },
152  { (0x32 << 26) | (0x3a), "lf.sfugt.d", INSN_AB, INSN_OPCODE_MASK | (0xff) },
153  { (0x32 << 26) | (0x3b), "lf.sfuge.d", INSN_AB, INSN_OPCODE_MASK | (0xff) },
154  { (0x32 << 26) | (0x3c), "lf.sfult.d", INSN_AB, INSN_OPCODE_MASK | (0xff) },
155  { (0x32 << 26) | (0x3d), "lf.sfule.d", INSN_AB, INSN_OPCODE_MASK | (0xff) },
156  { (0x32 << 26) | (0x3e), "lf.sfun.d", INSN_AB, INSN_OPCODE_MASK | (0xff) },
157  { (0x32 << 26) | (0xd << 4), "lf.cust1.s", INSN_AB, INSN_OPCODE_MASK | (0xf << 4) },
158  { (0x32 << 26) | (0xe << 4), "lf.cust1.d", INSN_AB, INSN_OPCODE_MASK | (0xf << 4) },
159  { (0x32 << 26) | (0x4), "lf.itof.s", INSN_DA, INSN_OPCODE_MASK | (0xff) },
160  { (0x32 << 26) | (0x5), "lf.ftoi.s", INSN_DA, INSN_OPCODE_MASK | (0xff) },
161  { (0x32 << 26) | (0x14), "lf.itof.d", INSN_DA, INSN_OPCODE_MASK | (0xff) },
162  { (0x32 << 26) | (0x15), "lf.ftoi.d", INSN_DA, INSN_OPCODE_MASK | (0xff) },
163  { (0x32 << 26) | (0x0), "lf.add.s", INSN_DAB, INSN_OPCODE_MASK | (0xff) },
164  { (0x32 << 26) | (0x1), "lf.sub.s", INSN_DAB, INSN_OPCODE_MASK | (0xff) },
165  { (0x32 << 26) | (0x2), "lf.mul.s", INSN_DAB, INSN_OPCODE_MASK | (0xff) },
166  { (0x32 << 26) | (0x3), "lf.div.s", INSN_DAB, INSN_OPCODE_MASK | (0xff) },
167  { (0x32 << 26) | (0x7), "lf.madd.s", INSN_DAB, INSN_OPCODE_MASK | (0xff) },
168  { (0x32 << 26) | (0x10), "lf.add.d", INSN_DAB, INSN_OPCODE_MASK | (0xff) },
169  { (0x32 << 26) | (0x11), "lf.sub.d", INSN_DAB, INSN_OPCODE_MASK | (0xff) },
170  { (0x32 << 26) | (0x12), "lf.mul.d", INSN_DAB, INSN_OPCODE_MASK | (0xff) },
171  { (0x32 << 26) | (0x13), "lf.div.d", INSN_DAB, INSN_OPCODE_MASK | (0xff) },
172  { (0x32 << 26) | (0x17), "lf.madd.d", INSN_DAB, INSN_OPCODE_MASK | (0xff) },
173  { 0 }
174 };
175 
177  { (0x38 << 26) | (0x0 << 6) | (0xc), "l.exths", INSN_DA, INSN_OPCODE_MASK | (0xf << 6) | 0xf },
178  { (0x38 << 26) | (0x0 << 6) | (0xd), "l.extws", INSN_DA, INSN_OPCODE_MASK | (0xf << 6) | 0xf },
179  { (0x38 << 26) | (0x1 << 6) | (0xc), "l.extbs", INSN_DA, INSN_OPCODE_MASK | (0xf << 6) | 0xf },
180  { (0x38 << 26) | (0x1 << 6) | (0xd), "l.extwz", INSN_DA, INSN_OPCODE_MASK | (0xf << 6) | 0xf },
181  { (0x38 << 26) | (0x2 << 6) | (0xc), "l.exthz", INSN_DA, INSN_OPCODE_MASK | (0xf << 6) | 0xf },
182  { (0x38 << 26) | (0x3 << 6) | (0xc), "l.extbz", INSN_DA, INSN_OPCODE_MASK | (0xf << 6) | 0xf },
183  { (0x38 << 26) | (0x0 << 6) | (0x0), "l.add", INSN_DAB, INSN_OPCODE_MASK | (0xc << 6) | 0xf },
184  { (0x38 << 26) | (0x0 << 6) | (0x1), "l.addc", INSN_DAB, INSN_OPCODE_MASK | (0xc << 6) | 0xf },
185  { (0x38 << 26) | (0x0 << 6) | (0x2), "l.sub", INSN_DAB, INSN_OPCODE_MASK | (0xc << 6) | 0xf },
186  { (0x38 << 26) | (0x0 << 6) | (0x3), "l.and", INSN_DAB, INSN_OPCODE_MASK | (0xc << 6) | 0xf },
187  { (0x38 << 26) | (0x0 << 6) | (0x4), "l.or", INSN_DAB, INSN_OPCODE_MASK | (0xc << 6) | 0xf },
188  { (0x38 << 26) | (0x0 << 6) | (0x5), "l.xor", INSN_DAB, INSN_OPCODE_MASK | (0xc << 6) | 0xf },
189  { (0x38 << 26) | (0x0 << 6) | (0xe), "l.cmov", INSN_DAB, INSN_OPCODE_MASK | (0xc << 6) | 0xf },
190  { (0x38 << 26) | (0x0 << 6) | (0xf), "l.ff1", INSN_DA, INSN_OPCODE_MASK | (0xc << 6) | 0xf },
191  { (0x38 << 26) | (0x0 << 6) | (0x8), "l.sll", INSN_DAB, INSN_OPCODE_MASK | (0xf << 6) | 0xf },
192  { (0x38 << 26) | (0x1 << 6) | (0x8), "l.srl", INSN_DAB, INSN_OPCODE_MASK | (0xf << 6) | 0xf },
193  { (0x38 << 26) | (0x2 << 6) | (0x8), "l.sra", INSN_DAB, INSN_OPCODE_MASK | (0xf << 6) | 0xf },
194  { (0x38 << 26) | (0x3 << 6) | (0x8), "l.ror", INSN_DAB, INSN_OPCODE_MASK | (0xf << 6) | 0xf },
195  { (0x38 << 26) | (0x1 << 8) | (0xf), "l.fl1", INSN_DA, INSN_OPCODE_MASK | (0x3 << 8) | 0xf },
196  { (0x38 << 26) | (0x3 << 8) | (0x6), "l.mul", INSN_DAB, INSN_OPCODE_MASK | (0x3 << 8) | 0xf },
197  { (0x38 << 26) | (0x3 << 8) | (0x7), "l.muld", INSN_AB, INSN_OPCODE_MASK | (0x3 << 8) | 0xf },
198  { (0x38 << 26) | (0x3 << 8) | (0x9), "l.div", INSN_DAB, INSN_OPCODE_MASK | (0x3 << 8) | 0xf },
199  { (0x38 << 26) | (0x3 << 8) | (0xa), "l.divu", INSN_DAB, INSN_OPCODE_MASK | (0x3 << 8) | 0xf },
200  { (0x38 << 26) | (0x3 << 8) | (0xb), "l.mulu", INSN_DAB, INSN_OPCODE_MASK | (0x3 << 8) | 0xf },
201  { (0x38 << 26) | (0x3 << 8) | (0xc), "l.muldu", INSN_AB, INSN_OPCODE_MASK | (0x3 << 8) | 0xf },
202  { 0 }
203 };
204 
206  { (0x39 << 26) | (0x0 << 21), "l.sfeq", INSN_AB, INSN_OPCODE_MASK | (0x1f << 21) },
207  { (0x39 << 26) | (0x1 << 21), "l.sfne", INSN_AB, INSN_OPCODE_MASK | (0x1f << 21) },
208  { (0x39 << 26) | (0x2 << 21), "l.sfgtu", INSN_AB, INSN_OPCODE_MASK | (0x1f << 21) },
209  { (0x39 << 26) | (0x3 << 21), "l.sfgeu", INSN_AB, INSN_OPCODE_MASK | (0x1f << 21) },
210  { (0x39 << 26) | (0x4 << 21), "l.sfltu", INSN_AB, INSN_OPCODE_MASK | (0x1f << 21) },
211  { (0x39 << 26) | (0x5 << 21), "l.sfleu", INSN_AB, INSN_OPCODE_MASK | (0x1f << 21) },
212  { (0x39 << 26) | (0xa << 21), "l.sfgts", INSN_AB, INSN_OPCODE_MASK | (0x1f << 21) },
213  { (0x39 << 26) | (0xb << 21), "l.sfges", INSN_AB, INSN_OPCODE_MASK | (0x1f << 21) },
214  { (0x39 << 26) | (0xc << 21), "l.sflts", INSN_AB, INSN_OPCODE_MASK | (0x1f << 21) },
215  { (0x39 << 26) | (0xd << 21), "l.sfles", INSN_AB, INSN_OPCODE_MASK | (0x1f << 21) },
216  { 0 }
217 };
218 
220  [0x00] = { (0x00 << 26), "l.j", INSN_N, RZ_ANALYSIS_OP_TYPE_JMP },
221  [0x01] = { (0x01 << 26), "l.jal", INSN_N, RZ_ANALYSIS_OP_TYPE_CALL },
222  [0x02] = { (0x02 << 26), "l.adrp", INSN_DN },
223  [0x03] = { (0x03 << 26), "l.bnf", INSN_N, RZ_ANALYSIS_OP_TYPE_CJMP },
224  [0x04] = { (0x04 << 26), "l.bf", INSN_N, RZ_ANALYSIS_OP_TYPE_CJMP },
225  [0x05] = { (0x05 << 26), NULL, INSN_X, RZ_ANALYSIS_OP_TYPE_NULL, extra_0x5 },
226  [0x06] = { (0x06 << 26), NULL, INSN_X, RZ_ANALYSIS_OP_TYPE_NULL, extra_0x6 },
227  [0x07] = { (0x07 << 26) },
228  [0x08] = { (0x08 << 26), NULL, INSN_X, RZ_ANALYSIS_OP_TYPE_NULL, extra_0x8 },
229  [0x09] = { (0x09 << 26), "l.rfe", INSN_X },
230  [0x0a] = { (0x0a << 26), "lv.ext0a", INSN_X }, /* TODO: implement */
231  [0x0b] = { (0x0b << 26) },
232  [0x0c] = { (0x0c << 26) },
233  [0x0d] = { (0x0d << 26) },
234  [0x0e] = { (0x0e << 26) },
235  [0x0f] = { (0x0f << 26) },
236  [0x10] = { (0x10 << 26) },
237  [0x11] = { (0x11 << 26), "l.jr", INSN_B, RZ_ANALYSIS_OP_TYPE_JMP },
238  [0x12] = { (0x12 << 26), "l.jalr", INSN_B, RZ_ANALYSIS_OP_TYPE_CALL },
239  [0x13] = { (0x13 << 26), "l.maci", INSN_AI },
240  [0x14] = { (0x14 << 26) },
241  [0x15] = { (0x15 << 26) },
242  [0x16] = { (0x16 << 26) },
243  [0x17] = { (0x17 << 26) },
244  [0x18] = { (0x18 << 26) },
245  [0x19] = { (0x19 << 26) },
246  [0x1a] = { (0x1a << 26), "l.lf", INSN_DAI },
247  [0x1b] = { (0x1b << 26), "l.lwa", INSN_DAI },
248  [0x1c] = { (0x1c << 26), "l.cust1", INSN_X },
249  [0x1d] = { (0x1d << 26), "l.cust2", INSN_X },
250  [0x1e] = { (0x1e << 26), "l.cust3", INSN_X },
251  [0x1f] = { (0x1f << 26), "l.cust4", INSN_X },
252  [0x20] = { (0x20 << 26), "l.ld", INSN_DAI },
253  [0x21] = { (0x21 << 26), "l.lwz", INSN_DAI },
254  [0x22] = { (0x22 << 26), "l.lws", INSN_DAI },
255  [0x23] = { (0x23 << 26), "l.lbz", INSN_DAI },
256  [0x24] = { (0x24 << 26), "l.lbs", INSN_DAI },
257  [0x25] = { (0x25 << 26), "l.lhz", INSN_DAI },
258  [0x26] = { (0x26 << 26), "l.lhs", INSN_DAI },
259  [0x27] = { (0x27 << 26), "l.addi", INSN_DAI, RZ_ANALYSIS_OP_TYPE_LOAD },
260  [0x28] = { (0x28 << 26), "l.addic", INSN_DAI },
261  [0x29] = { (0x29 << 26), "l.andi", INSN_DAK },
262  [0x2a] = { (0x2a << 26), "l.ori", INSN_DAK, RZ_ANALYSIS_OP_TYPE_LOAD },
263  [0x2b] = { (0x2b << 26), "l.xori", INSN_DAI },
264  [0x2c] = { (0x2c << 26), "l.muli", INSN_DAI },
265  [0x2d] = { (0x2d << 26), "l.mfspr", INSN_DAK },
266  [0x2e] = { (0x2e << 26), NULL, INSN_X, RZ_ANALYSIS_OP_TYPE_NULL, extra_0x2e },
267  [0x2f] = { (0x2f << 26), NULL, INSN_X, RZ_ANALYSIS_OP_TYPE_NULL, extra_0x2f },
268  [0x30] = { (0x30 << 26), "l.mtspr", INSN_KABK },
269  [0x31] = { (0x31 << 26), NULL, INSN_X, RZ_ANALYSIS_OP_TYPE_NULL, extra_0x31 },
270  [0x32] = { (0x32 << 26), NULL, INSN_X, RZ_ANALYSIS_OP_TYPE_NULL, extra_0x32 },
271  [0x33] = { (0x33 << 26), "l.swa", INSN_IABI },
272  [0x34] = { (0x34 << 26) },
273  [0x35] = { (0x35 << 26), "l.sw", INSN_IABI },
274  [0x36] = { (0x36 << 26), "l.sb", INSN_IABI },
275  [0x37] = { (0x37 << 26), "l.sh", INSN_IABI },
276  [0x38] = { (0x38 << 26), NULL, INSN_X, RZ_ANALYSIS_OP_TYPE_NULL, extra_0x38 },
277  [0x39] = { (0x39 << 26), NULL, INSN_X, RZ_ANALYSIS_OP_TYPE_NULL, extra_0x39 },
278  [0x3a] = { (0x3a << 26) },
279  [0x3b] = { (0x3b << 26) },
280  [0x3c] = { (0x3c << 26), "l.cust5", INSN_X },
281  [0x3d] = { (0x3d << 26), "l.cust6", INSN_X },
282  [0x3e] = { (0x3e << 26), "l.cust7", INSN_X },
283  [0x3f] = { (0x3f << 26), "l.cust8", INSN_X },
284 };
285 
286 size_t insns_count = sizeof(or1k_insns) / sizeof(insn_t);
287 
289  ut32 opcode;
290  while (extra_descr->type != INSN_END) {
291  opcode = (insn & extra_descr->opcode_mask);
292  if (extra_descr->opcode == opcode) {
293  break;
294  }
295  extra_descr++;
296  }
297  if (extra_descr->type != INSN_END) {
298  return extra_descr;
299  } else {
300  return NULL;
301  }
302 }
303 
305  /* xor of mask with itself shifted left detects msb of mask and msb of space
306  * on the right. And discards the latter */
307  ut32 first_bit = (mask ^ (mask >> 1)) & mask;
308  /* if first bit is set */
309  if (number & first_bit) {
310  /* set every bit outside mask */
311  number |= ~mask;
312  }
313  return number;
314 }
#define mask()
#define NULL
Definition: cris-opc.c:27
uint32_t ut32
ut32 sign_extend(ut32 number, ut32 mask)
Performs sign extension of number.
Definition: or1k_disas.c:304
insn_extra_t extra_0x32[]
Definition: or1k_disas.c:128
insn_extra_t extra_0x39[]
Definition: or1k_disas.c:205
insn_extra_t extra_0x5[]
Definition: or1k_disas.c:78
insn_t or1k_insns[]
Definition: or1k_disas.c:219
insn_extra_t extra_0x2f[]
Definition: or1k_disas.c:106
insn_extra_t extra_0x31[]
Definition: or1k_disas.c:120
insn_type_descr_t types[]
Definition: or1k_disas.c:7
insn_extra_t extra_0x6[]
Definition: or1k_disas.c:83
insn_extra_t extra_0x8[]
Definition: or1k_disas.c:89
insn_extra_t extra_0x2e[]
Definition: or1k_disas.c:98
size_t types_count
Definition: or1k_disas.c:76
size_t insns_count
Definition: or1k_disas.c:286
insn_extra_t extra_0x38[]
Definition: or1k_disas.c:176
insn_extra_t * find_extra_descriptor(insn_extra_t *extra_descr, ut32 insn)
Definition: or1k_disas.c:288
#define INSN_L_MASK
Definition: or1k_disas.h:42
#define INSN_A_MASK
Definition: or1k_disas.h:36
#define INSN_B_MASK
Definition: or1k_disas.h:31
#define INSN_I_MASK
Definition: or1k_disas.h:39
#define INSN_D_MASK
Definition: or1k_disas.h:23
#define INSN_N_MASK
Definition: or1k_disas.h:18
#define INSN_D_SHIFT
Definition: or1k_disas.h:21
@ INSN_D
Definition: or1k_disas.h:60
@ INSN_DAB
Definition: or1k_disas.h:73
@ INSN_KABK
Definition: or1k_disas.h:69
@ INSN_DA
Definition: or1k_disas.h:72
@ INSN_X
Definition: or1k_disas.h:55
@ INSN_AI
Definition: or1k_disas.h:62
@ INSN_N
Definition: or1k_disas.h:56
@ INSN_END
Definition: or1k_disas.h:53
@ INSN_B
Definition: or1k_disas.h:61
@ INSN_DN
Definition: or1k_disas.h:57
@ INSN_DAL
Definition: or1k_disas.h:67
@ INSN_IABI
Definition: or1k_disas.h:75
@ INSN_K
Definition: or1k_disas.h:58
@ INSN_DAI
Definition: or1k_disas.h:63
@ INSN_AB
Definition: or1k_disas.h:71
@ INSN_DK
Definition: or1k_disas.h:59
@ INSN_DAK
Definition: or1k_disas.h:65
#define INSN_EMPTY_SHIFT
Definition: or1k_disas.h:14
@ INSN_OPER_A
Definition: or1k_disas.h:83
@ INSN_OPER_B
Definition: or1k_disas.h:84
@ INSN_OPER_I
Definition: or1k_disas.h:88
@ INSN_OPER_N
Definition: or1k_disas.h:85
@ INSN_OPER_K
Definition: or1k_disas.h:86
@ INSN_OPER_D
Definition: or1k_disas.h:87
@ INSN_OPER_L
Definition: or1k_disas.h:89
@ INSN_OPER_K2
Definition: or1k_disas.h:82
@ INSN_OPER_K1
Definition: or1k_disas.h:81
#define INSN_B_SHIFT
Definition: or1k_disas.h:29
#define INSN_K1_MASK
Definition: or1k_disas.h:47
#define INSN_K1_SHIFT
Definition: or1k_disas.h:45
#define INSN_A_SHIFT
Definition: or1k_disas.h:34
#define INSN_OPCODE_MASK
Definition: or1k_disas.h:10
#define INSN_K_MASK
Definition: or1k_disas.h:26
#define INSN_K2_MASK
Definition: or1k_disas.h:50
@ RZ_ANALYSIS_OP_TYPE_LOAD
Definition: rz_analysis.h:416
@ RZ_ANALYSIS_OP_TYPE_JMP
Definition: rz_analysis.h:368
@ RZ_ANALYSIS_OP_TYPE_NULL
Definition: rz_analysis.h:367
@ RZ_ANALYSIS_OP_TYPE_CALL
Definition: rz_analysis.h:378
@ RZ_ANALYSIS_OP_TYPE_CJMP
Definition: rz_analysis.h:373
@ RZ_ANALYSIS_OP_TYPE_NOP
Definition: rz_analysis.h:389