From e92074170d7d60c84c2325eb1412256206435360 Mon Sep 17 00:00:00 2001 From: Michael Zapf Date: Fri, 9 Aug 2013 20:30:50 +0000 Subject: [PATCH] Force word-aligned workspace pointer and program counter --- src/emu/cpu/tms9900/tms9900.c | 26 +++++++++++++------------- src/emu/cpu/tms9900/tms9995.c | 28 ++++++++++++++-------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/emu/cpu/tms9900/tms9900.c b/src/emu/cpu/tms9900/tms9900.c index 3ccbd5f308f..22a633fd4dc 100644 --- a/src/emu/cpu/tms9900/tms9900.c +++ b/src/emu/cpu/tms9900/tms9900.c @@ -242,10 +242,10 @@ void tms99xx_device::state_import(const device_state_entry &entry) // bits of the STATUS register break; case TMS9900_PC: - PC = (UINT16)(m_state_any & m_prgaddr_mask); + PC = (UINT16)(m_state_any & m_prgaddr_mask & 0xfffe); break; case TMS9900_WP: - WP = (UINT16)(m_state_any & m_prgaddr_mask); + WP = (UINT16)(m_state_any & m_prgaddr_mask & 0xfffe); break; case TMS9900_STATUS: ST = (UINT16)m_state_any; @@ -1942,7 +1942,7 @@ void tms99xx_device::alu_xop() break; case 1: m_value_copy = WP; // save the old WP - WP = m_current_value & m_prgaddr_mask; // the new WP has been read in the previous microoperation + WP = m_current_value & m_prgaddr_mask & 0xfffe; // the new WP has been read in the previous microoperation m_current_value = m_address_saved; // we saved the address of the source operand; retrieve it m_address = WP + 0x0016; // Next register is R11 break; @@ -1963,7 +1963,7 @@ void tms99xx_device::alu_xop() set_status_bit(ST_X, true); break; case 6: - PC = m_current_value & m_prgaddr_mask; + PC = m_current_value & m_prgaddr_mask & 0xfffe; break; } pulse_clock(2); @@ -2087,7 +2087,7 @@ void tms99xx_device::alu_b() // retrieves the value at 0xa000, but in fact it will load the PC // with the address 0xa000 m_current_value = PC; - PC = m_address & m_prgaddr_mask; + PC = m_address & m_prgaddr_mask & 0xfffe; m_address = WP + 22; if (VERBOSE>7) LOG("tms99xx: Set new PC = %04x\n", PC); pulse_clock(2); @@ -2099,7 +2099,7 @@ void tms99xx_device::alu_blwp() { case 0: m_value_copy = WP; - WP = m_current_value & m_prgaddr_mask; // set new WP (*m_destination) + WP = m_current_value & m_prgaddr_mask & 0xfffe; // set new WP (*m_destination) m_address_saved = (m_address + 2) & m_prgaddr_mask; // Save the location of the WP m_address = WP + 30; m_current_value = ST; // get status register @@ -2116,7 +2116,7 @@ void tms99xx_device::alu_blwp() m_address = m_address_saved; // point to PC component of branch vector break; case 4: - PC = m_current_value & m_prgaddr_mask; + PC = m_current_value & m_prgaddr_mask & 0xfffe; if (VERBOSE>5) LOG("tms9900: Context switch complete; WP=%04x, PC=%04x, ST=%04x\n", WP, PC, ST); break; } @@ -2316,7 +2316,7 @@ void tms99xx_device::alu_jmp() else { displacement = (IR & 0xff); - PC = (PC + (displacement<<1)) & m_prgaddr_mask; + PC = (PC + (displacement<<1)) & m_prgaddr_mask & 0xfffe; pulse_clock(2); } m_state++; @@ -2437,7 +2437,7 @@ void tms99xx_device::alu_li() void tms99xx_device::alu_lwpi() { - WP = m_current_value & m_prgaddr_mask; + WP = m_current_value & m_prgaddr_mask & 0xfffe; pulse_clock(2); } @@ -2486,11 +2486,11 @@ void tms99xx_device::alu_rtwp() m_address -= 2; // R14 break; case 2: - PC = m_current_value & m_prgaddr_mask; + PC = m_current_value & m_prgaddr_mask & 0xfffe; m_address -= 2; // R13 break; case 3: - WP = m_current_value & m_prgaddr_mask; + WP = m_current_value & m_prgaddr_mask & 0xfffe; break; } m_state++; @@ -2521,7 +2521,7 @@ void tms99xx_device::alu_int() case 1: m_address_copy = m_address; m_value_copy = WP; // old WP - WP = m_current_value & m_prgaddr_mask; // new WP + WP = m_current_value & m_prgaddr_mask & 0xfffe; // new WP m_current_value = ST; m_address = (WP + 30) & m_prgaddr_mask; break; @@ -2538,7 +2538,7 @@ void tms99xx_device::alu_int() if (VERBOSE>7) LOG("tms99xx: read from %04x\n", m_address); break; case 5: - PC = m_current_value & m_prgaddr_mask; + PC = m_current_value & m_prgaddr_mask & 0xfffe; if (m_irq_level > 0 ) { ST = (ST & 0xfff0) | (m_irq_level - 1); diff --git a/src/emu/cpu/tms9900/tms9995.c b/src/emu/cpu/tms9900/tms9995.c index e119973c193..14356fd6bcd 100644 --- a/src/emu/cpu/tms9900/tms9995.c +++ b/src/emu/cpu/tms9900/tms9995.c @@ -237,10 +237,10 @@ void tms9995_device::state_import(const device_state_entry &entry) // bits of the STATUS register break; case TMS9995_PC: - PC = (UINT16)m_state_any; + PC = (UINT16)m_state_any & 0xfffe; break; case TMS9995_WP: - WP = (UINT16)m_state_any; + WP = (UINT16)m_state_any & 0xfffe; break; case TMS9995_STATUS: ST = (UINT16)m_state_any; @@ -2229,7 +2229,7 @@ void tms9995_device::alu_add_s_sxc() void tms9995_device::alu_b() { m_current_value = PC; - PC = m_address; + PC = m_address & 0xfffe; m_address = WP + 22; } @@ -2245,7 +2245,7 @@ void tms9995_device::alu_blwp() case 0: // new WP in m_current_value m_value_copy = WP; - WP = m_current_value; + WP = m_current_value & 0xfffe; m_address_saved = m_address + 2; m_address = WP + 30; m_current_value = ST; @@ -2262,7 +2262,7 @@ void tms9995_device::alu_blwp() m_address = m_address_saved; break; case 4: - PC = m_current_value; + PC = m_current_value & 0xfffe; n = 0; if (VERBOSE>5) LOG("tms9995: Context switch complete; WP=%04x, PC=%04x, ST=%04x\n", WP, PC, ST); break; @@ -2653,7 +2653,7 @@ void tms9995_device::alu_jump() else { if (VERBOSE>7) LOG("tms9995: Jump condition true\n"); - PC = PC + (displacement<<1); + PC = (PC + (displacement<<1)) & 0xfffe; } pulse_clock(1); } @@ -2716,7 +2716,7 @@ void tms9995_device::alu_limi_lwpi() } else { - WP = m_current_value; + WP = m_current_value & 0xfffe; if (VERBOSE>7) LOG("tms9995: new WP = %04x\n", WP); } } @@ -2735,7 +2735,7 @@ void tms9995_device::alu_lst_lwp() } else { - WP = m_current_value; + WP = m_current_value & 0xfffe; if (VERBOSE>7) LOG("tms9995: new WP = %04x\n", WP); } } @@ -2838,11 +2838,11 @@ void tms9995_device::alu_rtwp() m_address -= 2; // R14 break; case 2: - PC = m_current_value; + PC = m_current_value & 0xfffe; m_address -= 2; // R13 break; case 3: - WP = m_current_value; + WP = m_current_value & 0xfffe; n = 1; break; } @@ -3154,7 +3154,7 @@ void tms9995_device::alu_xop() case 1: // m_current_value is new WP m_value_copy = WP; // store this for later - WP = m_current_value; + WP = m_current_value & 0xfffe; m_address = WP + 0x0016; // Address of new R11 m_current_value = m_address_saved; break; @@ -3174,7 +3174,7 @@ void tms9995_device::alu_xop() m_address = 0x0042 + ((m_instruction->IR & 0x03c0)>>4); break; case 6: - PC = m_current_value; + PC = m_current_value & 0xfffe; set_status_bit(ST_X, true); n = 0; break; @@ -3201,7 +3201,7 @@ void tms9995_device::alu_int() case 1: pulse = 2; // two cycles (with the one at the end) m_source_value = WP; // old WP - WP = m_current_value; // new WP + WP = m_current_value & 0xfffe; // new WP m_current_value = ST; m_address = (WP + 30)&0xfffe; if (VERBOSE>7) LOG("tms9995: interrupt service (1): Read new WP = %04x, save ST to %04x\n", WP, m_address); @@ -3221,7 +3221,7 @@ void tms9995_device::alu_int() if (VERBOSE>7) LOG("tms9995: interrupt service (4): Read PC from %04x\n", m_address); break; case 5: - PC = m_current_value; + PC = m_current_value & 0xfffe; ST = (ST & 0xfe00) | m_intmask; if (VERBOSE>5) LOG("tms9995: interrupt service (5): Context switch complete; WP=%04x, PC=%04x, ST=%04x\n", WP, PC, ST);