disassembler: Decode operands of new jump instructions
[b43-tools.git] / disassembler / main.c
index 601c84a9796022459b4af5a93fcb5ebfbcdd3018..b0d2c7b04dcd993fbd2178dc9a80eb52b2ebac07 100644 (file)
@@ -456,6 +456,33 @@ static void disasm_constant_opcodes(struct disassembler_context *ctx,
                disasm_std_operand(stmt, 0, 0);
                disasm_std_operand(stmt, 1, 1);
                break;
+       case 0x0D6:
+               stmt->u.insn.name = "@D6"; /* FIXME */
+               stmt->u.insn.is_labelref = 2;
+               stmt->u.insn.labeladdr = stmt->u.insn.bin->operands[2];
+               disasm_std_operand(stmt, 0, 0);
+               disasm_std_operand(stmt, 1, 1);
+               break;
+       case (0x0D6 | 0x1):
+               stmt->u.insn.name = "@D7"; /* FIXME */
+               stmt->u.insn.is_labelref = 2;
+               stmt->u.insn.labeladdr = stmt->u.insn.bin->operands[2];
+               disasm_std_operand(stmt, 0, 0);
+               disasm_std_operand(stmt, 1, 1);
+       case 0x0D8:
+               stmt->u.insn.name = "@D8"; /* FIXME */
+               stmt->u.insn.is_labelref = 2;
+               stmt->u.insn.labeladdr = stmt->u.insn.bin->operands[2];
+               disasm_std_operand(stmt, 0, 0);
+               disasm_std_operand(stmt, 1, 1);
+               break;
+       case (0x0D8 | 0x1):
+               stmt->u.insn.name = "@D9"; /* FIXME */
+               stmt->u.insn.is_labelref = 2;
+               stmt->u.insn.labeladdr = stmt->u.insn.bin->operands[2];
+               disasm_std_operand(stmt, 0, 0);
+               disasm_std_operand(stmt, 1, 1);
+               break;
        case 0x0DA:
                stmt->u.insn.name = "jl";
                stmt->u.insn.is_labelref = 2;
@@ -788,9 +815,9 @@ static void resolve_labels(struct disassembler_context *ctx)
 static void emit_asm(struct disassembler_context *ctx)
 {
        struct statement *stmt;
-       int first, i;
+       int first;
        int err;
-       unsigned int addr = 0;
+       unsigned int i, addr = 0;
 
        err = open_output_file();
        if (err)
@@ -803,19 +830,21 @@ static void emit_asm(struct disassembler_context *ctx)
                switch (stmt->type) {
                case STMT_INSN:
                        if (cmdargs.print_addresses)
-                               fprintf(outfile, "/* %03X */", addr);
+                               fprintf(outfile, "/* %04X */", addr);
                        fprintf(outfile, "\t%s", stmt->u.insn.name);
                        first = 1;
                        for (i = 0; i < ARRAY_SIZE(stmt->u.insn.operands); i++) {
                                if (!stmt->u.insn.operands[i] &&
-                                   stmt->u.insn.is_labelref != i)
+                                   (stmt->u.insn.is_labelref < 0 ||
+                                    (unsigned int)stmt->u.insn.is_labelref != i))
                                        continue;
                                if (first)
                                        fprintf(outfile, "\t");
                                if (!first)
                                        fprintf(outfile, ", ");
                                first = 0;
-                               if (stmt->u.insn.is_labelref == i) {
+                               if (stmt->u.insn.is_labelref >= 0 &&
+                                   (unsigned int)stmt->u.insn.is_labelref == i) {
                                        fprintf(outfile, "%s",
                                                stmt->u.insn.labelref->u.label.name);
                                } else {
@@ -857,11 +886,11 @@ static int read_input(struct disassembler_context *ctx)
        case FMT_B43:
                ret = fread(&hdr, 1, sizeof(hdr), infile);
                if (ret != sizeof(hdr)) {
-                       fprintf(stderr, "Corrupt input file (not fwcutter output)\n");
+                       fprintf(stderr, "Corrupt input file (no b43 header found)\n");
                        goto err_close;
                }
                if (hdr.type != FW_TYPE_UCODE) {
-                       fprintf(stderr, "Corrupt input file. Not a microcode image.\n");
+                       fprintf(stderr, "Corrupt input file. Not a b43 microcode image.\n");
                        goto err_close;
                }
                if (hdr.ver != FW_HDR_VER) {