Disassembly bug fixes.

This commit is contained in:
Daniel Beer 2010-03-30 16:00:02 +13:00
parent 01e26ce3a8
commit f3c66c5aa4
3 changed files with 15 additions and 6 deletions

13
dis.c
View File

@ -438,6 +438,13 @@ int dis_decode(u_int8_t *code, u_int16_t offset, u_int16_t len,
find_cgens(insn); find_cgens(insn);
find_emulated_ops(insn); find_emulated_ops(insn);
if (insn->is_byte_op) {
if (insn->src_mode == MSP430_AMODE_IMMEDIATE)
insn->src_addr &= 0xff;
if (insn->dst_mode == MSP430_AMODE_IMMEDIATE)
insn->dst_addr &= 0xff;
}
insn->len = ret; insn->len = ret;
return ret; return ret;
} }
@ -538,7 +545,6 @@ static int format_addr(msp430_amode_t amode, u_int16_t addr)
const char *prefix = ""; const char *prefix = "";
switch (amode) { switch (amode) {
case MSP430_AMODE_SYMBOLIC:
case MSP430_AMODE_REGISTER: case MSP430_AMODE_REGISTER:
case MSP430_AMODE_INDIRECT: case MSP430_AMODE_INDIRECT:
case MSP430_AMODE_INDIRECT_INC: case MSP430_AMODE_INDIRECT_INC:
@ -553,6 +559,9 @@ static int format_addr(msp430_amode_t amode, u_int16_t addr)
case MSP430_AMODE_ABSOLUTE: case MSP430_AMODE_ABSOLUTE:
prefix = "&"; prefix = "&";
break; break;
case MSP430_AMODE_SYMBOLIC:
break;
} }
len = printf("%s", prefix); len = printf("%s", prefix);
@ -672,7 +681,7 @@ static void dis_format(const struct msp430_instruction *insn)
printf(","); printf(",");
count++; count++;
while (count < 19) { while (count < 23) {
count++; count++;
printf(" "); printf(" ");
} }

5
main.c
View File

@ -185,7 +185,7 @@ static int cmd_dis(char **arg)
char *len_text = get_arg(arg); char *len_text = get_arg(arg);
int offset = 0; int offset = 0;
int length = 0x40; int length = 0x40;
u_int8_t buf[512]; u_int8_t buf[4096];
if (!off_text) { if (!off_text) {
fprintf(stderr, "md: offset must be specified\n"); fprintf(stderr, "md: offset must be specified\n");
@ -1034,6 +1034,9 @@ int main(int argc, char **argv)
while (optind < argc) while (optind < argc)
process_command(argv[optind++], 0); process_command(argv[optind++], 0);
} else { } else {
printf("\n");
cmd_help(NULL);
do { do {
reader_loop(); reader_loop();
} while (syms_modify_check()); } while (syms_modify_check());

3
util.c
View File

@ -165,9 +165,6 @@ static char *readline(const char *prompt)
void reader_loop(void) void reader_loop(void)
{ {
printf("\n");
cmd_help(NULL);
for (;;) { for (;;) {
char *buf = readline("(mspdebug) "); char *buf = readline("(mspdebug) ");