9 #include "../arch/sh/sh_il.h"
24 #define BIT_32(x) x ",0x80000000,&"
25 #define S16_EXT(x) x ",DUP,0x8000,&,?{,0xFFFFFFFFFFFF0000,|,}"
26 #define S32_EXT(x) x ",DUP,0x80000000,&,?{,0xFFFFFFFF00000000,|,}"
27 #define IS_T "sr,0x1,&,"
28 #define SET_T "0x1,sr,|="
29 #define CLR_T "0xFFFFFFFE,sr,&="
32 #define IS_CLRT(x) x == 0x0008
33 #define IS_NOP(x) x == 0x0009
34 #define IS_RTS(x) x == 0x000b
35 #define IS_SETT(x) x == 0x0018
36 #define IS_DIV0U(x) x == 0x0019
37 #define IS_SLEEP(x) x == 0x001b
38 #define IS_CLRMAC(x) x == 0x0028
39 #define IS_RTE(x) x == 0x002b
41 #define IS_STCSR1(x) (((x)&0xF0CF) == 0x0002)
42 #define IS_BSRF(x) ((x)&0xf0ff) == 0x0003
43 #define IS_BRAF(x) (((x)&0xf0ff) == 0x0023)
44 #define IS_MOVB_REG_TO_R0REL(x) (((x)&0xF00F) == 0x0004)
45 #define IS_MOVW_REG_TO_R0REL(x) (((x)&0xF00F) == 0x0005)
46 #define IS_MOVL_REG_TO_R0REL(x) (((x)&0xF00F) == 0x0006)
47 #define IS_MULL(x) (((x)&0xF00F) == 0x0007)
48 #define IS_MOVB_R0REL_TO_REG(x) (((x)&0xF00F) == 0x000C)
49 #define IS_MOVW_R0REL_TO_REG(x) (((x)&0xF00F) == 0x000D)
50 #define IS_MOVL_R0REL_TO_REG(x) (((x)&0xF00F) == 0x000E)
51 #define IS_MACL(x) (((x)&0xF00F) == 0x000F)
52 #define IS_MOVT(x) (((x)&0xF0FF) == 0x0029)
53 #define IS_STSMACH(x) (((x)&0xF0FF) == 0x000A)
54 #define IS_STSMACL(x) (((x)&0xF0FF) == 0x001A)
55 #define IS_STSPR(x) (((x)&0xF0FF) == 0x002A)
58 #define IS_MOVB_REG_TO_REGREF(x) (((x)&0xF00F) == 0x2000)
59 #define IS_MOVW_REG_TO_REGREF(x) (((x)&0xF00F) == 0x2001)
60 #define IS_MOVL_REG_TO_REGREF(x) (((x)&0xF00F) == 0x2002)
62 #define IS_PUSHB(x) (((x)&0xF00F) == 0x2004)
63 #define IS_PUSHW(x) (((x)&0xF00F) == 0x2005)
64 #define IS_PUSHL(x) (((x)&0xF00F) == 0x2006)
65 #define IS_DIV0S(x) (((x)&0xF00F) == 0x2007)
66 #define IS_TSTRR(x) (((x)&0xF00F) == 0x2008)
67 #define IS_AND_REGS(x) (((x)&0xF00F) == 0x2009)
68 #define IS_XOR_REGS(x) (((x)&0xF00F) == 0x200A)
69 #define IS_OR_REGS(x) (((x)&0xF00F) == 0x200B)
70 #define IS_CMPSTR(x) (((x)&0xF00F) == 0x200C)
71 #define IS_XTRCT(x) (((x)&0xF00F) == 0x200D)
72 #define IS_MULUW(x) (((x)&0xF00F) == 0x200E)
73 #define IS_MULSW(x) (((x)&0xF00F) == 0x200F)
74 #define IS_CMPEQ(x) (((x)&0xF00F) == 0x3000)
76 #define IS_CMPHS(x) (((x)&0xF00F) == 0x3002)
77 #define IS_CMPGE(x) (((x)&0xF00F) == 0x3003)
78 #define IS_CMPHI(x) (((x)&0xF00F) == 0x3006)
79 #define IS_CMPGT(x) (((x)&0xF00F) == 0x3007)
80 #define IS_DIV1(x) (((x)&0xF00F) == 0x3004)
81 #define IS_DMULU(x) (((x)&0xF00F) == 0x3005)
82 #define IS_DMULS(x) (((x)&0xF00F) == 0x300D)
83 #define IS_SUB(x) (((x)&0xF00F) == 0x3008)
85 #define IS_SUBC(x) (((x)&0xF00F) == 0x300A)
86 #define IS_SUBV(x) (((x)&0xF00F) == 0x300B)
87 #define IS_ADD(x) (((x)&0xF00F) == 0x300C)
88 #define IS_ADDC(x) (((x)&0xF00F) == 0x300E)
89 #define IS_ADDV(x) (((x)&0xF00F) == 0x300F)
90 #define IS_MACW(x) (((x)&0xF00F) == 0x400F)
91 #define IS_JSR(x) (((x)&0xf0ff) == 0x400b)
92 #define IS_JMP(x) (((x)&0xf0ff) == 0x402b)
93 #define IS_CMPPL(x) (((x)&0xf0ff) == 0x4015)
94 #define IS_CMPPZ(x) (((x)&0xf0ff) == 0x4011)
95 #define IS_LDCSR(x) (((x)&0xF0FF) == 0x400E)
96 #define IS_LDCGBR(x) (((x)&0xF0FF) == 0x401E)
97 #define IS_LDCVBR(x) (((x)&0xF0FF) == 0x402E)
98 #define IS_LDCLSR(x) (((x)&0xF0FF) == 0x4007)
99 #define IS_LDCLSRGBR(x) (((x)&0xF0FF) == 0x4017)
100 #define IS_LDCLSRVBR(x) (((x)&0xF0FF) == 0x4027)
101 #define IS_LDSMACH(x) (((x)&0xF0FF) == 0x400A)
102 #define IS_LDSMACL(x) (((x)&0xF0FF) == 0x401A)
103 #define IS_LDSLMACH(x) (((x)&0xF0FF) == 0x4006)
104 #define IS_LDSLMACL(x) (((x)&0xF0FF) == 0x4016)
105 #define IS_LDSPR(x) (((x)&0xF0FF) == 0x402A)
106 #define IS_LDSLPR(x) (((x)&0xF0FF) == 0x4026)
111 #define IS_ROTCR(x) (((x)&0xF0FF) == 0x4025)
112 #define IS_ROTCL(x) (((x)&0xF0FF) == 0x4024)
113 #define IS_ROTL(x) (((x)&0xF0FF) == 0x4004)
114 #define IS_ROTR(x) (((x)&0xF0FF) == 0x4005)
120 #define IS_STSLMACL(x) (((x)&0xF0FF) == 0x4012)
121 #define IS_STSLMACH(x) (((x)&0xF0FF) == 0x4002)
122 #define IS_STCLSR(x) (((x)&0xF0FF) == 0x4003)
123 #define IS_STCLGBR(x) (((x)&0xF0FF) == 0x4013)
124 #define IS_STCLVBR(x) (((x)&0xF0FF) == 0x4023)
126 #define IS_STSLPR(x) (((x)&0xF0FF) == 0x4022)
129 #define IS_TASB(x) (((x)&0xF0FF) == 0x401B)
130 #define IS_DT(x) (((x)&0xF0FF) == 0x4010)
132 #define IS_MOVB_REGREF_TO_REG(x) (((x)&0xF00F) == 0x6000)
133 #define IS_MOVW_REGREF_TO_REG(x) (((x)&0xF00F) == 0x6001)
134 #define IS_MOVL_REGREF_TO_REG(x) (((x)&0xF00F) == 0x6002)
135 #define IS_MOV_REGS(x) (((x)&0xf00f) == 0x6003)
136 #define IS_MOVB_POP(x) (((x)&0xF00F) == 0x6004)
137 #define IS_MOVW_POP(x) (((x)&0xF00F) == 0x6005)
138 #define IS_MOVL_POP(x) (((x)&0xF00F) == 0x6006)
139 #define IS_NOT(x) (((x)&0xF00F) == 0x6007)
140 #define IS_SWAPB(x) (((x)&0xF00F) == 0x6008)
141 #define IS_SWAPW(x) (((x)&0xF00F) == 0x6009)
142 #define IS_NEG(x) (((x)&0xF00F) == 0x600B)
143 #define IS_NEGC(x) (((x)&0xF00F) == 0x600A)
144 #define IS_EXT(x) (((x)&0xF00C) == 0x600C)
146 #define IS_MOVB_R0_REGDISP(x) (((x)&0xFF00) == 0x8000)
147 #define IS_MOVW_R0_REGDISP(x) (((x)&0xFF00) == 0x8100)
149 #define IS_MOVB_REGDISP_R0(x) (((x)&0xFF00) == 0x8400)
150 #define IS_MOVW_REGDISP_R0(x) (((x)&0xFF00) == 0x8500)
151 #define IS_CMPIMM(x) (((x)&0xFF00) == 0x8800)
153 #define IS_BT(x) (((x)&0xff00) == 0x8900)
154 #define IS_BF(x) (((x)&0xff00) == 0x8B00)
155 #define IS_BTS(x) (((x)&0xff00) == 0x8D00)
156 #define IS_BFS(x) (((x)&0xff00) == 0x8F00)
157 #define IS_BT_OR_BF(x) IS_BT(x) || IS_BTS(x) || IS_BF(x) || IS_BFS(x)
159 #define IS_MOVB_R0_GBRREF(x) (((x)&0xFF00) == 0xC000)
160 #define IS_MOVW_R0_GBRREF(x) (((x)&0xFF00) == 0xC100)
161 #define IS_MOVL_R0_GBRREF(x) (((x)&0xFF00) == 0xC200)
162 #define IS_TRAP(x) (((x)&0xFF00) == 0xC300)
163 #define IS_MOVB_GBRREF_R0(x) (((x)&0xFF00) == 0xC400)
164 #define IS_MOVW_GBRREF_R0(x) (((x)&0xFF00) == 0xC500)
165 #define IS_MOVL_GBRREF_R0(x) (((x)&0xFF00) == 0xC600)
166 #define IS_MOVA_PCREL_R0(x) (((x)&0xFF00) == 0xC700)
167 #define IS_BINLOGIC_IMM_R0(x) (((x)&0xFC00) == 0xC800)
168 #define IS_BINLOGIC_IMM_GBR(x) (((x)&0xFC00) == 0xCC00)
171 #define GET_BRA_OFFSET(x) ((x)&0x0fff)
172 #define GET_BTF_OFFSET(x) ((x)&0x00ff)
175 #define GET_TARGET_REG(x) (((x) >> 8) & 0x0f)
176 #define GET_SOURCE_REG(x) (((x) >> 4) & 0x0f)
185 if ((
off & 0x0800) == 0x0800) {
188 return (
op->addr) + (
off << 1) + 4;
197 if ((
off & 0x80) == 0x80) {
200 return (
off << 1) +
pc + 4;
203 static char *
regs[] = {
"r0",
"r1",
"r2",
"r3",
"r4",
"r5",
"r6",
"r7",
"r8",
"r9",
"r10",
"r11",
"r12",
"r13",
"r14",
"r15",
"pc" };
251 ret->
delta = disp << 1;
253 ret->
base = (
op->addr + 4) & ~0x03;
254 ret->
delta = disp << 2;
276 rz_strbuf_setf(&
op->esil,
"1,SETD,pc,2,+,pr,=,r%d,2,+,pc,+=",
GET_TARGET_REG(
code));
294 rz_strbuf_setf(&
op->esil,
"1,SETD,r15,[4],pc,=,r15,4,+,[4],0xFFF0FFF,&,sr,=,8,r15,+=");
314 rz_strbuf_setf(&
op->esil,
"r0,r%d,+,[1],r%d,=,0x000000FF,r%d,&=,r%d,0x80,&,?{,0xFFFFFF00,r%d,|=,}",
GET_SOURCE_REG(
code),
GET_TARGET_REG(
code),
GET_TARGET_REG(
code),
GET_TARGET_REG(
code),
GET_TARGET_REG(
code));
319 rz_strbuf_setf(&
op->esil,
"r0,r%d,+,[2],r%d,=,0x0000FFFF,r%d,&=,r%d,0x8000,&,?{,0xFFFF0000,r%d,|=,}",
GET_SOURCE_REG(
code),
GET_TARGET_REG(
code),
GET_TARGET_REG(
code),
GET_TARGET_REG(
code),
GET_TARGET_REG(
code));
388 "mach,0x80000000,&,!,"
399 "0xffffffff00000000,&,>>,mach,=,"
400 "0xffffffff,&,macl,=,"
401 "0x2,sr,&,!,?{,BREAK,},"
403 "0x80000000,mach,&,!,&,"
404 "?{,0x00007fff,mach,=,0xffffffff,macl,=,},"
406 "0x80000000,mach,&,!,!,&,"
407 "?{,0xffff8000,mach,=,0x0,macl,=,},"
468 rz_strbuf_setf(&
op->esil,
"1,sr,|=,r%d,r%d,&,?{,0xFFFFFFFE,sr,&=,}",
GET_SOURCE_REG(
code),
GET_TARGET_REG(
code));
473 rz_strbuf_setf(&
op->esil,
"0xFFFFFFFE,sr,&=,24,r%d,r%d,^,>>,0xFF,&,!,?{,1,sr,|=,},16,r%d,r%d,^,>>,0xFF,&,!,?{,1,sr,|=,},8,r%d,r%d,^,>>,0xFF,&,!,?{,1,sr,|=,},r%d,r%d,^,0xFF,&,!,?{,1,sr,|=,}",
GET_SOURCE_REG(
code),
GET_TARGET_REG(
code),
GET_SOURCE_REG(
code),
GET_TARGET_REG(
code),
GET_SOURCE_REG(
code),
GET_TARGET_REG(
code),
GET_SOURCE_REG(
code),
GET_TARGET_REG(
code));
479 rz_strbuf_setf(&
op->esil,
"16,r%d,0xFFFF,&,<<,16,r%d,0xFFFF0000,&,>>,|,r%d,=",
GET_SOURCE_REG(
code),
GET_TARGET_REG(
code),
GET_TARGET_REG(
code));
482 rz_strbuf_setf(&
op->esil,
"0xFFFFFCFE,sr,&=,r%d,0x80000000,&,?{,0x200,sr,|=,},r%d,0x80000000,&,?{,0x100,sr,|=,},sr,1,sr,<<,^,0x200,&,?{,1,sr,|=,}",
GET_SOURCE_REG(
code),
GET_TARGET_REG(
code));
487 rz_strbuf_setf(&
op->esil,
"r%d,0xFFFF,&,r%d,0xFFFF,&,*,macl,=",
GET_SOURCE_REG(
code),
GET_TARGET_REG(
code));
509 rz_strbuf_setf(&
op->esil,
"sr,0x1,&,0xFFFFFFFE,sr,&=,r%d,+=,31,$c,sr,|,sr,:=,r%d,r%d,+=,31,$c,sr,|,sr,:=",
GET_TARGET_REG(
code),
GET_SOURCE_REG(
code),
GET_TARGET_REG(
code));
514 rz_strbuf_setf(&
op->esil,
"0xFFFFFFFE,sr,&=,r%d,r%d,+=,31,$o,sr,|=",
GET_SOURCE_REG(
code),
GET_TARGET_REG(
code));
524 rz_strbuf_setf(&
op->esil,
"sr,1,&," CLR_T ",r%d,-=,31,$b,sr,|,sr,:=,r%d,r%d,-=,31,$b,sr,|,sr,:=",
GET_TARGET_REG(
code),
GET_SOURCE_REG(
code),
GET_TARGET_REG(
code));
529 rz_strbuf_setf(&
op->esil,
CLR_T ",r%d,r%d,-=,31,$o,sr,|,sr,:=",
GET_SOURCE_REG(
code),
GET_TARGET_REG(
code));
534 rz_strbuf_setf(&
op->esil,
"0xFFFFFFFE,sr,&,r%d,r%d,^,!,|,sr,=",
GET_SOURCE_REG(
code),
GET_TARGET_REG(
code));
539 rz_strbuf_setf(&
op->esil,
"0xFFFFFFFE,sr,&=,r%d,r%d,>=,?{,0x1,sr,|=,}",
GET_SOURCE_REG(
code),
GET_TARGET_REG(
code));
544 rz_strbuf_setf(&
op->esil,
"0xFFFFFFFE,sr,&=,r%d,r%d,>,?{,0x1,sr,|=,}",
GET_SOURCE_REG(
code),
GET_TARGET_REG(
code));
549 rz_strbuf_setf(&
op->esil,
"0xFFFFFFFE,sr,&=,r%d,0x100000000,+,r%d,0x100000000,+,>,?{,0x1,sr,|=,}",
GET_SOURCE_REG(
code),
GET_TARGET_REG(
code));
554 rz_strbuf_setf(&
op->esil,
"0xFFFFFFFE,sr,&=,r%d,0x100000000,+,r%d,0x100000000,+,>=,?{,0x1,sr,|=,}",
GET_SOURCE_REG(
code),
GET_TARGET_REG(
code));
560 "1,sr,>>,sr,^,0x80,&,"
562 "1,r%d,DUP,0x80000000,&,?{,0x80,sr,|=,},<<,sr,0x1,&,|,r%d,=,"
575 "1,sr,>>,sr,^,0x80,&,!,sr,|=",
587 rz_strbuf_setf(&
op->esil,
"32,r%d,r%d,*,DUP,0xFFFFFFFF,&,macl,=,>>,mach,=",
GET_SOURCE_REG(
code),
GET_TARGET_REG(
code));
592 rz_strbuf_setf(&
op->esil,
"32,r%d,r%d,0x80000000,&,?{,0xFFFFFFFF00000000,+,},r%d,r%d,0x80000000,&,?{,0xFFFFFFFF00000000,+,},*,DUP,0xFFFFFFFF,&,macl,=,>>,mach,=",
GET_SOURCE_REG(
code),
GET_SOURCE_REG(
code),
GET_TARGET_REG(
code),
GET_TARGET_REG(
code));
598 switch (
code & 0xF0FF) {
601 rz_strbuf_setf(&
op->esil,
"0xFFFFFFFE,sr,&=,r%d,0x80000000,&,?{,0x1,sr,|=,},1,r%d,<<=",
GET_TARGET_REG(
code),
GET_TARGET_REG(
code));
605 rz_strbuf_setf(&
op->esil,
"0xFFFFFFFE,sr,&=,r%d,0x1,&,?{,0x1,sr,|=,},0,r%d,0x80000000,&,?{,0x80000000,+,},1,r%d,>>=,r%d,|=",
GET_TARGET_REG(
code),
GET_TARGET_REG(
code),
GET_TARGET_REG(
code),
GET_TARGET_REG(
code));
609 rz_strbuf_setf(&
op->esil,
"0xFFFFFFFE,sr,&=,r%d,0x80000000,&,?{,0x1,sr,|=,},1,r%d,<<=",
GET_TARGET_REG(
code),
GET_TARGET_REG(
code));
624 rz_strbuf_setf(&
op->esil,
"0xFFFFFFFE,sr,&=,r%d,0x1,&,?{,0x1,sr,|=,},1,r%d,>>=",
GET_TARGET_REG(
code),
GET_TARGET_REG(
code));
648 rz_strbuf_setf(&
op->esil,
"1,SETD,pc,2,+,pr,=,r%d,pc,=",
GET_TARGET_REG(
code));
657 rz_strbuf_setf(&
op->esil,
"0xFFFFFFFE,sr,&=,0,r%d,>,?{,0x1,sr,|=,}",
GET_TARGET_REG(
code));
660 rz_strbuf_setf(&
op->esil,
"0xFFFFFFFE,sr,&=,0,r%d,>=,?{,0x1,sr,|=,}",
GET_TARGET_REG(
code));
663 rz_strbuf_setf(&
op->esil,
"r%d,[4],0x0FFF0FFF,&,sr,=,4,r%d,+=",
GET_TARGET_REG(
code),
GET_TARGET_REG(
code));
699 rz_strbuf_setf(&
op->esil,
"0xFFFFFFFE,sr,&=,r%d,0x1,&,sr,|=,0x1,r%d,>>>,r%d,=",
GET_TARGET_REG(
code),
GET_TARGET_REG(
code),
GET_TARGET_REG(
code));
702 rz_strbuf_setf(&
op->esil,
"0xFFFFFFFE,sr,&=,0x1,r%d,<<<,r%d,=,r%d,0x1,&,sr,|=",
GET_TARGET_REG(
code),
GET_TARGET_REG(
code),
GET_TARGET_REG(
code));
705 rz_strbuf_setf(&
op->esil,
"0,sr,0x1,&,?{,0x80000000,},0xFFFFFFFE,sr,&=,r%d,1,&,sr,|=,1,r%d,>>=,r%d,|=",
GET_TARGET_REG(
code),
GET_TARGET_REG(
code),
GET_TARGET_REG(
code));
708 rz_strbuf_setf(&
op->esil,
"sr,0x1,&,0xFFFFFFFE,sr,&=,r%d,0x80000000,&,?{,1,sr,|=,},1,r%d,<<=,r%d,|=",
GET_TARGET_REG(
code),
GET_TARGET_REG(
code),
GET_TARGET_REG(
code));
729 rz_strbuf_setf(&
op->esil,
"0xFFFFFFFE,sr,&=,r%d,[1],!,?{,0x80,r%d,=[1],1,sr,|=,}",
GET_TARGET_REG(
code),
GET_TARGET_REG(
code));
732 rz_strbuf_setf(&
op->esil,
"0xFFFFFFFE,sr,&=,1,r%d,-=,$z,sr,|,sr,:=",
GET_TARGET_REG(
code));
745 "0xffffffff00000000,&,>>,mach,=,"
746 "0xffffffff,&,macl,=,"
753 "macl,0x80000000,&,?{,"
790 rz_strbuf_setf(&
op->esil,
"0x000000FF,r%d,&=,r%d,[1],DUP,0x80,&,?{,0xFFFFFF00,|=,},r%d,=",
GET_TARGET_REG(
code),
GET_SOURCE_REG(
code),
GET_TARGET_REG(
code));
795 rz_strbuf_setf(&
op->esil,
"0x0000FFFF,r%d,&=,r%d,[2],DUP,0x8000,&,?{,0xFFFF0000,|=,},r%d,=",
GET_TARGET_REG(
code),
GET_SOURCE_REG(
code),
GET_TARGET_REG(
code));
806 switch (
code & 0xF) {
814 rz_strbuf_setf(&
op->esil,
"r%d,0xFF,&,DUP,0x80,&,?{,0xFFFFFF00,|,},r%d,=",
GET_SOURCE_REG(
code),
GET_TARGET_REG(
code));
817 rz_strbuf_setf(&
op->esil,
"r%d,0xFFFF,&,DUP,0x8000,&,?{,0xFFFF0000,|,},r%d,=",
GET_SOURCE_REG(
code),
GET_TARGET_REG(
code));
826 rz_strbuf_setf(&
op->esil,
"r%d,[1],DUP,0x80,&,?{,0xFFFFFF00,|,},r%d,=,1,r%d,+=",
GET_SOURCE_REG(
code),
GET_TARGET_REG(
code),
GET_SOURCE_REG(
code));
830 rz_strbuf_setf(&
op->esil,
"r%d,[2],DUP,0x8000,&,?{,0xFFFF0000,|,},r%d,=,2,r%d,+=",
GET_SOURCE_REG(
code),
GET_TARGET_REG(
code),
GET_SOURCE_REG(
code));
834 rz_strbuf_setf(&
op->esil,
"r%d,[4],r%d,=,4,r%d,+=",
GET_SOURCE_REG(
code),
GET_TARGET_REG(
code),
GET_SOURCE_REG(
code));
843 rz_strbuf_setf(&
op->esil,
"1,sr,&,0xFFFFFFFE,sr,&=,r%d,+,0,-,31,$b,sr,|,sr,=,r%d,=",
GET_SOURCE_REG(
code),
GET_TARGET_REG(
code));
853 rz_strbuf_setf(&
op->esil,
"r%d,0xFFFF0000,&,8,r%d,0xFF,&,<<,|,8,r%d,0xFF00,&,>>,|,r%d,=",
GET_SOURCE_REG(
code),
GET_SOURCE_REG(
code),
GET_SOURCE_REG(
code),
GET_TARGET_REG(
code));
857 rz_strbuf_setf(&
op->esil,
"16,r%d,0xFFFF,&,<<,16,r%d,0xFFFF0000,&,>>,|,r%d,=",
GET_SOURCE_REG(
code),
GET_SOURCE_REG(
code),
GET_TARGET_REG(
code));
868 rz_strbuf_setf(&
op->esil,
"0x%x,DUP,0x80,&,?{,0xFFFFFF00,|,},r%d,+=",
code & 0xFF,
GET_TARGET_REG(
code));
876 op->fail =
op->addr + 2;
881 rz_strbuf_setf(&
op->esil,
"1,SETD,sr,1,&,?{,0x%" PFMT64x ",pc,=,}",
op->jump);
884 rz_strbuf_setf(&
op->esil,
"1,SETD,sr,1,&,!,?{,0x%" PFMT64x ",pc,=,}",
op->jump);
887 rz_strbuf_setf(&
op->esil,
"sr,1,&,!,?{,0x%" PFMT64x ",pc,=,}",
op->jump);
894 rz_strbuf_setf(&
op->esil,
"r%d,0x%x,+,[1],DUP,0x80,&,?{,0xFFFFFF00,|,},r0,=",
GET_SOURCE_REG(
code),
code & 0xF);
900 rz_strbuf_setf(&
op->esil,
"r%d,0x%x,+,[2],DUP,0x8000,&,?{,0xFFFF0000,|,},r0,=",
GET_SOURCE_REG(
code), (
code & 0xF) * 2);
903 rz_strbuf_setf(&
op->esil,
"0xFFFFFFFE,sr,&=,0x%x,DUP,0x80,&,?{,0xFFFFFF00,|,},r0,==,$z,sr,|,sr,:=",
code & 0xFF);
925 op->src[0]->base = (
code & 0xFF) * 2 +
op->addr + 4;
926 op->src[0]->memref = 1;
927 rz_strbuf_setf(&
op->esil,
"0x%" PFMT64x ",[2],r%d,=,r%d,0x8000,&,?{,0xFFFF0000,r%d,|=,}",
op->src[0]->base,
GET_TARGET_REG(
code),
GET_TARGET_REG(
code),
GET_TARGET_REG(
code));
948 rz_strbuf_setf(&
op->esil,
"1,SETD,pc,2,+,pr,=,0x%" PFMT64x ",pc,=",
op->jump);
956 rz_strbuf_setf(&
op->esil,
"4,r15,-=,sr,r15,=[4],4,r15,-=,2,pc,-,r15,=[4],2,0x%x,<<,4,+,vbr,+,pc,=",
code & 0xFF);
967 switch (
code & 0xFF00) {
971 rz_strbuf_setf(&
op->esil,
"0xFFFFFFFE,sr,&=,r0,0x%x,&,!,?{,1,sr,|=,}",
code & 0xFF);
988 switch (
code & 0xFF00) {
992 rz_strbuf_setf(&
op->esil,
"0xFFFFFFFE,sr,&=,r0,gbr,+,[1],0x%x,&,!,?{,1,sr,|=,}",
code & 0xFF);
996 rz_strbuf_setf(&
op->esil,
"r0,gbr,+,[1],0x%x,&,r0,gbr,+,=[1]",
code & 0xFF);
1000 rz_strbuf_setf(&
op->esil,
"r0,gbr,+,[1],0x%x,^,r0,gbr,+,=[1]",
code & 0xFF);
1004 rz_strbuf_setf(&
op->esil,
"r0,gbr,+,[1],0x%x,|,r0,gbr,+,=[1]",
code & 0xFF);
1023 rz_strbuf_setf(&
op->esil,
"gbr,0x%x,+,[1],DUP,0x80,&,?{,0xFFFFFF00,|,},r0,=", (
code & 0xFF));
1027 rz_strbuf_setf(&
op->esil,
"gbr,0x%x,+,[2],DUP,0x8000,&,?{,0xFFFF0000,|,},r0,=", (
code & 0xFF) * 2);
1053 rz_strbuf_setf(&
op->esil,
"0x%x,r%d,=,r%d,0x80,&,?{,0xFFFFFF00,r%d,|=,}",
code & 0xFF,
GET_TARGET_REG(
code),
GET_TARGET_REG(
code),
GET_TARGET_REG(
code));
1090 if (!data ||
len < 2) {
1098 op_MSB = analysis->
big_endian ? data[0] : data[1];
1099 op_LSB = analysis->
big_endian ? data[1] : data[0];
1100 ut16 opcode = (
ut16)op_MSB << 8 | op_LSB;
1106 ctx->use_banked =
true;
1136 "gpr r0b .32 32 0\n"
1137 "gpr r1b .32 36 0\n"
1138 "gpr r2b .32 40 0\n"
1139 "gpr r3b .32 44 0\n"
1140 "gpr r4b .32 48 0\n"
1141 "gpr r5b .32 52 0\n"
1142 "gpr r6b .32 56 0\n"
1143 "gpr r7b .32 60 0\n"
1146 "gpr r10 .32 72 0\n"
1147 "gpr r11 .32 76 0\n"
1148 "gpr r12 .32 80 0\n"
1149 "gpr r13 .32 84 0\n"
1150 "gpr r14 .32 88 0\n"
1151 "gpr r15 .32 92 0\n"
1153 "gpr sr .32 100 0\n"
1154 "gpr sr_t .1 100.0 0\n"
1155 "gpr sr_s .1 100.1 0\n"
1156 "gpr sr_i .4 100.4 0\n"
1157 "gpr sr_q .1 101.0 0\n"
1158 "gpr sr_m .1 101.1 0\n"
1159 "gpr sr_f .1 101.7 0\n"
1160 "gpr sr_b .1 103.4 0\n"
1161 "gpr sr_r .1 103.5 0\n"
1162 "gpr sr_d .1 103.6 0\n"
1163 "gpr gbr .32 104 0\n"
1164 "gpr ssr .32 108 0\n"
1165 "gpr spc .32 112 0\n"
1166 "gpr sgr .32 116 0\n"
1167 "gpr dbr .32 120 0\n"
1168 "gpr vbr .32 124 0\n"
1169 "gpr mach .32 128 0\n"
1170 "gpr macl .32 132 0\n"
1171 "gpr pr .32 136 0\n";
1187 .desc =
"SH-4 code analysis plugin",
1199 #ifndef RZ_PLUGIN_INCORE
RZ_API RzAnalysisValue * rz_analysis_value_new(void)
static RzAnalysisValue * analysis_fill_ai_rg(RzAnalysis *analysis, int idx)
static RzAnalysisValue * analysis_fill_reg_disp_mem(RzAnalysis *analysis, int reg, st64 delta, st64 size)
static ut64 disarm_8bit_offset(ut64 pc, ut32 offs)
#define IS_MOVB_GBRREF_R0(x)
static int movl_rdisp_reg(RzAnalysis *analysis, RzAnalysisOp *op, ut16 code)
#define GET_BTF_OFFSET(x)
#define IS_MOVL_REG_TO_REGREF(x)
static int(* first_nibble_decode[])(RzAnalysis *, RzAnalysisOp *, ut16)
static int first_nibble_is_3(RzAnalysis *analysis, RzAnalysisOp *op, ut16 code)
#define GET_SOURCE_REG(x)
#define IS_MOVB_REG_TO_REGREF(x)
RzAnalysisPlugin rz_analysis_plugin_sh
#define GET_BRA_OFFSET(x)
#define IS_MOVB_R0_REGDISP(x)
static int movl_reg_rdisp(RzAnalysis *analysis, RzAnalysisOp *op, ut16 code)
static int movl_pcdisp_reg(RzAnalysis *analysis, RzAnalysisOp *op, ut16 code)
static int first_nibble_is_4(RzAnalysis *analysis, RzAnalysisOp *op, ut16 code)
static RzAnalysisValue * analysis_fill_r0_reg_ref(RzAnalysis *analysis, int reg, st64 size)
static RzAnalysisValue * analysis_fill_reg_ref(RzAnalysis *analysis, int reg, st64 size)
#define IS_MOVW_REG_TO_R0REL(x)
static RZ_OWN char * sh_get_reg_profile(RzAnalysis *analysis)
static int movw_pcdisp_reg(RzAnalysis *analysis, RzAnalysisOp *op, ut16 code)
static ut64 disarm_12bit_offset(RzAnalysisOp *op, unsigned int insoff)
static int first_nibble_is_8(RzAnalysis *analysis, RzAnalysisOp *op, ut16 code)
static int add_imm(RzAnalysis *analysis, RzAnalysisOp *op, ut16 code)
#define GET_TARGET_REG(x)
#define IS_MOVW_REG_TO_REGREF(x)
#define IS_BINLOGIC_IMM_R0(x)
static int first_nibble_is_0(RzAnalysis *analysis, RzAnalysisOp *op, ut16 code)
RZ_API RzLibStruct rizin_plugin
#define IS_MOVL_R0_GBRREF(x)
#define IS_MOVB_REG_TO_R0REL(x)
#define IS_MOVW_REGDISP_R0(x)
static int first_nibble_is_6(RzAnalysis *analysis, RzAnalysisOp *op, ut16 code)
static RzAnalysisValue * analysis_fill_im(RzAnalysis *analysis, st32 v)
#define IS_MOVL_REGREF_TO_REG(x)
#define IS_MOVW_R0_GBRREF(x)
#define IS_MOVW_GBRREF_R0(x)
#define IS_MOVB_R0REL_TO_REG(x)
#define IS_MOVA_PCREL_R0(x)
static int bra(RzAnalysis *analysis, RzAnalysisOp *op, ut16 code)
#define IS_MOVB_REGDISP_R0(x)
static int sh_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *data, int len, RzAnalysisOpMask mask)
static RzAnalysisValue * analysis_regrel_jump(RzAnalysis *analysis, RzAnalysisOp *op, ut8 reg)
static RzAnalysisValue * analysis_pcrel_disp_mov(RzAnalysis *analysis, RzAnalysisOp *op, ut8 disp, int size)
#define IS_MOVL_REG_TO_R0REL(x)
static int mov_imm_reg(RzAnalysis *analysis, RzAnalysisOp *op, ut16 code)
#define IS_MOVW_R0REL_TO_REG(x)
static int bsr(RzAnalysis *analysis, RzAnalysisOp *op, ut16 code)
static int first_nibble_is_c(RzAnalysis *analysis, RzAnalysisOp *op, ut16 code)
static int archinfo(RzAnalysis *analysis, int q)
#define IS_MOVW_R0_REGDISP(x)
#define IS_MOVL_R0REL_TO_REG(x)
static int fpu_insn(RzAnalysis *analysis, RzAnalysisOp *op, ut16 code)
#define IS_MOVB_R0_GBRREF(x)
#define IS_MOVB_REGREF_TO_REG(x)
#define IS_BINLOGIC_IMM_GBR(x)
static int first_nibble_is_2(RzAnalysis *analysis, RzAnalysisOp *op, ut16 code)
#define IS_MOVL_GBRREF_R0(x)
#define IS_MOVW_REGREF_TO_REG(x)
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")
RZ_API RzRegItem * rz_reg_get(RzReg *reg, const char *name, int type)
#define RZ_ANALYSIS_ARCHINFO_ALIGN
@ RZ_ANALYSIS_OP_FAMILY_FPU
@ RZ_ANALYSIS_OP_TYPE_CMP
@ RZ_ANALYSIS_OP_TYPE_SUB
@ RZ_ANALYSIS_OP_TYPE_LOAD
@ RZ_ANALYSIS_OP_TYPE_UNK
@ RZ_ANALYSIS_OP_TYPE_MUL
@ RZ_ANALYSIS_OP_TYPE_ROL
@ RZ_ANALYSIS_OP_TYPE_JMP
@ RZ_ANALYSIS_OP_TYPE_AND
@ RZ_ANALYSIS_OP_TYPE_SAL
@ RZ_ANALYSIS_OP_TYPE_UJMP
@ RZ_ANALYSIS_OP_TYPE_ROR
@ RZ_ANALYSIS_OP_TYPE_SWI
@ RZ_ANALYSIS_OP_TYPE_SAR
@ RZ_ANALYSIS_OP_TYPE_CALL
@ RZ_ANALYSIS_OP_TYPE_ADD
@ RZ_ANALYSIS_OP_TYPE_STORE
@ RZ_ANALYSIS_OP_TYPE_PUSH
@ RZ_ANALYSIS_OP_TYPE_SHR
@ RZ_ANALYSIS_OP_TYPE_POP
@ RZ_ANALYSIS_OP_TYPE_CJMP
@ RZ_ANALYSIS_OP_TYPE_DIV
@ RZ_ANALYSIS_OP_TYPE_MOV
@ RZ_ANALYSIS_OP_TYPE_SHL
@ RZ_ANALYSIS_OP_TYPE_UCALL
@ RZ_ANALYSIS_OP_TYPE_NOT
@ RZ_ANALYSIS_OP_TYPE_RET
@ RZ_ANALYSIS_OP_TYPE_NOP
@ RZ_ANALYSIS_OP_TYPE_ACMP
@ RZ_ANALYSIS_OP_TYPE_LEA
@ RZ_ANALYSIS_OP_TYPE_RCALL
@ RZ_ANALYSIS_OP_TYPE_XOR
RZ_API const char * rz_strbuf_setf(RzStrBuf *sb, const char *fmt,...) RZ_PRINTF_CHECK(2
RZ_IPI RZ_OWN SHOp * sh_disassembler(ut16 opcode)
Disassemble opcode and return a SHOp.
RZ_IPI bool rz_sh_il_opcode(RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL RzAnalysisOp *aop, ut64 pc, RZ_BORROW RZ_NONNULL const SHOp *op, RZ_NULLABLE SHILContext *ctx)
Store the lifted IL for op in aop This function also takes care of initializing and adding the privil...
RZ_IPI RzAnalysisILConfig * rz_sh_il_config(RZ_NONNULL RzAnalysis *analysis)
Initialize new config for the SuperH IL.
To store the context of the IL lifter ; Used to pass around information outside effects Other context...
ut64(WINAPI *w32_GetEnabledXStateFeatures)()