asm/dasm: Let's simply comment out these lines that generate the ext jmp operands.
authorMichael Buesch <mb@bu3sch.de>
Sun, 18 May 2008 10:51:03 +0000 (12:51 +0200)
committerMichael Buesch <mb@bu3sch.de>
Sun, 18 May 2008 10:51:03 +0000 (12:51 +0200)
Nothing bad can happen from commenting out a few stupid lines of code, right?

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

index 1dac1c7cafa146068c38d027f82f41a1dcaf0a9a..f2d2826aa5b2e804bf75506347d8b3b8a0f63aed 100644 (file)
@@ -470,6 +470,9 @@ static unsigned int merge_external_jmp_into_opcode(struct assembler_context *ctx
                                                   unsigned int opbase,
                                                   struct instruction *insn)
 {
+       struct operand *fake;
+       struct registr *fake_reg;
+       struct operand *target;
        struct operlist *ol;
        unsigned int cond;
        unsigned int opcode;
@@ -480,9 +483,21 @@ static unsigned int merge_external_jmp_into_opcode(struct assembler_context *ctx
        if (cond & ~0xFF)
                asm_error(ctx, "External jump condition value too big (> 0xFF)");
        opcode |= cond;
-       ol->oper[0] = ol->oper[1];
-       ol->oper[1] = ol->oper[2];
-       ol->oper[2] = ol->oper[3];
+       target = ol->oper[1];
+       memset(ol->oper, 0, sizeof(ol->oper));
+
+       /* This instruction has two fake r0 operands
+        * at position 0 and 1. */
+       fake = xmalloc(sizeof(struct operand));
+       fake_reg = xmalloc(sizeof(struct operand));
+       fake->type = OPER_REG;
+       fake->u.reg = fake_reg;
+       fake_reg->type = GPR;
+       fake_reg->nr = 0;
+
+       ol->oper[0] = fake;
+       ol->oper[1] = fake;
+       ol->oper[2] = target;
 
        return opcode;
 }
index 5e256abb45506d5d57dea26385af676e9c4eddc5..4bdb9ec6dc8516b2335961057a3a61decdd1760d 100644 (file)
@@ -1004,15 +1004,13 @@ extended_operlist : decnum COMMA decnum COMMA operand COMMA operand COMMA operan
                  }
                ;
 
-external_jump_operands : imm COMMA operand COMMA operand COMMA labelref {
+external_jump_operands : imm COMMA labelref {
                        struct operlist *ol = xmalloc(sizeof(struct operlist));
                        struct operand *cond = xmalloc(sizeof(struct operand));
                        cond->type = OPER_IMM;
                        cond->u.imm = $1;
                        ol->oper[0] = cond;
                        ol->oper[1] = $3;
-                       ol->oper[2] = $5;
-                       ol->oper[3] = $7;
                        $$ = ol;
                  }
                ;
index b1f3f147b01267d520f7ce287aefc3b36abe7c79..599ca8eb1900c62e92b5f592bd39b30953206dcc 100644 (file)
@@ -38,7 +38,6 @@ label:
        addc    r0,r1,r2        /* add with carry */
        addc.   r0,r1,r2        /* add with carry, set carry */
 
-or 0x1000, r0, r0
 testlabel:
        /* SUB instructions */
        sub     r0,r1,r2        /* sub */
@@ -88,8 +87,8 @@ testlabel:
        jnzx    7,8,r0,r1,label /* Jump if nonzero after shift and mask */
 
        /* jump on external conditions */
-       jext    ECOND_MAC_ON,r0,r0,label  /* jump if external condition is TRUE */
-       jnext   ECOND_MAC_ON,r0,r0,label  /* jump if external condition is FALSE */
+       jext    ECOND_MAC_ON,label  /* jump if external condition is TRUE */
+       jnext   ECOND_MAC_ON,label  /* jump if external condition is FALSE */
 
        /* Subroutines */
        call    lr0,label       /* store PC in lr0, call func at label */
index 8e6415ed875ee8ca98b9068f9786bf5aff772f14..718e33fcb013874a7ccf28a0ef13dd547878a465 100644 (file)
@@ -539,9 +539,13 @@ static void disasm_opcodes(struct disassembler_context *ctx)
                        snprintf(str, 5, "0x%02X", (bin->opcode & 0x0FF));
                        stmt->u.insn.operands[0] = str;
 
-                       disasm_std_operand(stmt, 0, 1, 0);
-                       disasm_std_operand(stmt, 1, 2, 0);
-                       stmt->u.insn.is_labelref = 3;
+                       /* We don't disassemble the first and second operand, as
+                        * that always is a dummy r0 operand.
+                        * disasm_std_operand(stmt, 0, 1, 0);
+                        * disasm_std_operand(stmt, 1, 2, 0);
+                        * stmt->u.insn.is_labelref = 3;
+                        */
+                       stmt->u.insn.is_labelref = 1;
                        stmt->u.insn.labeladdr = stmt->u.insn.bin->operands[2];
                        break;
                case 0x700:
@@ -551,9 +555,13 @@ static void disasm_opcodes(struct disassembler_context *ctx)
                        snprintf(str, 5, "0x%02X", (bin->opcode & 0x0FF));
                        stmt->u.insn.operands[0] = str;
 
-                       disasm_std_operand(stmt, 0, 1, 0);
-                       disasm_std_operand(stmt, 1, 2, 0);
-                       stmt->u.insn.is_labelref = 3;
+                       /* We don't disassemble the first and second operand, as
+                        * that always is a dummy r0 operand.
+                        * disasm_std_operand(stmt, 0, 1, 0);
+                        * disasm_std_operand(stmt, 1, 2, 0);
+                        * stmt->u.insn.is_labelref = 3;
+                        */
+                       stmt->u.insn.is_labelref = 1;
                        stmt->u.insn.labeladdr = stmt->u.insn.bin->operands[2];
                        break;
                default: