DCPU16_WORD pc = (DCPU16_WORD)(vm->reg[DCPU16_REG_PC] + *pc_adjust),
sp = (DCPU16_WORD)(vm->reg[DCPU16_REG_PC] + *sp_adjust);
- TRACE("%s: pc:0x%04x sp:0x%04x value_data:0x%04x\n",
+ TRACE("%s>> is_a:%u pc:0x%04x sp:0x%04x value_data:0x%04x\n",
__func__,
+ value_is_a,
pc,
sp,
value_data);
*a = (mem[addr] >> (OPCODE_BASIC_BITS + OPCODE_OPERAND_B_BITS)) & ((1 << OPCODE_OPERAND_A_BITS) - 1);
*instr_len = 1;
- if ( (*b >= 0x10 && *b <= 0x17) || *b == 0x1e || *b == 0x1f ) {
+ if ((*opcode != 0x0000) &&
+ ( (*b >= 0x10 && *b <= 0x17) || *b == 0x1e || *b == 0x1f ) ) {
*b_data = mem + (DCPU16_WORD)(addr + *instr_len);
- TRACE("**b_data:%hu", **b_data);
*instr_len += 1;
} else {
*b_data = NULL;
if ( (*opcode != 0x0000 || (*opcode == 0 && *b != 0x0000) )
&& ( (*a >= 0x10 && *a <= 0x17) || *a == 0x1e || *a == 0x1f) ) {
*a_data = mem + (DCPU16_WORD)(addr + *instr_len);
- TRACE("**a_data:%hu", **a_data);
*instr_len += 1;
} else {
*a_data = NULL;
}
-#if 0
TRACE("\n%s: [0x%04x]:0x%04x op:0x%02x b:0x%02x (b_data:0x%04x) a:0x%02x (a_data:0x%04x) len:0x%02x\n",
__func__,
addr,
*a,
*a_data ? **a_data : 0,
*instr_len);
-#endif
}
/* dcpu16_mnemonify_buf
size_t i;
const struct opcode_entry *e;
- if (!vm) return;
+ if (!vm)
+ return;
/* signal interested parties that a new cycle has ticked */
- TRACE("%s: sending global cycle event", __func__);
+ TRACE("%s>> sending global cycle event", __func__);
acct_event_(vm, DCPU16_ACCT_EV_CYCLE, vm->reg[DCPU16_REG_PC]);
/* signal attached hardware */
for (i = 0; i < vm->hw_table_entries_; i++) {
if (vm->hw_table_[i].cycle) {
- TRACE("%s: sending cycle to %s", __func__, vm->hw_table_[i].name_);
+ TRACE("%s>> sending cycle to %s", __func__, vm->hw_table_[i].name_);
vm->hw_table_[i].cycle(vm, vm->hw_table_[i].data);
}
}
message = interrupt_dequeue_(vm);
if (vm->reg[DCPU16_REG_IA]) {
- TRACE("servicing interrupt IA:0x%04x message:0x%04x \n", vm->reg[DCPU16_REG_IA], message);
+ TRACE("%s>> servicing interrupt IA:0x%04x message:0x%04x \n", __func__, vm->reg[DCPU16_REG_IA], message);
/* then service the next interrupt */
vm->interrupts_deferred_ = 1;
vm->ram[--vm->reg[DCPU16_REG_SP]] = vm->reg[DCPU16_REG_PC];
vm->reg[DCPU16_REG_PC] = vm->reg[DCPU16_REG_IA];
vm->reg[DCPU16_REG_A] = message;
} else {
- TRACE("ignoring interrupt IA:0");
+ TRACE("%s>> ignoring interrupt IA:0", __func__);
}
}
}
if (!vm || !hw)
return -1;
+ TRACE("%s>> name:%s ID:0x%04x%04x MFG:0x%04x%04x VER:0x%04x",
+ __func__,
+ hw->name_,
+ hw->id_h, hw->id_l,
+ hw->mfg_l, hw->mfg_h,
+ hw->ver);
+
if (vm->hw_table_entries_ == 0xffff) {
WARN("maximum hardware entries reached");
return -1;
memcpy(vm->hw_table_ + vm->hw_table_entries_, hw, sizeof *hw);
vm->hw_table_entries_++;
+ TRACE("%s>> added hw entry %zu", __func__, vm->hw_table_entries_);
+
return 0;
}
memcpy(vm->cb_table_ + vm->cb_table_entries_, &cb, sizeof cb);
vm->cb_table_entries_++;
+ TRACE("%s>> attached event callback %zu", __func__, vm->cb_table_entries_);
+
return 0;
}
if (!vm)
return;
+ TRACE("%s>> reset", __func__);
+
vm->skip_ = 0;
vm->interrupts_deferred_ = 0;
vm->on_fire_ = 0;