summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/se3208/se3208.cpp
diff options
context:
space:
mode:
author Olivier Galibert <galibert@pobox.com>2020-05-25 16:42:42 +0200
committer Olivier Galibert <galibert@pobox.com>2020-05-25 16:42:57 +0200
commit22513fb6fe281f5ccb75aaddb6417a12a66c313d (patch)
tree3cf84032cc6482d685a8dbb57e015bd17c7f7fdc /src/devices/cpu/se3208/se3208.cpp
parente42c2d2874cf9c1092c01ab5ce9ef997d465ce25 (diff)
emumem: A little more speedup. cache and specific change syntax, and are not pointers anymore [O. Galibert]
The last(?) two changes are: - Add a template parameter to everything (theoretically the address space width, in practice a level derived from it to keep as much compatibility between widths as possible) so that the shift size becomes a constant. - Change the syntax of declaring and initializing the caches and specifics so that they're embedded in the owner device. Solves lifetime issues and also removes one indirection (looking up the base dispatch pointer through the cache/specific pointer).
Diffstat (limited to 'src/devices/cpu/se3208/se3208.cpp')
-rw-r--r--src/devices/cpu/se3208/se3208.cpp98
1 files changed, 38 insertions, 60 deletions
diff --git a/src/devices/cpu/se3208/se3208.cpp b/src/devices/cpu/se3208/se3208.cpp
index a8d2381c0da..6e5a15bef2c 100644
--- a/src/devices/cpu/se3208/se3208.cpp
+++ b/src/devices/cpu/se3208/se3208.cpp
@@ -53,7 +53,7 @@ se3208_device::se3208_device(const machine_config &mconfig, const char *tag, dev
, m_program_config("program", ENDIANNESS_LITTLE, 32, 32, 0)
, m_machinex_cb(*this)
, m_iackx_cb(*this)
- , m_PC(0), m_SR(0), m_SP(0), m_ER(0), m_PPC(0), m_program(nullptr), m_cache(nullptr), m_IRQ(0), m_NMI(0), m_icount(0)
+ , m_PC(0), m_SR(0), m_SP(0), m_ER(0), m_PPC(0), m_IRQ(0), m_NMI(0), m_icount(0)
{
}
@@ -72,88 +72,66 @@ void se3208_device::device_resolve_objects()
}
-uint32_t se3208_device::read_dword_unaligned(address_space &space, uint32_t address)
+uint8_t se3208_device::SE3208_Read8(uint32_t address)
{
- if (DWORD_ALIGNED(address))
- return space.read_dword(address);
- else
- {
- osd_printf_debug("%08x: dword READ unaligned %08x\n", m_PC, address);
-#if ALLOW_UNALIGNED_DWORD_ACCESS
- return space.read_byte(address) | space.read_byte(address + 1) << 8 | space.read_byte(address + 2) << 16 | space.read_byte(address + 3) << 24;
-#else
- return 0;
-#endif
- }
+ return m_program.read_byte(address);
}
-uint16_t se3208_device::read_word_unaligned(address_space &space, uint32_t address)
+uint16_t se3208_device::SE3208_Read16(uint32_t address)
{
if (!WORD_ALIGNED(address))
- return space.read_byte(address) | space.read_byte(address+1)<<8;
+ return m_program.read_byte(address) | m_program.read_byte(address+1)<<8;
else
- return space.read_word(address);
+ return m_program.read_word(address);
}
-void se3208_device::write_dword_unaligned(address_space &space, uint32_t address, uint32_t data)
+uint32_t se3208_device::SE3208_Read32(uint32_t address)
{
if (DWORD_ALIGNED(address))
- space.write_dword(address, data);
+ return m_program.read_dword(address);
else
{
+ osd_printf_debug("%08x: dword READ unaligned %08x\n", m_PC, address);
#if ALLOW_UNALIGNED_DWORD_ACCESS
- space.write_byte(address, data & 0xff);
- space.write_byte(address + 1, (data >> 8) & 0xff);
- space.write_byte(address + 2, (data >> 16) & 0xff);
- space.write_byte(address + 3, (data >> 24) & 0xff);
+ return m_program.read_byte(address) | m_program.read_byte(address + 1) << 8 | m_program.read_byte(address + 2) << 16 | m_program.read_byte(address + 3) << 24;
+#else
+ return 0;
#endif
- osd_printf_debug("%08x: dword WRITE unaligned %08x\n", m_PC, address);
}
+}
+void se3208_device::SE3208_Write8(uint32_t address,uint8_t data)
+{
+ m_program.write_byte(address,data);
}
-void se3208_device::write_word_unaligned(address_space &space, uint32_t address, uint16_t data)
+void se3208_device::SE3208_Write16(uint32_t address,uint16_t data)
{
if (!WORD_ALIGNED(address))
{
- space.write_byte(address, data & 0xff);
- space.write_byte(address+1, (data>>8)&0xff);
+ m_program.write_byte(address, data & 0xff);
+ m_program.write_byte(address+1, (data>>8)&0xff);
}
else
{
- space.write_word(address, data);
+ m_program.write_word(address, data);
}
}
-
-uint8_t se3208_device::SE3208_Read8(uint32_t addr)
-{
- return m_program->read_byte(addr);
-}
-
-uint16_t se3208_device::SE3208_Read16(uint32_t addr)
+void se3208_device::SE3208_Write32(uint32_t address, uint32_t data)
{
- return read_word_unaligned(*m_program,addr);
-}
-
-uint32_t se3208_device::SE3208_Read32(uint32_t addr)
-{
- return read_dword_unaligned(*m_program,addr);
-}
-
-void se3208_device::SE3208_Write8(uint32_t addr,uint8_t val)
-{
- m_program->write_byte(addr,val);
-}
-
-void se3208_device::SE3208_Write16(uint32_t addr,uint16_t val)
-{
- write_word_unaligned(*m_program,addr,val);
-}
-
-void se3208_device::SE3208_Write32(uint32_t addr,uint32_t val)
-{
- write_dword_unaligned(*m_program,addr,val);
+ if (DWORD_ALIGNED(address))
+ m_program.write_dword(address, data);
+ else
+ {
+#if ALLOW_UNALIGNED_DWORD_ACCESS
+ m_program.write_byte(address, data & 0xff);
+ m_program.write_byte(address + 1, (data >> 8) & 0xff);
+ m_program.write_byte(address + 2, (data >> 16) & 0xff);
+ m_program.write_byte(address + 3, (data >> 24) & 0xff);
+#endif
+ osd_printf_debug("%08x: dword WRITE unaligned %08x\n", m_PC, address);
+ }
}
@@ -1732,8 +1710,8 @@ void se3208_device::device_reset()
m_SP = 0;
m_ER = 0;
m_PPC = 0;
- m_program = &space(AS_PROGRAM);
- m_cache = m_program->cache<2, 0, ENDIANNESS_LITTLE>();
+ space(AS_PROGRAM).cache(m_cache);
+ space(AS_PROGRAM).specific(m_program);
m_PC=SE3208_Read32(0);
m_SR=0;
m_IRQ=CLEAR_LINE;
@@ -1777,7 +1755,7 @@ void se3208_device::execute_run()
{
do
{
- uint16_t Opcode=m_cache->read_word(m_PC, WORD_XOR_LE(0));
+ uint16_t Opcode=m_cache.read_word(m_PC, WORD_XOR_LE(0));
m_PPC = m_PC;
debugger_instruction_hook(m_PC);
@@ -1802,8 +1780,8 @@ void se3208_device::device_start()
{
BuildTable();
- m_program = &space(AS_PROGRAM);
- m_cache = m_program->cache<2, 0, ENDIANNESS_LITTLE>();
+ space(AS_PROGRAM).cache(m_cache);
+ space(AS_PROGRAM).specific(m_program);
save_item(NAME(m_R));
save_item(NAME(m_PC));