summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2019-09-10 19:31:38 -0400
committer AJR <ajrhacker@users.noreply.github.com>2019-09-10 19:31:45 -0400
commit0cd99546dd2e7c8399b093de5e19189f2a668ab5 (patch)
tree40f1dbcb85824a8d6dcb5e9e2bc235276fbd4f1b
parent286b34a24c17a235b00a6288d27fc1ed94638e02 (diff)
rii: Stack endianness is swapped; TBRD is allowed to be RPTed (nw)
-rw-r--r--src/devices/cpu/rii/riscii.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/devices/cpu/rii/riscii.cpp b/src/devices/cpu/rii/riscii.cpp
index 11978351072..9155fa93cbe 100644
--- a/src/devices/cpu/rii/riscii.cpp
+++ b/src/devices/cpu/rii/riscii.cpp
@@ -614,7 +614,8 @@ void riscii_series_device::execute_jump(u32 addr)
void riscii_series_device::execute_call(u32 addr)
{
m_stkptr -= 2;
- m_regs->write_word((BIT(m_stkptr, 7) ? m_maxbank : m_maxbank - 1) << 8 | 0x80 | (m_stkptr & 0x7e), m_pc & 0xffff);
+ u16 stkaddr = u16(m_maxbank - (BIT(m_stkptr, 7) ? 0 : 1)) << 8 | 0x80 | (m_stkptr & 0x7e);
+ m_regs->write_word(stkaddr, swapendian_int16(m_pc & 0xffff));
execute_jump(addr);
}
@@ -746,7 +747,8 @@ void riscii_series_device::execute_rpt(u8 reg)
void riscii_series_device::execute_ret(bool inte)
{
- execute_jump((m_pc & 0xf0000) | m_regs->read_word((BIT(m_stkptr, 7) ? m_maxbank : m_maxbank - 1) << 8 | 0x80 | (m_stkptr & 0x7e)));
+ u16 stkaddr = u16(m_maxbank - (BIT(m_stkptr, 7) ? 0 : 1)) << 8 | 0x80 | (m_stkptr & 0x7e);
+ execute_jump((m_pc & 0xf0000) | swapendian_int16(m_regs->read_word(stkaddr)));
m_stkptr += 2;
if (inte)
m_cpucon |= 0x08;
@@ -1056,7 +1058,10 @@ void riscii_series_device::execute_tbrd(u32 ptr)
m_regs->write_byte(addr, data >> 8);
else
m_regs->write_byte(addr, data);
- m_exec_state = EXEC_CYCLE1;
+ if (m_repeat != 0)
+ --m_repeat;
+ else
+ m_exec_state = EXEC_CYCLE1;
}
void riscii_series_device::execute_run()
@@ -1070,8 +1075,12 @@ void riscii_series_device::execute_run()
debugger_instruction_hook(m_pc);
if (m_repeat != 0)
{
- --m_repeat;
- execute_cycle1(m_cache->read_word(m_pc));
+ execute_cycle1(m_cache->read_word(m_pc++));
+ if (m_exec_state == EXEC_CYCLE1)
+ {
+ --m_repeat;
+ m_pc = m_ppc;
+ }
}
else
execute_cycle1(m_cache->read_word(m_pc++));