From 108c194a17db692ef385e6b79e3be0722632f551 Mon Sep 17 00:00:00 2001 From: AJR Date: Fri, 10 Mar 2023 21:35:46 -0500 Subject: m68000: Ensure exception hook is called before SP is updated --- src/devices/cpu/m68000/m68000-sdf.cpp | 14 +++++++------- src/devices/cpu/m68000/m68000-sdp.cpp | 14 +++++++------- src/devices/cpu/m68000/m68000-sif.cpp | 14 +++++++------- src/devices/cpu/m68000/m68000-sip.cpp | 14 +++++++------- src/devices/cpu/m68000/m68000gen.py | 12 ++++++++---- 5 files changed, 36 insertions(+), 32 deletions(-) diff --git a/src/devices/cpu/m68000/m68000-sdf.cpp b/src/devices/cpu/m68000/m68000-sdf.cpp index 89efe17121f..6165bb3b2da 100644 --- a/src/devices/cpu/m68000/m68000-sdf.cpp +++ b/src/devices/cpu/m68000/m68000-sdf.cpp @@ -325,8 +325,8 @@ void m68000_device::state_bus_error_df() m_inst_state = S_ADDRESS_ERROR; return; } - m_da[16] = m_au; debugger_exception_hook(0x02); + m_da[16] = m_au; m_ftu = 0x0008; m_au = m_au + 2; // alu r=0 c=1 m=..... i=....... ALU.and_ a=R.pch:m_pc d=-1 @@ -830,8 +830,8 @@ void m68000_device::state_interrupt_df() m_inst_state = S_ADDRESS_ERROR; return; } - m_da[16] = m_au; debugger_exception_hook((m_int_vector) >> 2); + m_da[16] = m_au; m_ftu = m_int_vector; m_au = m_au + 2; // alu r=0 c=1 m=..... i=....... ALU.and_ a=R.pch:m_pc d=-1 @@ -1014,8 +1014,8 @@ void m68000_device::state_trace_df() m_inst_state = S_ADDRESS_ERROR; return; } - m_da[16] = m_au; debugger_exception_hook(0x09); + m_da[16] = m_au; m_ftu = 0x0024; m_au = m_au + 2; // alu r=0 c=1 m=..... i=....... ALU.and_ a=R.pch:m_pc d=-1 @@ -1198,8 +1198,8 @@ void m68000_device::state_illegal_df() m_inst_state = S_ADDRESS_ERROR; return; } - m_da[16] = m_au; debugger_exception_hook(0x04); + m_da[16] = m_au; m_ftu = 0x0010; m_au = m_au + 2; // alu r=0 c=1 m=..... i=....... ALU.and_ a=R.pch:m_pc d=-1 @@ -1566,8 +1566,8 @@ void m68000_device::state_linea_df() m_inst_state = S_ADDRESS_ERROR; return; } - m_da[16] = m_au; debugger_exception_hook(0x0a); + m_da[16] = m_au; m_ftu = 0x0028; m_au = m_au + 2; // alu r=0 c=1 m=..... i=....... ALU.and_ a=R.pch:m_pc d=-1 @@ -1750,8 +1750,8 @@ void m68000_device::state_linef_df() m_inst_state = S_ADDRESS_ERROR; return; } - m_da[16] = m_au; debugger_exception_hook(0x0b); + m_da[16] = m_au; m_ftu = 0x002c; m_au = m_au + 2; // alu r=0 c=1 m=..... i=....... ALU.and_ a=R.pch:m_pc d=-1 @@ -93974,8 +93974,8 @@ void m68000_device::trap_imm4_df() // 4e40 fff0 m_inst_state = S_ADDRESS_ERROR; return; } - m_da[16] = m_au; debugger_exception_hook((0x80 | ((m_ird & 0xf) << 2)) >> 2); + m_da[16] = m_au; m_ftu = 0x80 | ((m_ird & 0xf) << 2); m_au = m_au + 2; // alu r=0 c=1 m=..... i=....... ALU.and_ a=R.pch:m_pc d=-1 diff --git a/src/devices/cpu/m68000/m68000-sdp.cpp b/src/devices/cpu/m68000/m68000-sdp.cpp index 999bf3ea693..6ff74905aef 100644 --- a/src/devices/cpu/m68000/m68000-sdp.cpp +++ b/src/devices/cpu/m68000/m68000-sdp.cpp @@ -367,8 +367,8 @@ void m68000_device::state_bus_error_dp() m_inst_substate = 0; return; } - m_da[16] = m_au; debugger_exception_hook(0x02); + m_da[16] = m_au; m_ftu = 0x0008; m_au = m_au + 2; // alu r=0 c=1 m=..... i=....... ALU.and_ a=R.pch:m_pc d=-1 @@ -940,8 +940,8 @@ void m68000_device::state_interrupt_dp() m_inst_substate = 0; return; } - m_da[16] = m_au; debugger_exception_hook((m_int_vector) >> 2); + m_da[16] = m_au; m_ftu = m_int_vector; m_au = m_au + 2; // alu r=0 c=1 m=..... i=....... ALU.and_ a=R.pch:m_pc d=-1 @@ -1149,8 +1149,8 @@ void m68000_device::state_trace_dp() m_inst_substate = 0; return; } - m_da[16] = m_au; debugger_exception_hook(0x09); + m_da[16] = m_au; m_ftu = 0x0024; m_au = m_au + 2; // alu r=0 c=1 m=..... i=....... ALU.and_ a=R.pch:m_pc d=-1 @@ -1358,8 +1358,8 @@ void m68000_device::state_illegal_dp() m_inst_substate = 0; return; } - m_da[16] = m_au; debugger_exception_hook(0x04); + m_da[16] = m_au; m_ftu = 0x0010; m_au = m_au + 2; // alu r=0 c=1 m=..... i=....... ALU.and_ a=R.pch:m_pc d=-1 @@ -1776,8 +1776,8 @@ void m68000_device::state_linea_dp() m_inst_substate = 0; return; } - m_da[16] = m_au; debugger_exception_hook(0x0a); + m_da[16] = m_au; m_ftu = 0x0028; m_au = m_au + 2; // alu r=0 c=1 m=..... i=....... ALU.and_ a=R.pch:m_pc d=-1 @@ -1985,8 +1985,8 @@ void m68000_device::state_linef_dp() m_inst_substate = 0; return; } - m_da[16] = m_au; debugger_exception_hook(0x0b); + m_da[16] = m_au; m_ftu = 0x002c; m_au = m_au + 2; // alu r=0 c=1 m=..... i=....... ALU.and_ a=R.pch:m_pc d=-1 @@ -106990,8 +106990,8 @@ void m68000_device::trap_imm4_dp() // 4e40 fff0 m_inst_substate = 0; return; } - m_da[16] = m_au; debugger_exception_hook((0x80 | ((m_ird & 0xf) << 2)) >> 2); + m_da[16] = m_au; m_ftu = 0x80 | ((m_ird & 0xf) << 2); m_au = m_au + 2; // alu r=0 c=1 m=..... i=....... ALU.and_ a=R.pch:m_pc d=-1 diff --git a/src/devices/cpu/m68000/m68000-sif.cpp b/src/devices/cpu/m68000/m68000-sif.cpp index a347a8d792b..52c53e5f25e 100644 --- a/src/devices/cpu/m68000/m68000-sif.cpp +++ b/src/devices/cpu/m68000/m68000-sif.cpp @@ -325,8 +325,8 @@ void m68000_device::state_bus_error_if() m_inst_state = S_ADDRESS_ERROR; return; } - m_da[16] = m_au; debugger_exception_hook(0x02); + m_da[16] = m_au; m_ftu = 0x0008; m_au = m_au + 2; // alu r=0 c=1 m=..... i=....... ALU.and_ a=R.pch:m_pc d=-1 @@ -830,8 +830,8 @@ void m68000_device::state_interrupt_if() m_inst_state = S_ADDRESS_ERROR; return; } - m_da[16] = m_au; debugger_exception_hook((m_int_vector) >> 2); + m_da[16] = m_au; m_ftu = m_int_vector; m_au = m_au + 2; // alu r=0 c=1 m=..... i=....... ALU.and_ a=R.pch:m_pc d=-1 @@ -1014,8 +1014,8 @@ void m68000_device::state_trace_if() m_inst_state = S_ADDRESS_ERROR; return; } - m_da[16] = m_au; debugger_exception_hook(0x09); + m_da[16] = m_au; m_ftu = 0x0024; m_au = m_au + 2; // alu r=0 c=1 m=..... i=....... ALU.and_ a=R.pch:m_pc d=-1 @@ -1198,8 +1198,8 @@ void m68000_device::state_illegal_if() m_inst_state = S_ADDRESS_ERROR; return; } - m_da[16] = m_au; debugger_exception_hook(0x04); + m_da[16] = m_au; m_ftu = 0x0010; m_au = m_au + 2; // alu r=0 c=1 m=..... i=....... ALU.and_ a=R.pch:m_pc d=-1 @@ -1566,8 +1566,8 @@ void m68000_device::state_linea_if() m_inst_state = S_ADDRESS_ERROR; return; } - m_da[16] = m_au; debugger_exception_hook(0x0a); + m_da[16] = m_au; m_ftu = 0x0028; m_au = m_au + 2; // alu r=0 c=1 m=..... i=....... ALU.and_ a=R.pch:m_pc d=-1 @@ -1750,8 +1750,8 @@ void m68000_device::state_linef_if() m_inst_state = S_ADDRESS_ERROR; return; } - m_da[16] = m_au; debugger_exception_hook(0x0b); + m_da[16] = m_au; m_ftu = 0x002c; m_au = m_au + 2; // alu r=0 c=1 m=..... i=....... ALU.and_ a=R.pch:m_pc d=-1 @@ -93974,8 +93974,8 @@ void m68000_device::trap_imm4_if() // 4e40 fff0 m_inst_state = S_ADDRESS_ERROR; return; } - m_da[16] = m_au; debugger_exception_hook((0x80 | ((m_ird & 0xf) << 2)) >> 2); + m_da[16] = m_au; m_ftu = 0x80 | ((m_ird & 0xf) << 2); m_au = m_au + 2; // alu r=0 c=1 m=..... i=....... ALU.and_ a=R.pch:m_pc d=-1 diff --git a/src/devices/cpu/m68000/m68000-sip.cpp b/src/devices/cpu/m68000/m68000-sip.cpp index 5a8955e03d4..ded209913fe 100644 --- a/src/devices/cpu/m68000/m68000-sip.cpp +++ b/src/devices/cpu/m68000/m68000-sip.cpp @@ -367,8 +367,8 @@ void m68000_device::state_bus_error_ip() m_inst_substate = 0; return; } - m_da[16] = m_au; debugger_exception_hook(0x02); + m_da[16] = m_au; m_ftu = 0x0008; m_au = m_au + 2; // alu r=0 c=1 m=..... i=....... ALU.and_ a=R.pch:m_pc d=-1 @@ -940,8 +940,8 @@ void m68000_device::state_interrupt_ip() m_inst_substate = 0; return; } - m_da[16] = m_au; debugger_exception_hook((m_int_vector) >> 2); + m_da[16] = m_au; m_ftu = m_int_vector; m_au = m_au + 2; // alu r=0 c=1 m=..... i=....... ALU.and_ a=R.pch:m_pc d=-1 @@ -1149,8 +1149,8 @@ void m68000_device::state_trace_ip() m_inst_substate = 0; return; } - m_da[16] = m_au; debugger_exception_hook(0x09); + m_da[16] = m_au; m_ftu = 0x0024; m_au = m_au + 2; // alu r=0 c=1 m=..... i=....... ALU.and_ a=R.pch:m_pc d=-1 @@ -1358,8 +1358,8 @@ void m68000_device::state_illegal_ip() m_inst_substate = 0; return; } - m_da[16] = m_au; debugger_exception_hook(0x04); + m_da[16] = m_au; m_ftu = 0x0010; m_au = m_au + 2; // alu r=0 c=1 m=..... i=....... ALU.and_ a=R.pch:m_pc d=-1 @@ -1776,8 +1776,8 @@ void m68000_device::state_linea_ip() m_inst_substate = 0; return; } - m_da[16] = m_au; debugger_exception_hook(0x0a); + m_da[16] = m_au; m_ftu = 0x0028; m_au = m_au + 2; // alu r=0 c=1 m=..... i=....... ALU.and_ a=R.pch:m_pc d=-1 @@ -1985,8 +1985,8 @@ void m68000_device::state_linef_ip() m_inst_substate = 0; return; } - m_da[16] = m_au; debugger_exception_hook(0x0b); + m_da[16] = m_au; m_ftu = 0x002c; m_au = m_au + 2; // alu r=0 c=1 m=..... i=....... ALU.and_ a=R.pch:m_pc d=-1 @@ -106990,8 +106990,8 @@ void m68000_device::trap_imm4_ip() // 4e40 fff0 m_inst_substate = 0; return; } - m_da[16] = m_au; debugger_exception_hook((0x80 | ((m_ird & 0xf) << 2)) >> 2); + m_da[16] = m_au; m_ftu = 0x80 | ((m_ird & 0xf) << 2); m_au = m_au + 2; // alu r=0 c=1 m=..... i=....... ALU.and_ a=R.pch:m_pc d=-1 diff --git a/src/devices/cpu/m68000/m68000gen.py b/src/devices/cpu/m68000/m68000gen.py index 15d42c5fbcd..07108ab7b89 100755 --- a/src/devices/cpu/m68000/m68000gen.py +++ b/src/devices/cpu/m68000/m68000gen.py @@ -1471,7 +1471,13 @@ def generate_base_code_for_microcode(ir, irmask, madr, tvn, group01): if drop_critical: code.append(["drop_critical"]) - + + if tvn_to_ftu: + if tvn != None: + code.append(["trap", tvn]) + else: + code.append(["trap", macro_tvn]) + dbl_to_pcl = dbl_to_reg and pcl_dbl dbh_to_pch = dbh_to_reg and pch_dbh abl_to_pcl = abl_to_reg and pcl_abl @@ -1602,16 +1608,14 @@ def generate_base_code_for_microcode(ir, irmask, madr, tvn, group01): code_to_sort.append(["=sri"]) else: code_to_sort.append(["=sri7"]) - + if tvn_to_ftu: if tvn != None: - code_to_sort.append(["trap", tvn]) if type(tvn) == str: code_to_sort.append(["=", R.ftu, tvn]) else: code_to_sort.append(["=", R.ftu, "c", tvn << 2]) else: - code_to_sort.append(["trap", macro_tvn]) if type(macro_tvn) == str: code_to_sort.append(["=", R.ftu, macro_tvn]) else: -- cgit v1.2.3