summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/asap
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/cpu/asap')
-rw-r--r--src/devices/cpu/asap/asap.cpp33
-rw-r--r--src/devices/cpu/asap/asap.h6
-rw-r--r--src/devices/cpu/asap/asapdasm.cpp45
-rw-r--r--src/devices/cpu/asap/asapdasm.h33
4 files changed, 64 insertions, 53 deletions
diff --git a/src/devices/cpu/asap/asap.cpp b/src/devices/cpu/asap/asap.cpp
index e808f3fbb6c..c5d91084a83 100644
--- a/src/devices/cpu/asap/asap.cpp
+++ b/src/devices/cpu/asap/asap.cpp
@@ -13,6 +13,7 @@
#include "emu.h"
#include "asap.h"
+#include "asapdasm.h"
#include "debugger.h"
@@ -183,7 +184,7 @@ void asap_device::device_start()
{
// get our address spaces
m_program = &space(AS_PROGRAM);
- m_direct = &m_program->direct();
+ m_direct = m_program->direct<0>();
// register our state for the debugger
state_add(STATE_GENPC, "GENPC", m_pc).noshow();
@@ -300,40 +301,16 @@ void asap_device::state_string_export(const device_state_entry &entry, std::stri
//-------------------------------------------------
-// disasm_min_opcode_bytes - return the length
-// of the shortest instruction, in bytes
-//-------------------------------------------------
-
-uint32_t asap_device::disasm_min_opcode_bytes() const
-{
- return 4;
-}
-
-
-//-------------------------------------------------
-// disasm_max_opcode_bytes - return the length
-// of the longest instruction, in bytes
-//-------------------------------------------------
-
-uint32_t asap_device::disasm_max_opcode_bytes() const
-{
- return 12;
-}
-
-
-//-------------------------------------------------
-// disasm_disassemble - call the disassembly
+// disassemble - call the disassembly
// helper function
//-------------------------------------------------
-offs_t asap_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options)
+util::disasm_interface *asap_device::create_disassembler()
{
- extern CPU_DISASSEMBLE( asap );
- return CPU_DISASSEMBLE_NAME(asap)(this, stream, pc, oprom, opram, options);
+ return new asap_disassembler;
}
-
//**************************************************************************
// INLINE HELPERS
//**************************************************************************
diff --git a/src/devices/cpu/asap/asap.h b/src/devices/cpu/asap/asap.h
index 55d78d5b6cf..bfeb7c60350 100644
--- a/src/devices/cpu/asap/asap.h
+++ b/src/devices/cpu/asap/asap.h
@@ -89,9 +89,7 @@ protected:
virtual void state_string_export(const device_state_entry &entry, std::string &str) const override;
// device_disasm_interface overrides
- virtual uint32_t disasm_min_opcode_bytes() const override;
- virtual uint32_t disasm_max_opcode_bytes() const override;
- virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override;
+ virtual util::disasm_interface *create_disassembler() override;
// helpers
inline uint32_t readop(offs_t pc);
@@ -240,7 +238,7 @@ protected:
uint8_t m_irq_state;
int m_icount;
address_space * m_program;
- direct_read_data * m_direct;
+ direct_read_data<0> *m_direct;
// src2val table, registers are at the end
uint32_t m_src2val[65536];
diff --git a/src/devices/cpu/asap/asapdasm.cpp b/src/devices/cpu/asap/asapdasm.cpp
index 840c50f2635..8f652b6dad4 100644
--- a/src/devices/cpu/asap/asapdasm.cpp
+++ b/src/devices/cpu/asap/asapdasm.cpp
@@ -9,10 +9,10 @@
***************************************************************************/
#include "emu.h"
-#include "asap.h"
+#include "asapdasm.h"
-static const char *const reg[32] =
+const char *const asap_disassembler::reg[32] =
{
"0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
@@ -20,12 +20,12 @@ static const char *const reg[32] =
"r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31"
};
-static const char *const setcond[2] =
+const char *const asap_disassembler::setcond[2] =
{
" ", ".c"
};
-static const char *const condition[16] =
+const char *const asap_disassembler::condition[16] =
{
"sp", "mz", "gt", "le", "ge", "lt", "hi", "ls", "cc", "cs", "pl", "mi", "ne", "eq", "vc", "vs"
};
@@ -35,19 +35,17 @@ static const char *const condition[16] =
CODE CODE
***************************************************************************/
-static inline char *src2(uint32_t op, int scale)
+std::string asap_disassembler::src2(uint32_t op, int scale)
{
- static char temp[20];
if ((op & 0xffe0) == 0xffe0)
- sprintf(temp, "%s", reg[op & 31]);
+ return util::string_format("%s", reg[op & 31]);
else
- sprintf(temp, "$%x", (op & 0xffff) << scale);
- return temp;
+ return util::string_format("$%x", (op & 0xffff) << scale);
}
-CPU_DISASSEMBLE(asap)
+offs_t asap_disassembler::disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer &params)
{
- uint32_t op = oprom[0] | (oprom[1] << 8) | (oprom[2] << 16) | (oprom[3] << 24);
+ uint32_t op = opcodes.r32(pc);
int opcode = op >> 27;
int cond = (op >> 21) & 1;
int rdst = (op >> 22) & 31;
@@ -58,21 +56,21 @@ CPU_DISASSEMBLE(asap)
switch (opcode)
{
- case 0x00: util::stream_format(stream, "trap $00"); flags = DASMFLAG_STEP_OVER; break;
+ case 0x00: util::stream_format(stream, "trap $00"); flags = STEP_OVER; break;
case 0x01: util::stream_format(stream, "b%s $%08x", condition[rdst & 15], pc + ((int32_t)(op << 10) >> 8)); break;
case 0x02: if ((op & 0x003fffff) == 3)
{
- uint32_t nextop = oprom[4] | (oprom[5] << 8) | (oprom[6] << 16) | (oprom[7] << 24);
+ uint32_t nextop = opcodes.r32(pc+4);
if ((nextop >> 27) == 0x10 && ((nextop >> 22) & 31) == rdst && (nextop & 0xffff) == 0)
{
- uint32_t nextnextop = oprom[8] | (oprom[9] << 8) | (oprom[10] << 16) | (oprom[11] << 24);
+ uint32_t nextnextop = opcodes.r32(pc+8);
util::stream_format(stream, "llit%s $%08x,%s", setcond[cond], nextnextop, reg[rdst]);
- return 12 | DASMFLAG_STEP_OVER | DASMFLAG_SUPPORTED;
+ return 12 | STEP_OVER | SUPPORTED;
}
}
if (rdst)
{
- flags = DASMFLAG_STEP_OVER | DASMFLAG_STEP_OVER_EXTRA(1);
+ flags = STEP_OVER | step_over_extra(1);
util::stream_format(stream, "bsr %s,$%08x", reg[rdst], pc + ((int32_t)(op << 10) >> 8));
}
else
@@ -123,24 +121,29 @@ CPU_DISASSEMBLE(asap)
case 0x1d: util::stream_format(stream, "putps %s", src2(op,0)); break;
case 0x1e: if (rdst && rsrc2_iszero)
{
- flags = DASMFLAG_STEP_OVER | DASMFLAG_STEP_OVER_EXTRA(1);
+ flags = STEP_OVER | step_over_extra(1);
util::stream_format(stream, "jsr%s %s,%s", setcond[cond], reg[rdst], reg[rsrc1]);
}
else if (rdst)
{
- flags = DASMFLAG_STEP_OVER | DASMFLAG_STEP_OVER_EXTRA(1);
+ flags = STEP_OVER | step_over_extra(1);
util::stream_format(stream, "jsr%s %s,%s[%s]", setcond[cond], reg[rdst], reg[rsrc1], src2(op,2));
}
else if (rsrc2_iszero)
{
if (rsrc1 == 28)
- flags = DASMFLAG_STEP_OUT;
+ flags = STEP_OUT;
util::stream_format(stream, "jmp%s %s", setcond[cond], reg[rsrc1]);
}
else
util::stream_format(stream, "jmp%s %s[%s]", setcond[cond], reg[rsrc1], src2(op,2));
break;
- case 0x1f: util::stream_format(stream, "trap $1f"); flags = DASMFLAG_STEP_OVER; break;
+ case 0x1f: util::stream_format(stream, "trap $1f"); flags = STEP_OVER; break;
}
- return 4 | flags | DASMFLAG_SUPPORTED;
+ return 4 | flags | SUPPORTED;
+}
+
+u32 asap_disassembler::opcode_alignment() const
+{
+ return 4;
}
diff --git a/src/devices/cpu/asap/asapdasm.h b/src/devices/cpu/asap/asapdasm.h
new file mode 100644
index 00000000000..45ca554368d
--- /dev/null
+++ b/src/devices/cpu/asap/asapdasm.h
@@ -0,0 +1,33 @@
+// license:BSD-3-Clause
+// copyright-holders:Aaron Giles
+/***************************************************************************
+
+ asapdasm.c
+ Disassembler for the portable ASAP emulator.
+ Written by Aaron Giles
+
+***************************************************************************/
+
+#ifndef MAME_CPU_ASAP_ASAPDASM_H
+#define MAME_CPU_ASAP_ASAPDASM_H
+
+#pragma once
+
+class asap_disassembler : public util::disasm_interface
+{
+public:
+ asap_disassembler() = default;
+ virtual ~asap_disassembler() = default;
+
+ virtual u32 opcode_alignment() const override;
+ virtual offs_t disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer &params) override;
+
+private:
+ static const char *const reg[32];
+ static const char *const setcond[2];
+ static const char *const condition[16];
+ std::string src2(uint32_t op, int scale);
+
+};
+
+#endif