From daee870b449adeb1b698623382c0045be052f536 Mon Sep 17 00:00:00 2001 From: Daniel Beer Date: Tue, 10 Aug 2010 16:04:29 +1200 Subject: [PATCH] Disassembly bug fixes, show repetitions in disassembly. --- cproc_util.c | 9 +++++++++ dis.c | 10 ++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/cproc_util.c b/cproc_util.c index 05190f0..e99de4c 100644 --- a/cproc_util.c +++ b/cproc_util.c @@ -184,6 +184,15 @@ static int dis_format(stab_t stab, char *buf, int max_len, insn->dst_addr, insn->dst_reg); + /* Repetition count */ + if (insn->rep_register) + total += snprintf(buf + total, max_len - total, + " [repeat %s]", + dis_reg_name(insn->rep_index)); + else if (insn->rep_index) + total += snprintf(buf + total, max_len - total, + " [repeat %d]", insn->rep_index + 1); + if (total < max_len) buf[total] = 0; else if (total) { diff --git a/dis.c b/dis.c index c5d37fb..366b05a 100644 --- a/dis.c +++ b/dis.c @@ -80,11 +80,12 @@ static int decode_00xx(const uint8_t *code, address_t offset, case 4: case 5: /* RxxM */ - insn->itype = MSP430_ITYPE_SINGLE; + insn->itype = MSP430_ITYPE_DOUBLE; insn->op = op & 0xf3e0; insn->dst_mode = MSP430_AMODE_REGISTER; insn->dst_reg = op & 0xf; - insn->rep_index = (op >> 10) & 3; + insn->src_mode = MSP430_AMODE_IMMEDIATE; + insn->src_addr = (op >> 10) & 3; insn->dsize = (op & 0x0010) ? MSP430_DSIZE_WORD : MSP430_DSIZE_AWORD; return 2; @@ -223,11 +224,12 @@ static int decode_14xx(const uint8_t *code, address_t offset, uint16_t op = (code[1] << 8) | code[0]; /* PUSHM/POPM */ - insn->itype = MSP430_ITYPE_SINGLE; + insn->itype = MSP430_ITYPE_DOUBLE; insn->op = op & 0xfe00; insn->dst_mode = MSP430_AMODE_REGISTER; insn->dst_reg = op & 0xf; - insn->rep_index = (op >> 4) & 0xf; + insn->src_mode = MSP430_AMODE_IMMEDIATE; + insn->src_addr = (op >> 4) & 0xf; insn->dsize = (op & 0x0100) ? MSP430_DSIZE_WORD : MSP430_DSIZE_AWORD;