From d21a3447576fbe8fc121daccd71ebb296c621607 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Mon, 30 Nov 2020 13:04:15 -0800 Subject: [PATCH] SCP: Fix RUN command to reliably allow PC to be specified Previously, the RUN command would gather and set the desired PC start address, but then it would invoke the reset logic for all DEVICEs. The CPU DEVICE's reset routine might reasonably initialize the PC to a known state which would the overwrite the PC specified on the RUN command. This change performs the reset before setting the PC to the specified value (or it's previous value if no PC was supplied on the RUN command). --- scp.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scp.c b/scp.c index 8a061fb2..2aca151b 100644 --- a/scp.c +++ b/scp.c @@ -8591,7 +8591,7 @@ CONST char *tptr; uint32 i, j; int32 sim_next = 0; int32 unitno; -t_value pcv, orig_pcv; +t_value new_pcv, orig_pcv; t_stat r; DEVICE *dptr; UNIT *uptr; @@ -8604,17 +8604,17 @@ if (sim_runlimit_enabled && /* If the run limit has GET_SWITCHES (cptr); /* get switches */ sim_step = 0; if ((flag == RU_RUN) || (flag == RU_GO)) { /* run or go */ - orig_pcv = get_rval (sim_PC, 0); /* get current PC value */ + new_pcv = orig_pcv = get_rval (sim_PC, 0); /* get current PC value */ if (*cptr != 0) { /* argument? */ cptr = get_glyph (cptr, gbuf, 0); /* get next glyph */ if (MATCH_CMD (gbuf, "UNTIL") != 0) { if (sim_vm_parse_addr) /* address parser? */ - pcv = sim_vm_parse_addr (sim_dflt_dev, gbuf, &tptr); - else pcv = strtotv (gbuf, &tptr, sim_PC->radix);/* parse PC */ + new_pcv = sim_vm_parse_addr (sim_dflt_dev, gbuf, &tptr); + else + new_pcv = strtotv (gbuf, &tptr, sim_PC->radix);/* parse PC */ if ((tptr == gbuf) || (*tptr != 0) || /* error? */ - (pcv > width_mask[sim_PC->width])) + (new_pcv > width_mask[sim_PC->width])) return SCPE_ARG; - put_rval (sim_PC, 0, pcv); /* Save in PC */ } } if ((flag == RU_RUN) && /* run? */ @@ -8649,6 +8649,7 @@ if ((flag == RU_RUN) || (flag == RU_GO)) { /* run or go */ } sim_switches = saved_switches; } + put_rval (sim_PC, 0, new_pcv); /* Save in PC */ } else if ((flag == RU_STEP) ||