diff options
Diffstat (limited to 'src/devices/cpu/hmcs40/hmcs40d.cpp')
-rw-r--r-- | src/devices/cpu/hmcs40/hmcs40d.cpp | 66 |
1 files changed, 28 insertions, 38 deletions
diff --git a/src/devices/cpu/hmcs40/hmcs40d.cpp b/src/devices/cpu/hmcs40/hmcs40d.cpp index 96e4b6399ea..d845b7545ae 100644 --- a/src/devices/cpu/hmcs40/hmcs40d.cpp +++ b/src/devices/cpu/hmcs40/hmcs40d.cpp @@ -11,6 +11,33 @@ #include "emu.h" #include "hmcs40d.h" +// constructor + +hmcs40_disassembler::hmcs40_disassembler() +{ + // init lfsr pc lut + for (u32 i = 0, pc = 0; i < 0x40; i++) + { + m_l2r[i] = pc; + m_r2l[pc] = i; + + // see hmcs40_cpu_device::increment_pc() + u32 mask = 0x3f; + u32 low = pc & mask; + u32 fb = (low << 1 & 0x20) == (low & 0x20); + + if (low == (mask >> 1)) + fb = 1; + else if (low == mask) + fb = 0; + + pc = (pc & ~mask) | ((pc << 1 | fb) & mask); + } +} + + +// common lookup tables + const char *const hmcs40_disassembler::s_mnemonics[] = { "?", @@ -152,6 +179,7 @@ const u8 hmcs40_disassembler::hmcs40_mnemonic[0x400] = }; +// disasm offs_t hmcs40_disassembler::disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer ¶ms) { @@ -197,41 +225,3 @@ offs_t hmcs40_disassembler::disassemble(std::ostream &stream, offs_t pc, const d return 1 | s_flags[instr] | SUPPORTED; } - -u32 hmcs40_disassembler::opcode_alignment() const -{ - return 1; -} - -u32 hmcs40_disassembler::interface_flags() const -{ - return NONLINEAR_PC | PAGED; -} - -u32 hmcs40_disassembler::page_address_bits() const -{ - return 6; -} - -offs_t hmcs40_disassembler::pc_linear_to_real(offs_t pc) const -{ - static const u8 l2r[64] = { - 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x3e, 0x3d, 0x3b, 0x37, 0x2f, 0x1e, 0x3c, 0x39, 0x33, - 0x27, 0x0e, 0x1d, 0x3a, 0x35, 0x2b, 0x16, 0x2c, 0x18, 0x30, 0x21, 0x02, 0x05, 0x0b, 0x17, 0x2e, - 0x1c, 0x38, 0x31, 0x23, 0x06, 0x0d, 0x1b, 0x36, 0x2d, 0x1a, 0x34, 0x29, 0x12, 0x24, 0x08, 0x11, - 0x22, 0x04, 0x09, 0x13, 0x26, 0x0c, 0x19, 0x32, 0x25, 0x0a, 0x15, 0x2a, 0x14, 0x28, 0x10, 0x20, - }; - return (pc & ~0x3f) | l2r[pc & 0x3f]; -} - -offs_t hmcs40_disassembler::pc_real_to_linear(offs_t pc) const -{ - static const u8 r2l[64] = { - 0x00, 0x01, 0x1b, 0x02, 0x31, 0x1c, 0x24, 0x03, 0x2e, 0x32, 0x39, 0x1d, 0x35, 0x25, 0x11, 0x04, - 0x3e, 0x2f, 0x2c, 0x33, 0x3c, 0x3a, 0x16, 0x1e, 0x18, 0x36, 0x29, 0x26, 0x20, 0x12, 0x0c, 0x05, - 0x3f, 0x1a, 0x30, 0x23, 0x2d, 0x38, 0x34, 0x10, 0x3d, 0x2b, 0x3b, 0x15, 0x17, 0x28, 0x1f, 0x0b, - 0x19, 0x22, 0x37, 0x0f, 0x2a, 0x14, 0x27, 0x0a, 0x21, 0x0e, 0x13, 0x09, 0x0d, 0x08, 0x07, 0x06, - }; - return (pc & ~0x3f) | r2l[pc & 0x3f]; -} - |