summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/cr16b/cr16bdasm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/cpu/cr16b/cr16bdasm.cpp')
-rw-r--r--src/devices/cpu/cr16b/cr16bdasm.cpp26
1 files changed, 9 insertions, 17 deletions
diff --git a/src/devices/cpu/cr16b/cr16bdasm.cpp b/src/devices/cpu/cr16b/cr16bdasm.cpp
index c9cb483e02e..afbd24e0add 100644
--- a/src/devices/cpu/cr16b/cr16bdasm.cpp
+++ b/src/devices/cpu/cr16b/cr16bdasm.cpp
@@ -160,9 +160,9 @@ void cr16b_disassembler::format_short_imm_unsigned(std::ostream &stream, u8 imm,
if (imm == 0)
stream << "$0";
else if (i)
- util::stream_format(stream, "$0x%04X", (imm >= 0x10) ? 0xfff0 | (imm & 0x0f) : imm);
+ util::stream_format(stream, "$0x%04X", u16(util::sext<s16>(imm, 5)));
else
- util::stream_format(stream, "$0x%02X", (imm >= 0x10) ? 0xf0 | (imm & 0x0f) : imm);
+ util::stream_format(stream, "$0x%02X", u8(util::sext(imm, 5)));
}
void cr16b_disassembler::format_short_imm_decimal(std::ostream &stream, u8 imm)
@@ -231,25 +231,17 @@ void cr16b_disassembler::format_abs18(std::ostream &stream, u32 addr)
util::stream_format(stream, "0x%05X", addr);
}
-void cr16b_disassembler::format_pc_disp5(std::ostream &stream, offs_t pc, u8 disp)
+void cr16b_disassembler::format_pc(std::ostream &stream, offs_t pc)
{
if (m_arch == cr16_arch::CR16A)
- util::stream_format(stream, "0x%05X", (pc + disp - (disp >= 0x10 ? 0x20 : 0)) & 0x1ffff); // SMM
+ util::stream_format(stream, "0x%05X", pc & 0x1ffff); // SMM
else
- util::stream_format(stream, "0x%06X", (pc + disp - (disp >= 0x10 ? 0x20 : 0)) & 0x1fffff); // LMM
-}
-
-void cr16b_disassembler::format_pc_disp9(std::ostream &stream, offs_t pc, u16 disp)
-{
- if (m_arch == cr16_arch::CR16A)
- util::stream_format(stream, "0x%05X", (pc + disp - (disp >= 0x100 ? 0x200 : 0)) & 0x1ffff); // SMM
- else
- util::stream_format(stream, "0x%06X", (pc + disp - (disp >= 0x100 ? 0x200 : 0)) & 0x1fffff); // LMM
+ util::stream_format(stream, "0x%06X", pc & 0x1fffff); // LMM
}
void cr16b_disassembler::format_pc_disp17(std::ostream &stream, offs_t pc, u32 disp)
{
- util::stream_format(stream, "0x%05X", (pc + disp - (disp >= 0x10000 ? 0x20000 : 0)) & 0x1ffff);
+ util::stream_format(stream, "0x%05X", (pc + disp) & 0x1ffff);
}
void cr16b_disassembler::format_pc_disp21(std::ostream &stream, offs_t pc, u32 disp)
@@ -594,7 +586,7 @@ offs_t cr16b_disassembler::disassemble(std::ostream &stream, offs_t pc, const cr
util::stream_format(stream, "b%s%c%c ", BIT(opcode, 7) ? "ne" : "eq", BIT(opcode, 6) ? '1' : '0', BIT(opcode, 13) ? 'w' : 'b');
format_reg(stream, (opcode & 0x0120) >> 5);
stream << ", ";
- format_pc_disp5(stream, pc, opcode & 0x001e);
+ format_pc(stream, pc + util::sext(opcode & 0x001e, 5));
return 2 | STEP_COND | SUPPORTED;
}
@@ -739,13 +731,13 @@ offs_t cr16b_disassembler::disassemble(std::ostream &stream, offs_t pc, const cr
if ((opcode & 0x01e0) == 0x01c0)
{
stream << "br ";
- format_pc_disp9(stream, pc, (opcode & 0x1e00) >> 4 | (opcode & 0x001e));
+ format_pc(stream, pc + util::sext((opcode & 0x1e00) >> 4 | (opcode & 0x001e), 9));
return 2 | SUPPORTED;
}
else
{
util::stream_format(stream, "b%s ", s_cc[(opcode & 0x01e0) >> 5]);
- format_pc_disp9(stream, pc, (opcode & 0x1e00) >> 4 | (opcode & 0x001e));
+ format_pc(stream, pc + util::sext((opcode & 0x1e00) >> 4 | (opcode & 0x001e), 9));
return 2 | STEP_COND | SUPPORTED;
}
}