7 static const char *
const regs[33] = {
8 "zero",
"at",
"v0",
"v1",
"a0",
"a1",
"a2",
"a3",
9 "t0",
"t1",
"t2",
"t3",
"t4",
"t5",
"t6",
"t7",
10 "s0",
"s1",
"s2",
"s3",
"s4",
"s5",
"s6",
"s7",
11 "t8",
"t9",
"k0",
"k1",
"gp",
"sp",
"s8",
"ra",
22 {
"nop",
'N', 0, 0, 0 },
23 {
"lui",
'I', 2, 15, 0 },
24 {
"sw",
'I', 3, 43, 0 },
25 {
"sh",
'I', 3, 41, 0 },
26 {
"sb",
'I', 3, 40, 0 },
27 {
"lw",
'I', 3, 35, 0 },
28 {
"lh",
'I', 3, 33, 0 },
29 {
"lb",
'I', 3, 32, 0 },
30 {
"ori",
'I', 3, 13, 0 },
31 {
"andi",
'I', 3, 12, 0 },
32 {
"xori",
'I', 3, 14, 0 },
33 {
"addi",
'I', 3, 8, 0 },
34 {
"addiu",
'I', 3, 9, 0 },
35 {
"b",
'B', -1, 4, 0 },
36 {
"bnez",
'B', 2, 5, 0 },
37 {
"bal",
'B', -1, -1, 17 },
38 {
"bne",
'B', 3, 5, 0 },
39 {
"beq",
'B', 3, 4, 0 },
40 {
"bgez",
'B', -2, -1, 1 },
41 {
"bgezal",
'B', -2, -1, 17 },
42 {
"bltzal",
'B', -2, -1, 16 },
43 {
"bgtz",
'B', -2, 7, 0 },
44 {
"blez",
'B', -2, 6, 0 },
45 {
"bltz",
'B', -2, 1, 0 },
46 {
"syscall",
'R', 0, 12, 0 },
47 {
"break",
'R', 0, 13, 0 },
48 {
"nor",
'R', 3, 39, 0 },
49 {
"or",
'R', 3, 37, 0 },
50 {
"xor",
'R', 3, 38, 0 },
51 {
"and",
'R', 3, 36, 0 },
52 {
"sll",
'R', -3, 0, 0 },
53 {
"sllv",
'R', 3, 4, 0 },
54 {
"slt",
'R', 3, 42, 0 },
55 {
"sltu",
'R', 3, 43, 0 },
56 {
"sra",
'R', -3, 3, 0 },
57 {
"srl",
'R', -3, 2, 0 },
58 {
"srlv",
'R', 3, 6, 0 },
59 {
"srav",
'R', 3, 7, 0 },
60 {
"add",
'R', 3, 32, 0 },
61 {
"move",
'R', -2, 32, 0 },
62 {
"addu",
'R', 3, 33, 0 },
63 {
"sub",
'R', 3, 34, 0 },
64 {
"subu",
'R', 3, 35, 0 },
65 {
"mult",
'R', 2, 24, 0 },
66 {
"multu",
'R', 2, 25, 0 },
67 {
"div",
'R', 2, 26, 0 },
68 {
"divu",
'R', 2, 27, 0 },
69 {
"mfhi",
'R', 1, 16, 0 },
70 {
"mflo",
'R', 1, 18, 0 },
71 {
"mthi",
'R', 1, 17, 0 },
72 {
"mtlo",
'R', 1, 19, 0 },
73 {
"jalr",
'R', -2, 9, 0 },
74 {
"jr",
'R', 1, 8, 0 },
75 {
"jal",
'J', 1, 3, 0 },
76 {
"j",
'J', 1, 2, 0 },
84 if (
rs < 0 || rt < 0 ||
rd < 0 || sa < 0) {
87 b[3] = ((
op << 2) & 0xfc) | ((
rs >> 3) & 3);
88 b[2] = (
rs << 5) | (rt & 0x1f);
89 b[1] = ((
rd << 3) & 0xff) | (sa >> 2);
90 b[0] = (fun & 0x3f) | ((sa & 3) << 6);
95 if (
rs < 0 || rt < 0) {
106 b[3] = ((
op << 2) & 0xfc) | ((
rs >> 3) & 3);
107 b[2] = (
rs << 5) | (rt);
108 b[1] = (
imm >> 8) & 0xff;
115 b[3] = ((
op << 2) & 0xfc) | ((
addr >> 24) & 3);
116 b[2] = (
addr >> 16) & 0xff;
117 b[1] = (
addr >> 8) & 0xff;
125 RZ_LOG_ERROR(
"assembler: mips: invalid assembly (missing an argument).\n");
130 if (!strcmp(
p,
regs[
n])) {
141 if (
n != 0 ||
p[0] ==
'0') {
144 RZ_LOG_ERROR(
"assembler: mips: invalid reg name (%s) at pos %d.\n",
p,
n);
150 char w0[32],
w1[32],
w2[32],
w3[32];
166 if (!strncmp(
s,
"jalr", 4) && !strchr(
s,
',')) {
168 const char *
arg = strchr(
s,
' ');
179 sscanf(
s,
"%31s",
w0);
181 for (
i = 0;
ops[
i].name;
i++) {
184 case 3: sscanf(
s,
"%31s %31s %31s %31s",
w0,
w1,
w2,
w3);
break;
185 case -3: sscanf(
s,
"%31s %31s %31s %31s",
w0,
w1,
w2,
w3);
break;
186 case 2: sscanf(
s,
"%31s %31s %31s",
w0,
w1,
w2);
break;
187 case -2: sscanf(
s,
"%31s %31s %31s",
w0,
w1,
w2);
break;
188 case 1: sscanf(
s,
"%31s %31s",
w0,
w1);
break;
189 case -1: sscanf(
s,
"%31s %31s",
w0,
w1);
break;
190 case 0: sscanf(
s,
"%31s",
w0);
break;
201 int op = 0,
rs = 0, rt = 0,
rd = 0, sa = 0,
fn = 0;
202 bool invalid =
false;
256 bool invalid =
false;
static int opstr(RzAsm *a, ut8 *data, const Opcode *op)
const lzma_allocator const uint8_t size_t uint8_t * out
RZ_API void Ht_() free(HtName_(Ht) *ht)
return memset(p, 0, total)
static const char struct stat static buf struct stat static buf static idle const char static path static fd const char static len const void static prot const char struct module static image struct kernel_sym static table unsigned char static buf static fsuid unsigned struct dirent unsigned static count const struct iovec static count static pid const void static len static flags const struct sched_param static p static pid static policy struct timespec static tp static suid unsigned fn
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")
static const char *const regs[33]
static int mips_r(ut8 *b, int op, int rs, int rt, int rd, int sa, int fun)
RZ_IPI int mips_assemble(const char *str, ut64 pc, ut8 *out)
static int getreg(const char *p)
static int mips_j(ut8 *b, int op, int addr)
static int mips_i(ut8 *b, int op, int rs, int rt, int imm, int is_branch)
#define RZ_LOG_ERROR(fmtstr,...)
RZ_API ut64 rz_num_get(RzNum *num, const char *str)
#define RZ_STR_ISEMPTY(x)
RZ_API int rz_str_replace_char(char *s, int a, int b)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()