From f981680e63cf6efb80b270d5ba2d30ffcbbf0ef4 Mon Sep 17 00:00:00 2001 From: Michael Buesch Date: Sun, 18 May 2008 12:51:03 +0200 Subject: [PATCH] asm/dasm: Let's simply comment out these lines that generate the ext jmp operands. Nothing bad can happen from commenting out a few stupid lines of code, right? Signed-off-by: Michael Buesch --- assembler/main.c | 21 ++++++++++++++++++--- assembler/parser.y | 4 +--- assembler/test.asm | 5 ++--- disassembler/main.c | 20 ++++++++++++++------ 4 files changed, 35 insertions(+), 15 deletions(-) diff --git a/assembler/main.c b/assembler/main.c index 1dac1c7..f2d2826 100644 --- a/assembler/main.c +++ b/assembler/main.c @@ -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; } diff --git a/assembler/parser.y b/assembler/parser.y index 5e256ab..4bdb9ec 100644 --- a/assembler/parser.y +++ b/assembler/parser.y @@ -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; } ; diff --git a/assembler/test.asm b/assembler/test.asm index b1f3f14..599ca8e 100644 --- a/assembler/test.asm +++ b/assembler/test.asm @@ -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 */ diff --git a/disassembler/main.c b/disassembler/main.c index 8e6415e..718e33f 100644 --- a/disassembler/main.c +++ b/disassembler/main.c @@ -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: -- 2.31.1