mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-20 14:21:25 +00:00
Fix 'cmp' in ARM assembler
- gnu dis is confusing: cmp r3, 1, 30 -> cmp r3, 1<<(32-30)
This commit is contained in:
parent
da33633680
commit
3e5dc60379
1
Makefile
1
Makefile
@ -162,6 +162,7 @@ purge-dev:
|
||||
purge: purge-doc purge-dev
|
||||
for a in ${R2BINS} ; do rm -f ${DESTDIR}/${BINDIR}/$$a ; done
|
||||
rm -f ${DESTDIR}/${BINDIR}/ragg2-cc
|
||||
rm -f ${DESTDIR}/${BINDIR}/r2
|
||||
rm -f ${DESTDIR}/${LIBDIR}/libr_*
|
||||
rm -rf ${DESTDIR}/${LIBDIR}/radare2
|
||||
rm -rf ${DESTDIR}/${INCLUDEDIR}/libr
|
||||
|
@ -538,6 +538,22 @@ static int thumb_assemble(ArmOpcode *ao, const char *str) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int findyz(int x, int *y, int *z) {
|
||||
int i, j;
|
||||
for (i=0;i<0xff; i++) {
|
||||
for (j=0;j<0xf;j++) {
|
||||
int v = i<<j;
|
||||
if (v>x) continue;
|
||||
if (v==x) {
|
||||
*y = i;
|
||||
*z = 16-(j/2);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int arm_assemble(ArmOpcode *ao, const char *str) {
|
||||
int i, j, ret, reg, a, b;
|
||||
for (i=0; ops[i].name; i++) {
|
||||
@ -640,15 +656,23 @@ static int arm_assemble(ArmOpcode *ao, const char *str) {
|
||||
a = getreg (ao->a[0]);
|
||||
b = getreg (ao->a[1]);
|
||||
if (b == -1) {
|
||||
ut16 numshift;
|
||||
int y, z;
|
||||
b = getnum (ao->a[1]);
|
||||
if (b<0|| b>255) {
|
||||
eprintf ("Parameter out of range (0-255)\n");
|
||||
if (b>=0 && b<=0xff) {
|
||||
ao->o = 0x50e3;
|
||||
// TODO: if (b>255) -> automatic multiplier
|
||||
ao->o |= (a<<8);
|
||||
ao->o |= ((b&0xff)<<24);
|
||||
} else
|
||||
if (findyz (b, &y, &z)) {
|
||||
ao->o = 0x50e3;
|
||||
ao->o |= (y<<24);
|
||||
ao->o |= (z<<16);
|
||||
} else {
|
||||
eprintf ("Parameter %d out of range (0-255)\n", (int)b);
|
||||
return 0;
|
||||
}
|
||||
ao->o = 0x50e3;
|
||||
// TODO: if (b>255) -> automatic multiplier
|
||||
ao->o |= (a<<8);
|
||||
ao->o |= ((b&0xff)<<24);
|
||||
} else {
|
||||
ao->o |= (a<<8);
|
||||
ao->o |= (b<<24);
|
||||
|
@ -52,10 +52,10 @@ static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
|
||||
ud_set_input_buffer (&d, (uint8_t*) buf, len);
|
||||
ud_set_pc (&d, a->pc);
|
||||
ud_set_mode (&d, a->bits);
|
||||
op->size = ud_disassemble (&d);
|
||||
opsize = ud_disassemble (&d);
|
||||
snprintf (op->buf_asm, R_ASM_BUFSIZE, "%s", ud_insn_asm (&d));
|
||||
opsize = op->size;
|
||||
if (op->size<1 || strstr (op->buf_asm, "invalid"))
|
||||
op->size = opsize;
|
||||
if (opsize<1 || strstr (op->buf_asm, "invalid"))
|
||||
opsize = -1;
|
||||
return opsize;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user