summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/z8000/z8000.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/cpu/z8000/z8000.cpp')
-rw-r--r--src/devices/cpu/z8000/z8000.cpp105
1 files changed, 24 insertions, 81 deletions
diff --git a/src/devices/cpu/z8000/z8000.cpp b/src/devices/cpu/z8000/z8000.cpp
index ab42e44539e..251dbfa9a99 100644
--- a/src/devices/cpu/z8000/z8000.cpp
+++ b/src/devices/cpu/z8000/z8000.cpp
@@ -22,10 +22,6 @@
//#define VERBOSE 1
#include "logmacro.h"
-
-extern int z8k_segm;
-extern int z8k_segm_mode;
-
DEFINE_DEVICE_TYPE(Z8001, z8001_device, "z8001", "Zilog Z8001")
DEFINE_DEVICE_TYPE(Z8002, z8002_device, "z8002", "Zilog Z8002")
@@ -54,12 +50,6 @@ z8001_device::z8001_device(const machine_config &mconfig, const char *tag, devic
}
-offs_t z8002_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options)
-{
- extern CPU_DISASSEMBLE( z8000 );
- return CPU_DISASSEMBLE_NAME(z8000)(this, stream, pc, oprom, opram, options);
-}
-
device_memory_interface::space_config_vector z8002_device::memory_space_config() const
{
return space_config_vector {
@@ -77,21 +67,14 @@ device_memory_interface::space_config_vector z8001_device::memory_space_config()
};
}
-/* opcode execution table */
-std::unique_ptr<z8002_device::Z8000_exec const []> z8002_device::z8000_exec;
-
-/* zero, sign and parity flags for logical byte operations */
-static uint8_t z8000_zsp[256];
-
-
-int z8002_device::segmented_mode()
+bool z8002_device::get_segmented_mode() const
{
- return 0;
+ return false;
}
-int z8001_device::segmented_mode()
+bool z8001_device::get_segmented_mode() const
{
- return (m_fcw & F_SEG) ? 1 : 0;
+ return (m_fcw & F_SEG) ? true : false;
}
uint32_t z8002_device::addr_add(uint32_t addr, uint32_t addend)
@@ -145,7 +128,7 @@ uint32_t z8002_device::get_addr_operand(int opnum)
{
uint32_t seg = m_program->read_word(m_pc);
m_pc += 2;
- if (segmented_mode())
+ if (get_segmented_mode())
{
if (seg & 0x8000)
{
@@ -175,7 +158,7 @@ uint32_t z8002_device::get_raw_addr_operand(int opnum)
{
uint32_t seg = m_program->read_word(m_pc);
m_pc += 2;
- if (segmented_mode())
+ if (get_segmented_mode())
{
if (seg & 0x8000)
{
@@ -651,47 +634,22 @@ void z8002_device::state_string_export(const device_state_entry &entry, std::str
}
}
-void z8001_device::z8k_disass_mode(int ref, const std::vector<std::string> &params)
+void z8002_device::init_tables()
{
- size_t len;
- if (params.size() == 1)
- {
- len = params[0].length();
- if (!core_strnicmp(params[0].c_str(), "segmented", len) || !core_stricmp(params[0].c_str(), "z8001")) {
- z8k_segm = true;
- z8k_segm_mode = Z8K_SEGM_MODE_SEG;
- machine().debugger().console().printf("Disassembler mode set to Z8001/segmented\n");
- }
- else if (!core_strnicmp(params[0].c_str(), "non-segmented", len) || !core_stricmp(params[0].c_str(), "z8002"))
- {
- z8k_segm = false;
- z8k_segm_mode = Z8K_SEGM_MODE_NONSEG;
- machine().debugger().console().printf("Disassembler mode set to Z8002/non-segmented\n");
- }
- else if (!core_strnicmp(params[0].c_str(), "automatic", len))
- {
- z8k_segm_mode = Z8K_SEGM_MODE_AUTO;
- machine().debugger().console().printf("Disassembler mode set to automatic\n");
- }
- else
- goto usage;
- }
- else if (params.size() > 1)
- {
- usage:
- machine().debugger().console().printf("Usage: z8k_disass_mode <mode>\n");
- machine().debugger().console().printf(" set disassembler mode\n");
- machine().debugger().console().printf(" mode: \"segmented\" or \"z8001\" - Z8001 mode\n");
- machine().debugger().console().printf(" \"non-segmented\" or \"z8002\" - Z8002 mode\n");
- machine().debugger().console().printf(" \"automatic\" - automatic mode\n");
- }
- else
- {
- machine().debugger().console().printf("Current disassembler mode: ");
- if (z8k_segm_mode == Z8K_SEGM_MODE_AUTO)
- machine().debugger().console().printf("automatic, currently ");
- machine().debugger().console().printf("%s\n", z8k_segm ? "Z8001/segmented" : "Z8002/non-segmented");
- }
+ /* set up the zero, sign, parity lookup table */
+ for (int i = 0; i < 256; i++)
+ z8000_zsp[i] = ((i == 0) ? F_Z : 0) |
+ ((i & 128) ? F_S : 0) |
+ ((((i>>7)^(i>>6)^(i>>5)^(i>>4)^(i>>3)^(i>>2)^(i>>1)^i) & 1) ? 0 : F_PV);
+
+ for (const Z8000_init *opc = table; opc->size; opc++)
+ for (u32 val = opc->beg; val <= opc->end; val += opc->step)
+ z8000_exec[val] = opc - table;
+}
+
+util::disasm_interface *z8002_device::create_disassembler()
+{
+ return new z8000_disassembler(this);
}
void z8001_device::device_start()
@@ -710,14 +668,6 @@ void z8001_device::device_start()
init_tables();
- if (machine().debug_flags & DEBUG_FLAG_ENABLED)
- {
- using namespace std::placeholders;
- machine().debugger().console().register_command("z8k_disass_mode", CMDFLAG_NONE, 0, 0, 1, std::bind(&z8001_device::z8k_disass_mode, this, _1, _2));
- }
-
- z8k_segm = true;
-
register_debug_state();
m_icountptr = &m_icount;
@@ -741,8 +691,6 @@ void z8002_device::device_start()
init_tables();
- z8k_segm = false;
-
register_debug_state();
m_icountptr = &m_icount;
@@ -773,8 +721,6 @@ void z8002_device::device_reset()
z8002_device::~z8002_device()
{
- // FIXME: assumes that these CPUs can't outlive each other
- deinit_tables();
}
void z8002_device::execute_run()
@@ -785,9 +731,6 @@ void z8002_device::execute_run()
if (m_irq_req)
Interrupt();
- if (z8k_segm_mode == Z8K_SEGM_MODE_AUTO)
- z8k_segm = (m_fcw & F_SEG_Z8001()) ? 1 : 0;
-
m_ppc = m_pc;
debugger_instruction_hook(this, m_pc);
@@ -799,10 +742,10 @@ void z8002_device::execute_run()
{
m_op[0] = RDOP();
m_op_valid = 1;
- Z8000_exec const *const exec = &z8000_exec[m_op[0]];
+ const Z8000_init &exec = table[z8000_exec[m_op[0]]];
- m_icount -= exec->cycles;
- (this->*exec->opcode)();
+ m_icount -= exec.cycles;
+ (this->*exec.opcode)();
m_op_valid = 0;
}
} while (m_icount > 0);