summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/dsp32
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/cpu/dsp32')
-rw-r--r--src/devices/cpu/dsp32/dsp32.cpp40
-rw-r--r--src/devices/cpu/dsp32/dsp32.h13
-rw-r--r--src/devices/cpu/dsp32/dsp32dis.cpp6
-rw-r--r--src/devices/cpu/dsp32/dsp32ops.hxx13
4 files changed, 27 insertions, 45 deletions
diff --git a/src/devices/cpu/dsp32/dsp32.cpp b/src/devices/cpu/dsp32/dsp32.cpp
index 26310c760ad..d75b62e5acd 100644
--- a/src/devices/cpu/dsp32/dsp32.cpp
+++ b/src/devices/cpu/dsp32/dsp32.cpp
@@ -31,7 +31,6 @@
#include "emu.h"
#include "dsp32.h"
#include "dsp32dis.h"
-#include "debugger.h"
//**************************************************************************
@@ -174,8 +173,6 @@ dsp32c_device::dsp32c_device(const machine_config &mconfig, const char *tag, dev
m_icount(0),
m_lastpins(0),
m_ppc(0),
- m_program(nullptr),
- m_cache(nullptr),
m_output_pins_changed(*this)
{
// set our instruction counter
@@ -188,16 +185,13 @@ dsp32c_device::dsp32c_device(const machine_config &mconfig, const char *tag, dev
void dsp32c_device::device_start()
{
- m_output_pins_changed.resolve_safe();
-
// get our address spaces
- 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);
// register our state for the debugger
state_add(STATE_GENPC, "GENPC", m_r[15]).noshow();
state_add(STATE_GENPCBASE, "CURPC", m_ppc).noshow();
- state_add(STATE_GENSP, "GENSP", m_r[21]).noshow();
state_add(STATE_GENFLAGS, "GENFLAGS", m_iotemp).callimport().callexport().formatstr("%6s").noshow();
state_add(DSP32_PC, "PC", m_r[15]).mask(0xffffff);
for (int regnum = 0; regnum <= 14; regnum++)
@@ -415,17 +409,17 @@ std::unique_ptr<util::disasm_interface> dsp32c_device::create_disassembler()
inline uint32_t dsp32c_device::ROPCODE(offs_t pc)
{
- return m_cache->read_dword(pc);
+ return m_cache.read_dword(pc);
}
inline uint8_t dsp32c_device::RBYTE(offs_t addr)
{
- return m_program->read_byte(addr);
+ return m_program.read_byte(addr);
}
inline void dsp32c_device::WBYTE(offs_t addr, uint8_t data)
{
- m_program->write_byte(addr, data);
+ m_program.write_byte(addr, data);
}
inline uint16_t dsp32c_device::RWORD(offs_t addr)
@@ -434,7 +428,7 @@ inline uint16_t dsp32c_device::RWORD(offs_t addr)
if (!WORD_ALIGNED(addr))
osd_printf_error("Unaligned word read @ %06X, PC=%06X\n", addr, PC);
#endif
- return m_program->read_word(addr);
+ return m_program.read_word(addr);
}
inline uint32_t dsp32c_device::RLONG(offs_t addr)
@@ -443,7 +437,7 @@ inline uint32_t dsp32c_device::RLONG(offs_t addr)
if (!DWORD_ALIGNED(addr))
osd_printf_error("Unaligned long read @ %06X, PC=%06X\n", addr, PC);
#endif
- return m_program->read_dword(addr);
+ return m_program.read_dword(addr);
}
inline void dsp32c_device::WWORD(offs_t addr, uint16_t data)
@@ -452,7 +446,7 @@ inline void dsp32c_device::WWORD(offs_t addr, uint16_t data)
if (!WORD_ALIGNED(addr))
osd_printf_error("Unaligned word write @ %06X, PC=%06X\n", addr, PC);
#endif
- m_program->write_word(addr, data);
+ m_program.write_word(addr, data);
}
inline void dsp32c_device::WLONG(offs_t addr, uint32_t data)
@@ -461,7 +455,7 @@ inline void dsp32c_device::WLONG(offs_t addr, uint32_t data)
if (!DWORD_ALIGNED(addr))
osd_printf_error("Unaligned long write @ %06X, PC=%06X\n", addr, PC);
#endif
- m_program->write_dword(addr, data);
+ m_program.write_dword(addr, data);
}
@@ -542,7 +536,7 @@ void dsp32c_device::update_pins(void)
// cycles it takes for one instruction to execute
//-------------------------------------------------
-uint32_t dsp32c_device::execute_min_cycles() const
+uint32_t dsp32c_device::execute_min_cycles() const noexcept
{
return 4;
}
@@ -553,23 +547,12 @@ uint32_t dsp32c_device::execute_min_cycles() const
// cycles it takes for one instruction to execute
//-------------------------------------------------
-uint32_t dsp32c_device::execute_max_cycles() const
+uint32_t dsp32c_device::execute_max_cycles() const noexcept
{
return 4;
}
-//-------------------------------------------------
-// execute_input_lines - return the number of
-// input/interrupt lines
-//-------------------------------------------------
-
-uint32_t dsp32c_device::execute_input_lines() const
-{
- return 2;
-}
-
-
void dsp32c_device::execute_set_input(int inputnum, int state)
{
}
@@ -580,6 +563,7 @@ void dsp32c_device::execute_run()
// skip if halted
if ((m_pcr & PCR_RESET) == 0)
{
+ debugger_wait_hook();
m_icount = 0;
return;
}
diff --git a/src/devices/cpu/dsp32/dsp32.h b/src/devices/cpu/dsp32/dsp32.h
index 9aa02201dd5..4f9f3f9bdf9 100644
--- a/src/devices/cpu/dsp32/dsp32.h
+++ b/src/devices/cpu/dsp32/dsp32.h
@@ -103,13 +103,12 @@ protected:
};
// device-level overrides
- virtual void device_start() override;
- virtual void device_reset() override;
+ virtual void device_start() override ATTR_COLD;
+ virtual void device_reset() override ATTR_COLD;
// device_execute_interface overrides
- virtual uint32_t execute_min_cycles() const override;
- virtual uint32_t execute_max_cycles() const override;
- virtual uint32_t execute_input_lines() const override;
+ virtual uint32_t execute_min_cycles() const noexcept override;
+ virtual uint32_t execute_max_cycles() const noexcept override;
virtual void execute_run() override;
virtual void execute_set_input(int inputnum, int state) override;
@@ -416,8 +415,8 @@ protected:
int m_icount;
uint8_t m_lastpins;
uint32_t m_ppc;
- address_space * m_program;
- memory_access_cache<2, 0, ENDIANNESS_LITTLE> *m_cache;
+ memory_access<24, 2, 0, ENDIANNESS_LITTLE>::cache m_cache;
+ memory_access<24, 2, 0, ENDIANNESS_LITTLE>::specific m_program;
devcb_write32 m_output_pins_changed;
// tables
diff --git a/src/devices/cpu/dsp32/dsp32dis.cpp b/src/devices/cpu/dsp32/dsp32dis.cpp
index 8748b2b55ab..1fc0d225a70 100644
--- a/src/devices/cpu/dsp32/dsp32dis.cpp
+++ b/src/devices/cpu/dsp32/dsp32dis.cpp
@@ -354,6 +354,8 @@ offs_t dsp32c_disassembler::disassemble(std::ostream &stream, offs_t pc, const d
flags = STEP_OUT;
util::stream_format(stream, "if (%s) goto %s", condtable[C], rH);
}
+ if (C > 1)
+ flags |= STEP_COND;
}
break;
}
@@ -440,10 +442,10 @@ offs_t dsp32c_disassembler::disassemble(std::ostream &stream, offs_t pc, const d
const char *rS2 = regname[(op >> 0) & 0x1f];
const char *s = sizesuffix[(op >> 31) & 1];
uint8_t threeop = (op >> 11) & 1;
- char condbuf[40] = { 0 };
+ std::string condbuf;
if ((op >> 10) & 1)
- sprintf(condbuf, "if (%s) ", condtable[(op >> 12) & 15]);
+ condbuf = "if (" + std::string(condtable[(op >> 12) & 15]) + ") ";
switch ((op >> 21) & 15)
{
diff --git a/src/devices/cpu/dsp32/dsp32ops.hxx b/src/devices/cpu/dsp32/dsp32ops.hxx
index ecffcde443c..f213b8b2d93 100644
--- a/src/devices/cpu/dsp32/dsp32ops.hxx
+++ b/src/devices/cpu/dsp32/dsp32ops.hxx
@@ -261,7 +261,7 @@ inline void dsp32c_device::cau_write_pi_4byte(int pi, uint32_t val)
int i = (pi >> 0) & 0x1f;
if (p)
{
- WLONG(m_r[p], (int32_t)(val << 8) >> 8);
+ WLONG(m_r[p], util::sext(val, 24));
if (i < 22 || i > 23)
m_r[p] = TRUNCATE24(m_r[p] + m_r[i]);
else
@@ -1844,7 +1844,7 @@ void dsp32c_device::store_i(uint32_t op)
void dsp32c_device::store_ei(uint32_t op)
{
- WLONG(EXTEND16_TO_24(op), (int32_t)(REG24((op >> 16) & 0x1f) << 8) >> 8);
+ WLONG(EXTEND16_TO_24(op), util::sext(REG24((op >> 16) & 0x1f), 24));
}
@@ -2431,7 +2431,7 @@ void dsp32c_device::d5_ifagt(uint32_t op)
void dsp32c_device::d5_float24(uint32_t op)
{
- double res = (double)((int32_t)(dau_read_pi_4bytes(op >> 7) << 8) >> 8);
+ double res = (double)util::sext(dau_read_pi_4bytes(op >> 7), 24);
int zpi = (op >> 0) & 0x7f;
if (zpi != 7)
dau_write_pi_double(zpi, res);
@@ -2443,14 +2443,11 @@ void dsp32c_device::d5_int24(uint32_t op)
{
double val = dau_read_pi_double_1st(op >> 7, 0);
int zpi = (op >> 0) & 0x7f;
- int32_t res;
if (!(DAUC & 0x10)) val = floor(val + 0.5);
else val = ceil(val - 0.5);
- res = (int32_t)val;
- if (res > 0x7fffff) res = 0x7fffff;
- else if (res < -0x800000) res = -0x800000;
+ int32_t res = int32_t(std::clamp<double>(val, -0x800000, 0x7fffff));
if (zpi != 7)
- dau_write_pi_4bytes(zpi, (int32_t)(res << 8) >> 8);
+ dau_write_pi_4bytes(zpi, res);
dau_set_val_noflags((op >> 21) & 3, dsp_to_double(res << 8));
}