From: Michael Buesch Date: Sun, 18 May 2008 11:10:59 +0000 (+0200) Subject: b43-asm: Fix the reverse search for JMPs before RETs X-Git-Tag: b43-fwcutter-013~55 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=15e6569e86bfc42db9932b3e817161c13d083252;p=b43-tools.git b43-asm: Fix the reverse search for JMPs before RETs We must ignore labels. Signed-off-by: Michael Buesch --- diff --git a/assembler/main.c b/assembler/main.c index 774f8f9..3f207ba 100644 --- a/assembler/main.c +++ b/assembler/main.c @@ -816,13 +816,16 @@ static void assemble_instruction(struct assembler_context *ctx, do_assemble_insn(ctx, insn, 0x002); break; case OP_RET: - if (!list_empty(&ctx->output)) { - /* Get the previous instruction and check whether it - * is a jump instruction. */ - out = list_entry(ctx->output.prev, struct code_output, list); - if (out->is_jump_insn) { - asm_error(ctx, "RET instruction directly after " - "jump instruction. The hardware won't like this."); + /* Get the previous instruction and check whether it + * is a jump instruction. */ + list_for_each_entry_reverse(out, &ctx->output, list) { + /* 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."); + } + break; } } do_assemble_insn(ctx, insn, 0x003); diff --git a/assembler/test.asm b/assembler/test.asm index 599ca8e..b0e86d9 100644 --- a/assembler/test.asm +++ b/assembler/test.asm @@ -122,6 +122,7 @@ function_a: nap jmp loop- out: + mov r0, r0 ret lr0, lr1 function_b: @@ -130,6 +131,7 @@ function_b: nap jmp loop- out: + mov r0, r0 ret lr0, lr1