From 7f0cb1b2deb0c46cbef02eded30a16f0432d5bdc Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Fri, 19 Oct 2018 14:35:35 +0300 Subject: remote work commit --- misc/radare2/asm_fspec.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'misc/radare2/asm_fspec.c') diff --git a/misc/radare2/asm_fspec.c b/misc/radare2/asm_fspec.c index fa7c1ad..9eb28ea 100644 --- a/misc/radare2/asm_fspec.c +++ b/misc/radare2/asm_fspec.c @@ -12,7 +12,8 @@ enum fspec_instruction { INS_REG, INS_PUSH, INS_PUSHR, - INS_STORE, + INS_POP, + INS_INCR, INS_OP, INS_QUEUE, INS_IO, @@ -54,7 +55,8 @@ ins_name_str(const enum fspec_instruction name) case INS_REG: return "reg"; case INS_PUSH: return "push"; case INS_PUSHR: return "pushr"; - case INS_STORE: return "store"; + case INS_INCR: return "incr"; + case INS_POP: return "pop"; case INS_OP: return "op"; case INS_QUEUE: return "queue"; case INS_IO: return "io"; @@ -98,26 +100,27 @@ op_name_str(const enum fspec_operation op) static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) { + (void)a; + union { struct { unsigned name:5; unsigned n:2; uint64_t v:57; } ins; - uint8_t v[16]; + uint8_t v[sizeof(uint64_t)]; } u = {0}; - memcpy(u.v, buf, R_MIN(sizeof(u.v[0]), len)); - const uint8_t insw = sizeof(uint16_t) * (1 << u.ins.n); + memcpy(u.v, buf, R_MIN(1, (size_t)len)); + const uint8_t insw = 1 << u.ins.n; memcpy(u.v, buf, R_MIN(insw, len)); + const char *buf_asm = "invalid"; + const bool reg_arg = (u.ins.name == INS_PUSHR || u.ins.name == INS_INCR || u.ins.name == INS_POP || + u.ins.name == INS_EXEC || u.ins.name == INS_CALL); if (u.ins.name == INS_OP) buf_asm = sdb_fmt("%s %s", ins_name_str(u.ins.name), op_name_str(u.ins.v)); - else if (u.ins.n == 0) - buf_asm = sdb_fmt("%s 0x%02x", ins_name_str(u.ins.name), (uint16_t)u.ins.v); - else if (u.ins.n == 1) - buf_asm = sdb_fmt("%s 0x%04x", ins_name_str(u.ins.name), (uint32_t)u.ins.v); - else if (u.ins.n == 2) - buf_asm = sdb_fmt("%s 0x%08x", ins_name_str(u.ins.name), (uint64_t)u.ins.v); + else if (reg_arg) + buf_asm = sdb_fmt("%s r%" PRIu64, ins_name_str(u.ins.name), (uint64_t)u.ins.v); else - return 0; + buf_asm = sdb_fmt("%s %" PRIu64, ins_name_str(u.ins.name), (uint64_t)u.ins.v); r_strbuf_set(&op->buf_asm, buf_asm); return (op->size = insw + (u.ins.name == INS_REG ? u.ins.v : 0)); @@ -128,7 +131,7 @@ RAsmPlugin r_asm_plugin_fspec = { .license = "LGPL3", .desc = "fspec disassembly plugin", .arch = "fspec", - .bits = 16 | 32 | 64, + .bits = 8 | 16 | 32 | 64, .endian = R_SYS_ENDIAN_LITTLE, .disassemble = disassemble }; -- cgit v1.2.3