mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-19 05:38:43 +00:00
Add ldrex strex to ARM assembler
This commit is contained in:
parent
25fec0ebec
commit
f6120770eb
@ -71,7 +71,10 @@ static ArmOp ops[] = {
|
||||
{ "cps", 0xb1, TYPE_IMM },
|
||||
{ "nop", 0xa0e1, -1 },
|
||||
|
||||
{ "ldrex", 0x9f0f9000, TYPE_MEM },
|
||||
{ "ldr", 0x9000, TYPE_MEM },
|
||||
|
||||
{ "strex", 0x900f8000, TYPE_MEM },
|
||||
{ "str", 0x8000, TYPE_MEM },
|
||||
|
||||
{ "blx", 0x30ff2fe1, TYPE_BRR },
|
||||
@ -855,32 +858,58 @@ static int findyz(int x, int *y, int *z) {
|
||||
|
||||
static int arm_assemble(ArmOpcode *ao, ut64 off, const char *str) {
|
||||
int i, j, ret, reg, a, b;
|
||||
bool rex = false;
|
||||
for (i = 0; ops[i].name; i++) {
|
||||
if (!strncmp (ao->op, ops[i].name, strlen (ops[i].name))) {
|
||||
ao->o = ops[i].code;
|
||||
arm_opcode_cond (ao, strlen(ops[i].name));
|
||||
if (ao->a[0] || ops[i].type == TYPE_BKP)
|
||||
switch (ops[i].type) {
|
||||
case TYPE_MEM:
|
||||
case TYPE_MEM:
|
||||
if (!strcmp (ops[i].name + 2, "rex")) {
|
||||
rex = 1;
|
||||
}
|
||||
getrange (ao->a[0]);
|
||||
getrange (ao->a[1]);
|
||||
getrange (ao->a[2]);
|
||||
if (ao->a[0] && ao->a[1]) {
|
||||
char rn[8];
|
||||
strncpy (rn, ao->a[1], 2);
|
||||
rn[2] = 0;
|
||||
ao->o |= getreg (ao->a[0]) << 20;
|
||||
ao->o |= getreg (rn) << 8; // delta
|
||||
strncpy (rn, ao->a[1], 7);
|
||||
int r0 = getreg (ao->a[0]);
|
||||
int r1 = getreg (ao->a[1]);
|
||||
if ( (r0 < 0 || r0 > 15) || (r1 > 15 || r1 < 0) ) {
|
||||
return 0;
|
||||
}
|
||||
ao->o |= r0 << 20;
|
||||
if (!strcmp (ops[i].name, "strex")) {
|
||||
ao->o |= r1 << 24;
|
||||
} else {
|
||||
ao->o |= r1 << 8; // delta
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = getreg (ao->a[2]);
|
||||
if (ret != -1) {
|
||||
ao->o |= (strstr (str,"],")) ? 6 : 7;
|
||||
ao->o |= (ret & 0x0f) << 24;
|
||||
if (rex) {
|
||||
ao->o |= 1;
|
||||
} else {
|
||||
ao->o |= (strstr (str,"],")) ? 6 : 7;
|
||||
}
|
||||
if (!strcmp (ops[i].name, "strex")) {
|
||||
ao->o |= (ret & 0x0f) << 8;
|
||||
} else {
|
||||
ao->o |= (ret & 0x0f) << 24;
|
||||
}
|
||||
} else {
|
||||
int num = getnum (ao->a[2]) & 0xfff;
|
||||
ao->o |= (strstr (str, "],")) ? 4 : 5;
|
||||
if (rex) {
|
||||
ao->o |= 1;
|
||||
} else {
|
||||
ao->o |= (strstr (str, "],")) ? 4 : 5;
|
||||
}
|
||||
ao->o |= 1;
|
||||
ao->o |= (num & 0xff) << 24;
|
||||
ao->o |= ((num >> 8) & 0xf) << 16;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user