Rizin
unix-like reverse engineering framework and cli tools
v850_disas.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2014-2018 Fedor Sakharov <fedor.sakharov@gmail.com>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #ifndef RZ_V850_DISASM_H
5 #define RZ_V850_DISASM_H
6 
7 #define V850_INSTR_MAXLEN 24
8 
9 #define SIGN_EXT_T5(imm) (((imm)&0x10) ? (imm) | 0xE0 : (imm))
10 #define SIGN_EXT_T9(imm) (((imm)&0x100) ? (imm) | 0xFFFFFE00 : (imm))
11 #define SIGN_EXT_T26(imm) (((imm)&0x2000000) ? (imm) | 0xFC000000 : (imm))
12 
14  V850_MOV = 0x0,
15  V850_NOT = 0x1,
16  V850_DIVH = 0x2,
17  V850_JMP = 0x3,
18  V850_SATSUBR = 0x4,
19  V850_SATSUB = 0x5,
20  V850_SATADD = 0x6,
21  V850_MULH = 0x7,
22  V850_OR = 0x8,
23  V850_XOR = 0x9,
24  V850_AND = 0xA,
25  V850_TST = 0xB,
26  V850_SUBR = 0xC,
27  V850_SUB = 0xD,
28  V850_ADD = 0xE,
29  V850_CMP = 0xF,
30  V850_MOV_IMM5 = 0x10,
32  V850_ADD_IMM5 = 0x12,
33  V850_CMP_IMM5 = 0x13,
34  V850_SHR_IMM5 = 0x14,
35  V850_SAR_IMM5 = 0x15,
36  V850_SHL_IMM5 = 0x16,
38  V850_SLDB = 0x18,
39  V850_SSTB = 0x1C,
40  V850_SLDH = 0x20,
41  V850_SSTH = 0x24,
42  V850_SLDW = 0x28,
43  V850_SSTW = 0x29,
44  V850_BCOND = 0x2C,
45  V850_BCOND2 = 0x2D,
46  V850_BCOND3 = 0x2E,
47  V850_BCOND4 = 0x2F,
48  V850_ADDI = 0x30,
49  V850_MOVEA = 0x31,
50  V850_MOVHI = 0x32,
51  V850_SATSUBI = 0x33,
52  V850_ORI = 0x34,
53  V850_XORI = 0x35,
54  V850_ANDI = 0x36,
55  V850_MULHI = 0x37,
56  V850_LDB = 0x38,
57  V850_LDHW = 0x39,
58  V850_STB = 0x3A,
59  V850_STHW = 0x3B,
60  V850_JARL1 = 0x3C,
61  V850_JARL2 = 0x3D,
63  V850_EXT1 = 0x3F,
64 };
65 
66 enum v850_conds {
67  V850_COND_V = 0x0, // Overflow
68  V850_COND_CL = 0x1, // Carry/Lower
69  V850_COND_ZE = 0x2, // Zero/equal
70  V850_COND_NH = 0x3, // Not higher
71  V850_COND_N = 0x4, // Negative
72  V850_COND_AL = 0x5, // Always
73  V850_COND_LT = 0x6, // Less than signed
74  V850_COND_LE = 0x7, // Less than or equal signed
75  V850_COND_NV = 0x8, // No overflow
76  V850_COND_NL = 0x9, // No carry / not lower
77  V850_COND_NC = 0x9, // No carry / not lower
78  V850_COND_NE = 0xA, // Not zero / not equal
79  V850_COND_NZ = 0xA, // Not zero / not equal
80  V850_COND_H = 0xB, // Higher/Greater than
81  V850_COND_P = 0xC, // Positive / not sign
82  V850_COND_NS = 0xC, // Positive / not sign
83  V850_COND_SA = 0xD, // Saturated
84  V850_COND_GE = 0xE, // Greater than or equal signed
85  V850_COND_GT = 0xF, // Greater than signed
86 };
87 
93 };
94 
108 };
109 
111  V850_EXT_DI = 0x0,
112  V850_EXT_EI = 0x4,
113 };
114 
115 enum v850_regs {
116  V850_ZERO = 0x0,
117  V850_R1 = 0x1,
118  V850_R2 = 0x2,
119  V850_SP = 0x3,
120  V850_GP = 0x4,
121  V850_TP = 0x5,
122  V850_R6 = 0x6,
123  V850_R7 = 0x7,
124  V850_R8 = 0x8,
125  V850_R9 = 0x9,
126  V850_R10 = 0xA,
127  V850_R11 = 0xB,
128  V850_R12 = 0xC,
129  V850_R13 = 0xD,
130  V850_R14 = 0xE,
131  V850_R15 = 0xF,
132  V850_R16 = 0x10,
133  V850_R17 = 0x11,
134  V850_R18 = 0x12,
135  V850_R19 = 0x13,
136  V850_R20 = 0x14,
137  V850_R21 = 0x15,
138  V850_R22 = 0x16,
139  V850_R23 = 0x17,
140  V850_R24 = 0x18,
141  V850_R25 = 0x19,
142  V850_R26 = 0x1A,
143  V850_R27 = 0x1B,
144  V850_R28 = 0x1C,
145  V850_R29 = 0x1D,
146  V850_EP = 0x1E,
147  V850_LP = 0x1F,
148 };
149 
163 };
164 
170 };
171 
172 struct v850_cmd {
174  unsigned type;
177 };
178 
179 static inline ut8 get_opcode(const ut16 instr) {
180  return (instr >> 5) & 0x3F;
181 }
182 
183 // FIXME: XXX: Invalid for extended instruction format 4 (Format XII)!
184 static inline ut8 get_subopcode(const ut16 instr) {
185  return (instr & 0x7e00000) >> 21;
186 }
187 
188 static inline ut8 get_reg1(const ut16 instr) {
189  return instr & 0x1F;
190 }
191 
192 static inline ut8 get_reg2(const ut16 instr) {
193  return instr >> 11;
194 }
195 
196 int v850_decode_command(const ut8 *instr, int len, struct v850_cmd *cmd);
197 #endif /* RZ_V850_DISASM_H */
size_t len
Definition: 6502dis.c:15
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags cmd
Definition: sflib.h:79
uint16_t ut16
uint8_t ut8
Definition: lh5801.h:11
ut64 addr
Definition: v850_disas.h:173
unsigned type
Definition: v850_disas.h:174
char instr[V850_INSTR_MAXLEN]
Definition: v850_disas.h:175
v850_regs
Definition: v850_disas.h:115
@ V850_R9
Definition: v850_disas.h:125
@ V850_R22
Definition: v850_disas.h:138
@ V850_R27
Definition: v850_disas.h:143
@ V850_R25
Definition: v850_disas.h:141
@ V850_R14
Definition: v850_disas.h:130
@ V850_R15
Definition: v850_disas.h:131
@ V850_R19
Definition: v850_disas.h:135
@ V850_R13
Definition: v850_disas.h:129
@ V850_GP
Definition: v850_disas.h:120
@ V850_R18
Definition: v850_disas.h:134
@ V850_ZERO
Definition: v850_disas.h:116
@ V850_R24
Definition: v850_disas.h:140
@ V850_LP
Definition: v850_disas.h:147
@ V850_R12
Definition: v850_disas.h:128
@ V850_R10
Definition: v850_disas.h:126
@ V850_R17
Definition: v850_disas.h:133
@ V850_R6
Definition: v850_disas.h:122
@ V850_EP
Definition: v850_disas.h:146
@ V850_R23
Definition: v850_disas.h:139
@ V850_R29
Definition: v850_disas.h:145
@ V850_R1
Definition: v850_disas.h:117
@ V850_R28
Definition: v850_disas.h:144
@ V850_R16
Definition: v850_disas.h:132
@ V850_R2
Definition: v850_disas.h:118
@ V850_R8
Definition: v850_disas.h:124
@ V850_R26
Definition: v850_disas.h:142
@ V850_R21
Definition: v850_disas.h:137
@ V850_R7
Definition: v850_disas.h:123
@ V850_R11
Definition: v850_disas.h:127
@ V850_R20
Definition: v850_disas.h:136
@ V850_TP
Definition: v850_disas.h:121
@ V850_SP
Definition: v850_disas.h:119
static ut8 get_reg2(const ut16 instr)
Definition: v850_disas.h:192
v850_extension1
Definition: v850_disas.h:95
@ V850_EXT_UNDEF1
Definition: v850_disas.h:99
@ V850_EXT_LDSR
Definition: v850_disas.h:97
@ V850_EXT_SHL
Definition: v850_disas.h:102
@ V850_EXT_SHR
Definition: v850_disas.h:100
@ V850_EXT_SAR
Definition: v850_disas.h:101
@ V850_EXT_UNDEF2
Definition: v850_disas.h:103
@ V850_EXT_EXT2
Definition: v850_disas.h:107
@ V850_EXT_HALT
Definition: v850_disas.h:105
@ V850_EXT_RETI
Definition: v850_disas.h:106
@ V850_EXT_STSR
Definition: v850_disas.h:98
@ V850_EXT_TRAP
Definition: v850_disas.h:104
@ V850_EXT_SETF
Definition: v850_disas.h:96
#define V850_INSTR_MAXLEN
Definition: v850_disas.h:7
static ut8 get_reg1(const ut16 instr)
Definition: v850_disas.h:188
v850_sysregs
Definition: v850_disas.h:150
@ V850_SREG_DBPC
Definition: v850_disas.h:159
@ V850_SREG_CTPC
Definition: v850_disas.h:157
@ V850_SREG_ECR
Definition: v850_disas.h:155
@ V850_SREG_CTPSW
Definition: v850_disas.h:158
@ V850_SREG_EIPCW
Definition: v850_disas.h:152
@ V850_SREG_PSW
Definition: v850_disas.h:156
@ V850_SREG_FEPC
Definition: v850_disas.h:153
@ V850_SREG_FEPSW
Definition: v850_disas.h:154
@ V850_SREG_CTBP
Definition: v850_disas.h:161
@ V850_SREG_DIR
Definition: v850_disas.h:162
@ V850_SREG_EIPC
Definition: v850_disas.h:151
@ V850_SREG_DBPSW
Definition: v850_disas.h:160
v850_bit_ops
Definition: v850_disas.h:88
@ V850_BIT_SET1
Definition: v850_disas.h:89
@ V850_BIT_NOT1
Definition: v850_disas.h:90
@ V850_BIT_TST1
Definition: v850_disas.h:92
@ V850_BIT_CLR1
Definition: v850_disas.h:91
int v850_decode_command(const ut8 *instr, int len, struct v850_cmd *cmd)
Definition: v850_disas.c:301
v850_extension2
Definition: v850_disas.h:110
@ V850_EXT_EI
Definition: v850_disas.h:112
@ V850_EXT_DI
Definition: v850_disas.h:111
v850_flags
Definition: v850_disas.h:165
@ V850_FLAG_CY
Definition: v850_disas.h:166
@ V850_FLAG_OV
Definition: v850_disas.h:167
@ V850_FLAG_S
Definition: v850_disas.h:168
@ V850_FLAG_Z
Definition: v850_disas.h:169
static ut8 get_opcode(const ut16 instr)
Definition: v850_disas.h:179
v850_conds
Definition: v850_disas.h:66
@ V850_COND_H
Definition: v850_disas.h:80
@ V850_COND_NZ
Definition: v850_disas.h:79
@ V850_COND_ZE
Definition: v850_disas.h:69
@ V850_COND_LT
Definition: v850_disas.h:73
@ V850_COND_N
Definition: v850_disas.h:71
@ V850_COND_V
Definition: v850_disas.h:67
@ V850_COND_CL
Definition: v850_disas.h:68
@ V850_COND_NL
Definition: v850_disas.h:76
@ V850_COND_P
Definition: v850_disas.h:81
@ V850_COND_NE
Definition: v850_disas.h:78
@ V850_COND_GE
Definition: v850_disas.h:84
@ V850_COND_NV
Definition: v850_disas.h:75
@ V850_COND_NS
Definition: v850_disas.h:82
@ V850_COND_GT
Definition: v850_disas.h:85
@ V850_COND_SA
Definition: v850_disas.h:83
@ V850_COND_AL
Definition: v850_disas.h:72
@ V850_COND_LE
Definition: v850_disas.h:74
@ V850_COND_NH
Definition: v850_disas.h:70
@ V850_COND_NC
Definition: v850_disas.h:77
static ut8 get_subopcode(const ut16 instr)
Definition: v850_disas.h:184
v850_cmd_opcodes
Definition: v850_disas.h:13
@ V850_MULH_IMM5
Definition: v850_disas.h:37
@ V850_SAR_IMM5
Definition: v850_disas.h:35
@ V850_SLDB
Definition: v850_disas.h:38
@ V850_BIT_MANIP
Definition: v850_disas.h:62
@ V850_STHW
Definition: v850_disas.h:59
@ V850_AND
Definition: v850_disas.h:24
@ V850_TST
Definition: v850_disas.h:25
@ V850_ADDI
Definition: v850_disas.h:48
@ V850_LDB
Definition: v850_disas.h:56
@ V850_SLDH
Definition: v850_disas.h:40
@ V850_SUBR
Definition: v850_disas.h:26
@ V850_ADD
Definition: v850_disas.h:28
@ V850_CMP_IMM5
Definition: v850_disas.h:33
@ V850_EXT1
Definition: v850_disas.h:63
@ V850_XORI
Definition: v850_disas.h:53
@ V850_JMP
Definition: v850_disas.h:17
@ V850_JARL1
Definition: v850_disas.h:60
@ V850_SHR_IMM5
Definition: v850_disas.h:34
@ V850_OR
Definition: v850_disas.h:22
@ V850_SATSUBI
Definition: v850_disas.h:51
@ V850_SUB
Definition: v850_disas.h:27
@ V850_DIVH
Definition: v850_disas.h:16
@ V850_BCOND4
Definition: v850_disas.h:47
@ V850_ORI
Definition: v850_disas.h:52
@ V850_MOV_IMM5
Definition: v850_disas.h:30
@ V850_SATSUBR
Definition: v850_disas.h:18
@ V850_NOT
Definition: v850_disas.h:15
@ V850_LDHW
Definition: v850_disas.h:57
@ V850_MOVEA
Definition: v850_disas.h:49
@ V850_STB
Definition: v850_disas.h:58
@ V850_MOV
Definition: v850_disas.h:14
@ V850_SLDW
Definition: v850_disas.h:42
@ V850_SSTH
Definition: v850_disas.h:41
@ V850_MOVHI
Definition: v850_disas.h:50
@ V850_BCOND3
Definition: v850_disas.h:46
@ V850_SATADD_IMM5
Definition: v850_disas.h:31
@ V850_SATADD
Definition: v850_disas.h:20
@ V850_MULH
Definition: v850_disas.h:21
@ V850_SHL_IMM5
Definition: v850_disas.h:36
@ V850_ADD_IMM5
Definition: v850_disas.h:32
@ V850_SSTW
Definition: v850_disas.h:43
@ V850_XOR
Definition: v850_disas.h:23
@ V850_SSTB
Definition: v850_disas.h:39
@ V850_MULHI
Definition: v850_disas.h:55
@ V850_CMP
Definition: v850_disas.h:29
@ V850_BCOND2
Definition: v850_disas.h:45
@ V850_ANDI
Definition: v850_disas.h:54
@ V850_SATSUB
Definition: v850_disas.h:19
@ V850_JARL2
Definition: v850_disas.h:61
@ V850_BCOND
Definition: v850_disas.h:44
ut64(WINAPI *w32_GetEnabledXStateFeatures)()