b43-asm: Fix the reverse search for JMPs before RETs
authorMichael Buesch <mb@bu3sch.de>
Sun, 18 May 2008 11:10:59 +0000 (13:10 +0200)
committerMichael Buesch <mb@bu3sch.de>
Sun, 18 May 2008 11:10:59 +0000 (13:10 +0200)
We must ignore labels.

Signed-off-by: Michael Buesch <mb@bu3sch.de>
assembler/main.c
assembler/test.asm

index 774f8f956dc5ad40ded7e40b7ba49079a43f4072..3f207baf1ed69e412d4f5a6be1c48e05a52c6607 100644 (file)
@@ -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);
index 599ca8eb1900c62e92b5f592bd39b30953206dcc..b0e86d903188819ee087ac739751fbe2d89ce6eb 100644 (file)
@@ -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