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;
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;
}
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 */
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 */
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:
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: