b43-asm: Only warning, not error, on RET after JMP
[b43-tools.git] / assembler / main.c
index 3f207baf1ed69e412d4f5a6be1c48e05a52c6607..54252dabe95fe89b762524ced673fd3d4a80fd5c 100644 (file)
@@ -571,19 +571,20 @@ static void emulate_jmp_insn(struct assembler_context *ctx,
 {
        struct instruction em_insn;
        struct operlist em_ol;
-       struct operand em_op;
-       struct immediate em_imm;
-
-       /* This is a pseudo-OP. We emulate it by JE */
-
-       em_insn.op = OP_JE;
-       em_imm.imm = 1;
-       em_op.type = OPER_IMM;
-       em_op.u.imm = &em_imm;
-       em_ol.oper[0] = &em_op;
-       em_ol.oper[1] = &em_op;
-       em_ol.oper[2] = insn->operands->oper[0];
+       struct immediate em_condition;
+       struct operand em_cond_op;
+
+       /* This is a pseudo-OP. We emulate it with
+        * JEXT 0x7F, target */
+
+       em_insn.op = OP_JEXT;
+       em_condition.imm = 0x7F; /* Ext cond: Always true */
+       em_cond_op.type = OPER_IMM;
+       em_cond_op.u.imm = &em_condition;
+       em_ol.oper[0] = &em_cond_op;
+       em_ol.oper[1] = insn->operands->oper[0]; /* Target */
        em_insn.operands = &em_ol;
+
        assemble_instruction(ctx, &em_insn); /* recurse */
 }
 
@@ -822,8 +823,8 @@ static void assemble_instruction(struct assembler_context *ctx,
                        /* Search the last insn. */
                        if (out->type == OUT_INSN) {
                                if (out->is_jump_insn) {
-                                       asm_error(ctx, "RET instruction directly after "
-                                                 "jump instruction. The hardware won't like this.");
+                                       asm_warn(ctx, "RET instruction directly after "
+                                                "jump instruction. The hardware won't like this.");
                                }
                                break;
                        }
@@ -1025,21 +1026,17 @@ does_not_exist:
 static void emit_code(struct assembler_context *ctx)
 {
        FILE *fd;
-       char *fn;
-       size_t fn_len;
+       const char *fn;
        struct code_output *c;
        uint64_t code;
        unsigned char outbuf[8];
        unsigned int insn_count = 0;
        struct fw_header hdr;
 
-       fn_len = strlen(outfile_name) + 20;
-       fn = xmalloc(fn_len);
-       snprintf(fn, fn_len, "%s.ucode", outfile_name);
+       fn = outfile_name;
        fd = fopen(fn, "w+");
        if (!fd) {
                fprintf(stderr, "Could not open microcode output file \"%s\"\n", fn);
-               free(fn);
                exit(1);
        }
        if (IS_VERBOSE_DEBUG)
@@ -1124,8 +1121,13 @@ static void emit_code(struct assembler_context *ctx)
                        break;
                }
        }
+
+       if (arg_print_sizes) {
+               printf("%s:  text = %u instructions (%u bytes)\n",
+                      fn, insn_count, insn_count * sizeof(uint64_t));
+       }
+
        fclose(fd);
-       free(fn);
 }
 
 static void assemble(void)