From 15e6569e86bfc42db9932b3e817161c13d083252 Mon Sep 17 00:00:00 2001 From: Michael Buesch Date: Sun, 18 May 2008 13:10:59 +0200 Subject: [PATCH] b43-asm: Fix the reverse search for JMPs before RETs We must ignore labels. Signed-off-by: Michael Buesch --- assembler/main.c | 17 ++++++++++------- assembler/test.asm | 2 ++ 2 files changed, 12 insertions(+), 7 deletions(-) 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 -- 2.31.1