diff options
author | 2019-08-29 12:13:51 -0400 | |
---|---|---|
committer | 2019-08-29 12:13:51 -0400 | |
commit | 4effbd40d6684233e3bee9378939d7ef6c685eee (patch) | |
tree | fdd83cc9f2496626d24f5f1c2e18adbf49862818 /src/devices/cpu | |
parent | 194691c63475ed5b5beee0174e119e946944613b (diff) |
f2mc16: fixed BBC branch offset, add savestates, cleanup variable usage in utility functions [R. Belmont]
Diffstat (limited to 'src/devices/cpu')
-rw-r--r-- | src/devices/cpu/f2mc16/f2mc16.cpp | 24 | ||||
-rw-r--r-- | src/devices/cpu/f2mc16/f2mc16.h | 86 |
2 files changed, 66 insertions, 44 deletions
diff --git a/src/devices/cpu/f2mc16/f2mc16.cpp b/src/devices/cpu/f2mc16/f2mc16.cpp index cbe44880421..e581a2e49e1 100644 --- a/src/devices/cpu/f2mc16/f2mc16.cpp +++ b/src/devices/cpu/f2mc16/f2mc16.cpp @@ -93,6 +93,28 @@ void f2mc16_device::device_start() state_add(F2MC16_R5, "R5", m_temp).callimport().callexport().formatstr("%02X"); state_add(F2MC16_R6, "R6", m_temp).callimport().callexport().formatstr("%02X"); state_add(F2MC16_R7, "R7", m_temp).callimport().callexport().formatstr("%02X"); + + save_item(NAME(m_pc)); + save_item(NAME(m_usp)); + save_item(NAME(m_ssp)); + save_item(NAME(m_ps)); + save_item(NAME(m_tmp16)); + save_item(NAME(m_tmpea)); + save_item(NAME(m_tmp16aux)); + save_item(NAME(m_pcb)); + save_item(NAME(m_dtb)); + save_item(NAME(m_usb)); + save_item(NAME(m_ssb)); + save_item(NAME(m_adb)); + save_item(NAME(m_dpr)); + save_item(NAME(m_tmp8)); + save_item(NAME(m_prefix)); + save_item(NAME(m_acc)); + save_item(NAME(m_temp)); + save_item(NAME(m_tmp32)); + save_item(NAME(m_tmp32aux)); + save_item(NAME(m_tmp64)); + save_item(NAME(m_prefix_valid)); } void f2mc16_device::device_reset() @@ -1617,7 +1639,7 @@ void f2mc16_device::opcodes_bo6c(u8 operand) m_tmp32 = read_8((m_pcb<<16) | (m_pc+2)); m_tmp32 |= (m_dpr<<8) | (m_dtb<<8); m_tmp8 = read_8(m_tmp32); - m_tmp8 = read_8((m_pcb << 16) | (m_pc + 4)); + m_tmp8 = read_8((m_pcb << 16) | (m_pc + 3)); m_ps &= ~F_Z; m_pc += 4; if (!(read_8(m_tmp32) & (1 << (operand & 7)))) diff --git a/src/devices/cpu/f2mc16/f2mc16.h b/src/devices/cpu/f2mc16/f2mc16.h index abcf35e4d53..032b0ca2b34 100644 --- a/src/devices/cpu/f2mc16/f2mc16.h +++ b/src/devices/cpu/f2mc16/f2mc16.h @@ -321,42 +321,42 @@ private: inline void doCMP_8(u8 lhs, u8 rhs) { - m_tmp16 = lhs - rhs; - setNZ_16(m_tmp16 & 0xff); + u16 tmp16 = lhs - rhs; + setNZ_16(tmp16 & 0xff); m_ps &= ~(F_C|F_V); - if (m_tmp16 & 0x100) + if (tmp16 & 0x100) { m_ps |= F_C; } - if ((lhs ^ rhs) & (lhs ^ (m_tmp16 & 0xff)) & 0x80) + if ((lhs ^ rhs) & (lhs ^ (tmp16 & 0xff)) & 0x80) { m_ps |= F_V; } } inline void doCMP_16(u16 lhs, u16 rhs) { - m_tmp32 = lhs - rhs; - setNZ_16(m_tmp32 & 0xffff); + u32 tmp32 = lhs - rhs; + setNZ_16(tmp32 & 0xffff); m_ps &= ~(F_C|F_V); - if (m_tmp32 & 0x10000) + if (tmp32 & 0x10000) { m_ps |= F_C; } - if ((lhs ^ rhs) & (lhs ^ (m_tmp32 & 0xffff)) & 0x8000) + if ((lhs ^ rhs) & (lhs ^ (tmp32 & 0xffff)) & 0x8000) { m_ps |= F_V; } } inline void doCMP_32(u32 lhs, u32 rhs) { - m_tmp64 = lhs - rhs; - setNZ_32(m_tmp64 & 0xffffffff); + u64 tmp64 = lhs - rhs; + setNZ_32(tmp64 & 0xffffffff); m_ps &= ~(F_C|F_V); - if (m_tmp64 & 0x100000000) + if (tmp64 & 0x100000000) { m_ps |= F_C; } - if ((lhs ^ rhs) & (lhs ^ (m_tmp64 & 0xffffffff)) & 0x80000000) + if ((lhs ^ rhs) & (lhs ^ (tmp64 & 0xffffffff)) & 0x80000000) { m_ps |= F_V; } @@ -364,14 +364,14 @@ private: inline u8 doSUB_8(u8 lhs, u8 rhs) { - m_tmp16 = lhs - rhs; - setNZ_16(m_tmp16 & 0xff); + u16 tmp16 = lhs - rhs; + setNZ_16(tmp16 & 0xff); m_ps &= ~(F_C|F_V); - if (m_tmp16 & 0x100) + if (tmp16 & 0x100) { m_ps |= F_C; } - if ((lhs ^ rhs) & (lhs ^ (m_tmp16 & 0xff)) & 0x80) + if ((lhs ^ rhs) & (lhs ^ (tmp16 & 0xff)) & 0x80) { m_ps |= F_V; } @@ -380,89 +380,89 @@ private: } inline u16 doSUB_16(u16 lhs, u16 rhs) { - m_tmp32 = lhs - rhs; - setNZ_16(m_tmp32 & 0xffff); + u32 tmp32 = lhs - rhs; + setNZ_16(tmp32 & 0xffff); m_ps &= ~(F_C|F_V); - if (m_tmp32 & 0x10000) + if (tmp32 & 0x10000) { m_ps |= F_C; } - if ((lhs ^ rhs) & (lhs ^ (m_tmp32 & 0xffff)) & 0x8000) + if ((lhs ^ rhs) & (lhs ^ (tmp32 & 0xffff)) & 0x8000) { m_ps |= F_V; } - return m_tmp32 & 0xffff; + return tmp32 & 0xffff; } inline u32 doSUB_32(u32 lhs, u32 rhs) { - m_tmp64 = lhs - rhs; - setNZ_32(m_tmp64 & 0xffffffff); + u64 tmp64 = lhs - rhs; + setNZ_32(tmp64 & 0xffffffff); m_ps &= ~(F_C|F_V); - if (m_tmp64 & 0x100000000) + if (tmp64 & 0x100000000) { m_ps |= F_C; } - if ((lhs ^ rhs) & (lhs ^ (m_tmp64 & 0xffffffff)) & 0x8000000) + if ((lhs ^ rhs) & (lhs ^ (tmp64 & 0xffffffff)) & 0x8000000) { m_ps |= F_V; } - return m_tmp64 & 0xffffffff; + return tmp64 & 0xffffffff; } inline u8 doADD_8(u8 lhs, u8 rhs) { - m_tmp16 = lhs + rhs; + u16 tmp16 = lhs + rhs; m_ps &= ~(F_C|F_V); - if ((m_tmp16 ^ lhs) & (m_tmp16 ^ rhs) & 0x80) + if ((tmp16 ^ lhs) & (tmp16 ^ rhs) & 0x80) { m_ps |= F_V; } - if (m_tmp16 > 0xff) + if (tmp16 > 0xff) { m_ps |= F_C; } - setNZ_8(m_tmp16 & 0xff); + setNZ_8(tmp16 & 0xff); - return m_tmp16 & 0xff; + return tmp16 & 0xff; } inline u16 doADD_16(u16 lhs, u16 rhs) { - m_tmp32 = lhs + rhs; + u32 tmp32 = lhs + rhs; m_ps &= ~(F_C|F_V); - if ((m_tmp32 ^ lhs) & (m_tmp32 ^ rhs) & 0x8000) + if ((tmp32 ^ lhs) & (tmp32 ^ rhs) & 0x8000) { m_ps |= F_V; } - if (m_tmp32 > 0xffff) + if (tmp32 > 0xffff) { m_ps |= F_C; } - setNZ_16(m_tmp32 & 0xffff); + setNZ_16(tmp32 & 0xffff); - return m_tmp32 & 0xffff; + return tmp32 & 0xffff; } inline u32 doADD_32(u32 lhs, u32 rhs) { - m_tmp64 = lhs + rhs; + u64 tmp64 = lhs + rhs; m_ps &= ~(F_C|F_V); - if ((m_tmp64 ^ lhs) & (m_tmp64 ^ rhs) & 0x80000000) + if ((tmp64 ^ lhs) & (tmp64 ^ rhs) & 0x80000000) { m_ps |= F_V; } - if (m_tmp64 > 0xffffffff) + if (tmp64 > 0xffffffff) { m_ps |= F_C; } - setNZ_32(m_tmp64 & 0xffffffff); + setNZ_32(tmp64 & 0xffffffff); - return m_tmp64 & 0xffffffff; + return tmp64 & 0xffffffff; } inline void take_branch() { - m_tmp8 = read_8((m_pcb << 16) | (m_pc+1)); - m_pc = m_pc + 2 + (s8)m_tmp8; + u8 tmp8 = read_8((m_pcb << 16) | (m_pc+1)); + m_pc = m_pc + 2 + (s8)tmp8; m_icount -= 4; } |