X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=disassembler%2Fmain.c;h=76295fd5eb2a836b91c1692827c7fb50405e8033;hb=28703f82744ed3eb122ae33474e9c53f4fe528d3;hp=43415a1d003575c4b92add7de4e7a5d9cb2368f3;hpb=7ff7a760aa92b63ed4af8aabddb621cc9483e67f;p=b43-tools.git diff --git a/disassembler/main.c b/disassembler/main.c index 43415a1..76295fd 100644 --- a/disassembler/main.c +++ b/disassembler/main.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006 Michael Buesch + * Copyright (C) 2006-2010 Michael Buesch * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 @@ -72,8 +72,8 @@ static const char * gen_raw_code(unsigned int operand) { char *ret; - ret = xmalloc(5); - snprintf(ret, 5, "@%03X", operand); + ret = xmalloc(6); + snprintf(ret, 6, "@%X", operand); return ret; } @@ -91,10 +91,23 @@ static const char * disasm_mem_operand(unsigned int operand) static const char * disasm_indirect_mem_operand(unsigned int operand) { char *ret; + unsigned int offset, reg; + switch (cmdargs.arch) { + case 5: + offset = (operand & 0x3F); + reg = ((operand >> 6) & 0x7); + break; + case 15: + offset = (operand & 0x7F); + reg = ((operand >> 7) & 0x7); + break; + default: + fprintf(stderr, "Internal error: disasm_indirect_mem_operand invalid arch\n"); + exit(1); + } ret = xmalloc(12); - snprintf(ret, 12, "[0x%02X,off%u]", - (operand & 0x3F), ((operand >> 6) & 0x7)); //FIXME r15? + snprintf(ret, 12, "[0x%02X,off%u]", offset, reg); return ret; } @@ -736,7 +749,9 @@ static void emit_asm(struct disassembler_context *ctx) if (err) exit(1); - fprintf(outfile, "%%arch %u\n\n", ctx->arch); + fprintf(outfile, "%%arch %u\n", ctx->arch); + fprintf(outfile, "%%start entry\n\n"); + fprintf(outfile, "entry:\n"); list_for_each_entry(stmt, &ctx->stmt_list, list) { switch (stmt->type) { case STMT_INSN: