X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=assembler%2Fmain.c;h=0d995a4d6ffe0619ecf57e4cc092364d5b11d5ed;hb=db3a1d329e7346b65ec69bd18062e1433aa86901;hp=255cabc88c74b6966d0c0a4262e374d2048cdf14;hpb=e882e360ba16d2eed103adffdd1809076ee98017;p=b43-tools.git diff --git a/assembler/main.c b/assembler/main.c index 255cabc..0d995a4 100644 --- a/assembler/main.c +++ b/assembler/main.c @@ -341,8 +341,14 @@ static unsigned int generate_mem_operand(struct assembler_context *ctx, asm_warn(ctx, "INDIRECT memoffset 0x%X too long (> 6 bits)", off); off &= 0x3F; } - if (reg & ~0x7) + if (reg > 6) { + /* Assembler bug. The parser shouldn't pass this value. */ asm_error(ctx, "OFFR-nr too big"); + } + if (reg == 6) { + asm_warn(ctx, "Using offset register 6. This register is broken " + "on certain devices. Use off0 to off5 only."); + } val |= off; val |= (reg << 6); break; @@ -823,8 +829,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; } @@ -1026,21 +1032,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) @@ -1128,11 +1130,11 @@ static void emit_code(struct assembler_context *ctx) if (arg_print_sizes) { printf("%s: text = %u instructions (%u bytes)\n", - fn, insn_count, insn_count * sizeof(uint64_t)); + fn, insn_count, + (unsigned int)(insn_count * sizeof(uint64_t))); } fclose(fd); - free(fn); } static void assemble(void)