16 #define F1_REG1(instr) ((instr)&0x1F)
17 #define F1_REG2(instr) (((instr)&0xF800) >> 11)
19 #define F1_RN1(instr) (V850_REG_NAMES[F1_REG1(instr)])
20 #define F1_RN2(instr) (V850_REG_NAMES[F1_REG2(instr)])
23 #define F2_IMM(instr) F1_REG1(instr)
24 #define F2_REG2(instr) F1_REG2(instr)
26 #define F2_RN2(instr) (V850_REG_NAMES[F2_REG2(instr)])
29 #define F3_COND(instr) ((instr)&0xF)
30 #define F3_DISP(instr) (((instr)&0x70) >> 4) | (((instr)&0xF800) >> 7)
33 #define F4_DISP(instr) ((instr)&0x3F)
34 #define F4_REG2(instr) F1_REG2(instr)
36 #define F4_RN2(instr) (V850_REG_NAMES[F4_REG2(instr)])
39 #define F5_REG2(instr) F1_REG2(instr)
40 #define F5_DISP(instr) ((((ut32)(instr)&0xffff) << 31) | (((ut32)(instr)&0xffff0000) << 1))
41 #define F5_RN2(instr) (V850_REG_NAMES[F5_REG2(instr)])
44 #define F6_REG1(instr) F1_REG1(instr)
45 #define F6_REG2(instr) F1_REG2(instr)
46 #define F6_IMM(instr) (((instr)&0xFFFF0000) >> 16)
48 #define F6_RN1(instr) (V850_REG_NAMES[F6_REG1(instr)])
49 #define F6_RN2(instr) (V850_REG_NAMES[F6_REG2(instr)])
52 #define F7_REG1(instr) F1_REG1(instr)
53 #define F7_REG2(instr) F1_REG2(instr)
54 #define F7_DISP(instr) F6_IMM(instr)
56 #define F7_RN1(instr) (V850_REG_NAMES[F7_REG1(instr)])
57 #define F7_RN2(instr) (V850_REG_NAMES[F7_REG2(instr)])
60 #define F8_REG1(instr) F1_REG1(instr)
61 #define F8_DISP(instr) F6_IMM(instr)
62 #define F8_BIT(instr) (((instr)&0x3800) >> 11)
63 #define F8_SUB(instr) (((instr)&0xC000) >> 14)
65 #define F8_RN1(instr) (V850_REG_NAMES[F8_REG1(instr)])
66 #define F8_RN2(instr) (V850_REG_NAMES[F8_REG2(instr)])
70 #define F9_REG1(instr) F1_REG1(instr)
71 #define F9_REG2(instr) F1_REG2(instr)
72 #define F9_SUB(instr) (((instr)&0x7E00000) >> 21)
74 #define F9_RN1(instr) (V850_REG_NAMES[F9_REG1(instr)])
75 #define F9_RN2(instr) (V850_REG_NAMES[F9_REG2(instr)])
79 #define F11_REG1(instr) F1_REG1(instr)
80 #define F11_REG2(instr) F1_REG2(instr)
81 #define F11_REG3(instr) (((instr)&0xF8000000) >> 27)
82 #define F11_SUB(instr) ((((instr)&0x7E00000) >> 20) | (((instr)&2) >> 1))
84 #define F11_RN1(instr) (V850_REG_NAMES[F11_REG1(instr)])
85 #define F11_RN2(instr) (V850_REG_NAMES[F11_REG2(instr)])
87 #define F12_IMM(instr) (F1_REG1(instr) | (((instr)&0x7C0000) >> 13))
88 #define F12_REG2(instr) F1_REG2(instr)
89 #define F12_REG3(instr) (((instr)&0xF8000000) >> 27)
90 #define F12_SUB(instr) ((((instr)&0x7800001) >> 22) | (((instr)&2) >> 1))
92 #define F12_RN2(instr) (V850_REG_NAMES[F12_REG2(instr)])
93 #define F12_RN3(instr) (V850_REG_NAMES[F12_REG3(instr)])
96 #define F13_IMM(instr) (((instr)&0x3E) >> 1)
98 #define F13_REG2(instr) (((instr)&0x1F0000) >> 16)
99 #define F13_LIST(instr) (((instr) && 0xFFE00000) >> 21)
101 #define F13_RN2(instr) (V850_REG_NAMES[F13_REG2(instr)])
171 const char *reg1 =
NULL;
172 const char *reg2 =
NULL;
176 ut16 word1 = 0, word2 = 0;
179 if (
len < 1 || (
len > 0 && !memcmp(
buf,
"\xff\xff\xff\xff\xff\xff",
RZ_MIN(
len, 6)))) {
213 rz_strbuf_appendf(&
op->esil,
"%s,0xffff,&,%u,+,%s,=",
F6_RN1(word1), word2,
F6_RN2(word1));
266 jumpdisp =
DISP26(word1, word2);
348 op->val =
op->stackptr;
357 op->stackptr = (
st64)word2;
358 op->val =
op->stackptr;
373 rz_strbuf_appendf(&
op->esil,
"31,%s,>>,?{,%u,32,-,%u,1,<<,--,<<,}{,0,},%u,%s,>>,|,%s,=", reg2, (
ut8)imm5, (
ut8)imm5, (
ut8)imm5, reg2, reg2);
387 destaddr = ((((word1 >> 4) & 0x7) |
388 ((word1 >> 11) << 3))
390 if (destaddr & 0x100) {
391 destaddrs = destaddr | 0xFE00;
393 destaddrs = destaddr;
395 op->jump =
addr + destaddrs;
448 ut8 bitop = word1 >> 14;
451 bitmask = (1 <<
F8_BIT(word1));
452 rz_strbuf_appendf(&
op->esil,
"%hu,%s,+,[1],%u,&,%hu,%s,+,=[1]", word2,
F8_RN1(word1), bitmask, word2,
F8_RN1(word1));
456 bitmask = (1 <<
F8_BIT(word1));
457 rz_strbuf_appendf(&
op->esil,
"%hu,%s,+,[1],%u,^,%hu,%s,+,=[1]", word2,
F8_RN1(word1), bitmask, word2,
F8_RN1(word1));
480 rz_strbuf_appendf(&
op->esil,
"31,%s,>>,?{,%s,32,-,%s,1,<<,--,<<,}{,0,},%s,%s,>>,|,%s,=", reg2, reg1, reg1, reg1, reg2, reg2);
534 "gpr r25 .32 100 0\n"
535 "gpr r26 .32 104 0\n"
536 "gpr r27 .32 108 0\n"
537 "gpr r28 .32 112 0\n"
538 "gpr r29 .32 116 0\n"
539 "gpr r30 .32 120 0\n"
541 "gpr r31 .32 124 0\n"
546 "gpr psw .32 132 0\n"
547 "gpr npi .1 132.16 0\n"
548 "gpr epi .1 132.17 0\n"
549 "gpr id .1 132.18 0\n"
550 "gpr sat .1 132.19 0\n"
551 "flg cy .1 132.28 0\n"
552 "flg ov .1 132.29 0\n"
553 "flg s .1 132.30 0\n"
554 "flg z .1 132.31 0\n";
559 #define KW(d, ds, m, ms) rz_list_append(l, rz_search_keyword_new((const ut8 *)d, ds, (const ut8 *)m, ms, NULL))
561 KW(
"\x80\x07", 2,
"\xf0\xff", 2);
562 KW(
"\x50\x1a\x63\x0f", 4,
"\xf0\xff\xff\x0f", 4);
580 .desc =
"V850 code analysis plugin",
591 #ifndef RZ_PLUGIN_INCORE
static void update_flags(RzAnalysisOp *op, int flags)
static char * get_reg_profile(RzAnalysis *analysis)
RzAnalysisPlugin rz_analysis_plugin_v850
RZ_API RzLibStruct rizin_plugin
static void clear_flags(RzAnalysisOp *op, int flags)
static const char * V850_REG_NAMES[]
static int archinfo(RzAnalysis *analysis, int q)
static RzList * analysis_preludes(RzAnalysis *analysis)
static int v850_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, RzAnalysisOpMask mask)
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
RZ_API void rz_search_keyword_free(RzSearchKeyword *kw)
return memset(p, 0, total)
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
#define RZ_ANALYSIS_ARCHINFO_ALIGN
#define RZ_ANALYSIS_ARCHINFO_MAX_OP_SIZE
#define RZ_ANALYSIS_ARCHINFO_MIN_OP_SIZE
@ RZ_ANALYSIS_OP_TYPE_CMP
@ RZ_ANALYSIS_OP_TYPE_SUB
@ RZ_ANALYSIS_OP_TYPE_LOAD
@ RZ_ANALYSIS_OP_TYPE_MUL
@ RZ_ANALYSIS_OP_TYPE_JMP
@ RZ_ANALYSIS_OP_TYPE_AND
@ RZ_ANALYSIS_OP_TYPE_UJMP
@ RZ_ANALYSIS_OP_TYPE_SAR
@ RZ_ANALYSIS_OP_TYPE_ADD
@ RZ_ANALYSIS_OP_TYPE_STORE
@ RZ_ANALYSIS_OP_TYPE_SHR
@ RZ_ANALYSIS_OP_TYPE_CJMP
@ RZ_ANALYSIS_OP_TYPE_DIV
@ RZ_ANALYSIS_OP_TYPE_MOV
@ RZ_ANALYSIS_OP_TYPE_SHL
@ RZ_ANALYSIS_OP_TYPE_NOT
@ RZ_ANALYSIS_OP_TYPE_RET
@ RZ_ANALYSIS_OP_TYPE_XOR
static ut16 rz_read_le16(const void *src)
void(* RzListFree)(void *ptr)
RZ_API bool rz_strbuf_append(RzStrBuf *sb, const char *s)
RZ_API bool rz_strbuf_appendf(RzStrBuf *sb, const char *fmt,...) RZ_PRINTF_CHECK(2
static struct sockaddr static addrlen static backlog const void static flags void flags
#define DISP26(word1, word2)
int v850_decode_command(const ut8 *instr, int len, struct v850_cmd *cmd)
static ut8 get_subopcode(const ut16 instr)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()