From 71e745b0c87453629b63654011502be8b722df73 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Sun, 6 Mar 2016 06:27:15 -0800 Subject: [PATCH] PDP11: Fixed bug in history virtual addressing (Bob Supnik) The problem has to do with the difference in how the PSW is stored when the simulator is running (it's all in pieces) or stopped (it's collected in PSW). cpu_ex is a console routine and expects the PSW to be stored in PSW, but when history is collected, it's not. In particular, cm (current mode) is in local variable cm. cpu_ex with /v calls relocC, which derives the current mode from the switches: - if /ksup, use kernel/supervisor/user/previous mode (from PSW); otherwise, use current mode from PSW - if /d, use data space; otherwise, use instruction space relocC is doing current mode i-space, which is what's wanted... except that it's deriving current mode from PSW, rather than cm, which is where it's stored while the simulator is running. It's fairly likely that PSW is long obsolete by the time the history is invoked. --- PDP11/pdp11_cpu.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/PDP11/pdp11_cpu.c b/PDP11/pdp11_cpu.c index 3185edfd..356f2ff4 100644 --- a/PDP11/pdp11_cpu.c +++ b/PDP11/pdp11_cpu.c @@ -1,6 +1,6 @@ /* pdp11_cpu.c: PDP-11 CPU simulator - Copyright (c) 1993-2015, Robert M Supnik + Copyright (c) 1993-2016, Robert M Supnik Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -25,6 +25,7 @@ cpu PDP-11 CPU + 06-Mar-16 RMS Fixed bug in history virtual addressing 30-Dec-15 RMS Added NOBEVENT option for 11/03, 11/23 29-Dec-15 RMS Call build_dib_tab during reset (Mark Pizzolato) 05-Dec-13 RMS Fixed bug in CSM (John Dundas) @@ -876,13 +877,17 @@ while (reason == 0) { if (hst_lnt) { /* record history? */ t_value val; uint32 i; + static int32 swmap[4] = { + SWMASK ('K') | SWMASK ('V'), SWMASK ('S') | SWMASK ('V'), + SWMASK ('U') | SWMASK ('V'), SWMASK ('U') | SWMASK ('V') + }; hst[hst_p].pc = PC | HIST_VLD; hst[hst_p].psw = get_PSW (); hst[hst_p].src = R[srcspec & 07]; hst[hst_p].dst = R[dstspec & 07]; hst[hst_p].inst[0] = IR; for (i = 1; i < HIST_ILNT; i++) { - if (cpu_ex (&val, (PC + (i << 1)) & 0177777, &cpu_unit, SWMASK ('V'))) + if (cpu_ex (&val, (PC + (i << 1)) & 0177777, &cpu_unit, swmap[cm & 03])) hst[hst_p].inst[i] = 0; else hst[hst_p].inst[i] = (uint16) val; }