From dadb00eb1975d890f63ede17d5108d87426e7ba8 Mon Sep 17 00:00:00 2001 From: Ken Rector Date: Tue, 8 Jun 2021 01:55:07 -0700 Subject: [PATCH] SDS: Added C register implementation for various devices --- SDS/sds_cpu.c | 38 +++++++++++++++++++++++++++----------- SDS/sds_cr.c | 9 +++++---- SDS/sds_mt.c | 6 ++++-- SDS/sds_rad.c | 7 +++++-- SDS/sds_stddev.c | 6 ++++-- SDS/sds_sys.c | 8 +++++--- 6 files changed, 50 insertions(+), 24 deletions(-) diff --git a/SDS/sds_cpu.c b/SDS/sds_cpu.c index d942e27c..d77cdbad 100644 --- a/SDS/sds_cpu.c +++ b/SDS/sds_cpu.c @@ -1,6 +1,6 @@ /* sds_cpu.c: SDS 940 CPU simulator - Copyright (c) 2001-2017, Robert M. Supnik + Copyright (c) 2001-2021, 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"), @@ -26,6 +26,7 @@ cpu central processor rtc real time clock + 17-Feb-21 kenr Added C register implementation to support console 07-Sep-17 RMS Fixed sim_eval declaration in history routine (COVERITY) 09-Mar-17 RMS trap_P not set if mem mgt trap during fetch (COVERITY) 28-Apr-07 RMS Removed clock initialization @@ -38,6 +39,7 @@ A<0:23> A register B<0:23> B register + C<0:23> C register X<0:23> X (index) register OV overflow indicator P<0:13> program counter @@ -152,7 +154,7 @@ typedef struct { uint32 typ; uint32 pc; - uint32 ir; + uint32 c; uint32 a; uint32 b; uint32 x; @@ -160,7 +162,7 @@ typedef struct { } InstHistory; uint32 M[MAXMEMSIZE] = { 0 }; /* memory */ -uint32 A, B, X; /* registers */ +uint32 A, B, C, X; /* registers */ uint32 P; /* program counter */ uint32 OV; /* overflow */ uint32 xfr_req = 0; /* xfr req */ @@ -248,6 +250,7 @@ REG cpu_reg[] = { { ORDATA (P, P, 14) }, { ORDATA (A, A, 24) }, { ORDATA (B, B, 24) }, + { ORDATA (C, C, 24) }, { ORDATA (X, X, 24) }, { FLDATA (OV, OV, 0) }, { ORDATA (EM2, EM2, 3) }, @@ -411,6 +414,7 @@ while (reason == 0) { /* loop until halted */ inst_hist (tinst, P, HIST_INT); if (pa != VEC_RTCP) { /* normal intr? */ tr = one_inst (tinst, P, save_mode, &tmp); /* exec intr inst */ + Read (P, &C); if (tr) { /* stop code? */ cpu_mode = save_mode; /* restore mode */ reason = (tr > 0)? tr: STOP_MMINT; @@ -464,11 +468,14 @@ while (reason == 0) { /* loop until halted */ if (reason == SCPE_OK) { /* fetch ok? */ ion_defer = 0; /* clear ion */ if (hst_lnt) - inst_hist (inst, save_P, HIST_XCT); - reason = one_inst (inst, save_P, cpu_mode, &trap_P); /* exec inst */ + inst_hist (C, save_P, HIST_XCT); + reason = one_inst (C, save_P, cpu_mode, &trap_P); /* exec inst */ + Read (P, &C); if (reason > 0) { /* stop code? */ - if (reason != STOP_HALT) + if (reason != STOP_HALT) { P = save_P; + Read (P, &C); + } if (reason == STOP_IONRDY) reason = 0; } @@ -496,6 +503,7 @@ while (reason == 0) { /* loop until halted */ */ tr = one_inst (tinst, (reason == MM_NOACC)? trap_P: save_P, save_mode, &tmp); /* trap address */ + Read (P, &C); if (tr) { /* stop code? */ cpu_mode = save_mode; /* restore mode */ P = save_P; /* restore PC */ @@ -1511,6 +1519,13 @@ int_reqhi = api_findreq (); /* recalc intreq */ return; } +/* Post command routine */ + +void cpu_post_cmd (t_bool from_scp) +{ + C = M[P]; +} + /* Reset routine */ t_stat cpu_reset (DEVICE *dptr) @@ -1534,6 +1549,7 @@ else return SCPE_IERR; sim_brk_dflt = SWMASK ('E'); sim_brk_types = SWMASK ('E') | SWMASK ('M') | SWMASK ('N') | SWMASK ('U'); sim_vm_is_subroutine_call = cpu_is_pc_a_subroutine_call; +sim_vm_post = cpu_post_cmd; return SCPE_OK; } @@ -1803,7 +1819,7 @@ return SCPE_OK; /* Record history */ -void inst_hist (uint32 ir, uint32 pc, uint32 tp) +void inst_hist (uint32 c, uint32 pc, uint32 tp) { if (cpu_mode == hst_exclude) return; @@ -1812,7 +1828,7 @@ if (hst_p >= hst_lnt) hst_p = 0; hst[hst_p].typ = tp | (OV << 4) | (cpu_mode << 5); hst[hst_p].pc = pc; -hst[hst_p].ir = ir; +hst[hst_p].c = c; hst[hst_p].a = A; hst[hst_p].b = B; hst[hst_p].x = X; @@ -1881,7 +1897,7 @@ else lnt = hst_lnt; di = hst_p - lnt; /* work forward */ if (di < 0) di = di + hst_lnt; -fprintf (st, "CYC PC MD OV A B X EA IR\n\n"); +fprintf (st, "CYC PC MD OV A B X EA C\n\n"); for (k = 0; k < lnt; k++) { /* print specified */ h = &hst[(++di) % hst_lnt]; /* entry pointer */ if (h->typ) { /* instruction? */ @@ -1891,9 +1907,9 @@ for (k = 0; k < lnt; k++) { /* print specified */ if (h->ea & HIST_NOEA) fprintf (st, " "); else fprintf (st, "%05o ", h->ea); - sim_eval[0] = h->ir; + sim_eval[0] = h->c; if ((fprint_sym (st, h->pc, sim_eval, &cpu_unit, SWMASK ('M'))) > 0) - fprintf (st, "(undefined) %08o", h->ir); + fprintf (st, "(undefined) %08o", h->c); fputc ('\n', st); /* end line */ } /* end else instruction */ } /* end for */ diff --git a/SDS/sds_cr.c b/SDS/sds_cr.c index 06ea3483..20206a8a 100644 --- a/SDS/sds_cr.c +++ b/SDS/sds_cr.c @@ -1,6 +1,6 @@ /* sds_cr.c: SDS-930 card reader simulator - Copyright (c) 2020, Ken Rector + Copyright (c) 2020-2021, Ken Rector Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -23,8 +23,8 @@ used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from Ken Rector. - 03-Mar-20 kenr Initial Version - + 17-Feb-21 kenr Initial Version + 17-Feb-21 kenr Added C register support to CDR boot */ /* @@ -353,7 +353,7 @@ t_stat cr_attach (UNIT *uptr, CONST char *cptr) { /* Boot routine - simulate FILL console command */ t_stat cr_boot (int32 unitno, DEVICE *dptr) { - extern uint32 P, M[]; + extern uint32 P, C, M[]; cr_reset(dptr); M[0] = 077777771; /* -7B */ @@ -362,6 +362,7 @@ t_stat cr_boot (int32 unitno, DEVICE *dptr) { M[3] = 003200002; /* WIM 2 */ M[4] = 000100002; /* BRU 2 */ P = 1; /* start at 1 */ + C = M[1]; return SCPE_OK; } diff --git a/SDS/sds_mt.c b/SDS/sds_mt.c index 6887323b..c00838a9 100644 --- a/SDS/sds_mt.c +++ b/SDS/sds_mt.c @@ -1,6 +1,6 @@ /* sds_mt.c: SDS 940 magnetic tape simulator - Copyright (c) 2001-2016, Robert M. Supnik + Copyright (c) 2001-2021, 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 @@ mt 7 track magnetic tape + 03-Mar-21 kenr Added C register support to MT boot 09-Oct-16 RMS Added precise gap erase 19-Mar-12 RMS Fixed bug in scan function decode (Peter Schorn) 16-Feb-06 RMS Added tape capacity checking @@ -499,7 +500,7 @@ return sim_tape_detach (uptr); t_stat mt_boot (int32 unitno, DEVICE *dptr) { -extern uint32 P, M[]; +extern uint32 P, C, M[]; if (unitno) /* only unit 0 */ return SCPE_ARG; @@ -509,5 +510,6 @@ M[2] = 000203610; /* EOM 3610B */ M[3] = 003200002; /* WIM 2 */ M[4] = 000100002; /* BRU 2 */ P = 1; /* start at 1 */ +C = M[1]; return SCPE_OK; } diff --git a/SDS/sds_rad.c b/SDS/sds_rad.c index b393ae44..6b1634e2 100644 --- a/SDS/sds_rad.c +++ b/SDS/sds_rad.c @@ -1,6 +1,6 @@ /* sds_rad.c: SDS 940 fixed head disk simulator - Copyright (c) 2001-2008, Robert M. Supnik + Copyright (c) 2001-2021, 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,8 @@ rad fixed head disk + 17-Feb-21 kenr Added C register support to RAD boot + The fixed head disk is a head-per-track disk, with up to four disks. Each disk is divided into two logical units. Reads and writes cannot cross logical unit boundaries. The fixed head disk transfers 12b characters, rather than 6b @@ -326,7 +328,7 @@ return SCPE_OK; t_stat rad_boot (int32 unitno, DEVICE *dptr) { -extern uint32 P, M[]; +extern uint32 P, C, M[]; if (unitno) /* only unit 0 */ return SCPE_ARG; @@ -338,5 +340,6 @@ M[2] = 000203226; /* EOM 3226B */ M[3] = 003200002; /* WIM 2 */ M[4] = 000100002; /* BRU 2 */ P = 1; /* start at 1 */ +C = M[1]; return SCPE_OK; } diff --git a/SDS/sds_stddev.c b/SDS/sds_stddev.c index 2d153dc8..6bf60912 100644 --- a/SDS/sds_stddev.c +++ b/SDS/sds_stddev.c @@ -1,6 +1,6 @@ /* sds_stddev.c: SDS 940 standard devices - Copyright (c) 2001-2020, Robert M. Supnik + Copyright (c) 2001-2021, 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"), @@ -28,6 +28,7 @@ tti keyboard tto teleprinter + 12-Feb-21 kenr Added C register support to PTR boot 23-Oct-20 RMS TTO recognizes no leader flag (Ken Rector) 29-Dec-03 RMS Added console backpressure support 25-Apr-03 RMS Revised for extended file support @@ -327,7 +328,7 @@ return SCPE_OK; t_stat ptr_boot (int32 unitno, DEVICE *dptr) { -extern uint32 P, M[]; +extern uint32 P, C, M[]; M[0] = 077777771; /* -7B */ M[1] = 007100000; /* LDX 0 */ @@ -335,6 +336,7 @@ M[2] = 000203604; /* EOM 3604B */ M[3] = 003200002; /* WIM 2 */ M[4] = 000100002; /* BRU 2 */ P = 1; /* start at 1 */ +C = M[1]; return SCPE_OK; } diff --git a/SDS/sds_sys.c b/SDS/sds_sys.c index 89288985..53a2b80b 100644 --- a/SDS/sds_sys.c +++ b/SDS/sds_sys.c @@ -1,6 +1,6 @@ /* sds_sys.c: SDS 940 simulator interface - Copyright (c) 2001-2020, Robert M Supnik + Copyright (c) 2001-2021, 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"), @@ -23,11 +23,12 @@ used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from Robert M Supnik. + 12-Feb-21 kenr Added C register support to loader 01-Nov-20 RMS Fixed sds930-to-ascii entry 060 (Ken Rector) 05-May-16 RMS Fixed ascii-to-sds940 data (Mark Pizzolato) 19-Mar-12 RMS Fixed declarations of CCT arrays (Mark Pizzolato) */ - + #include "sds_defs.h" #include #define FMTASC(x) ((x) < 040)? "<%03o>": "%c", (x) @@ -261,7 +262,7 @@ t_stat sim_load (FILE *fileref, CONST char *cptr, CONST char *fnam, int flag) { int32 i, wd, buf[8]; int32 ldr = 1; -extern uint32 P; +extern uint32 P, C; if ((*cptr != 0) || (flag != 0)) return SCPE_ARG; @@ -283,6 +284,7 @@ for (i = 0; i < 8; i++) /* copy boot */ M[i + 2] = buf[i]; if (I_GETOP (buf[6]) == BRU) P = buf[6] & VA_MASK; +C = M[P]; for (i = (buf[3]+buf[7]) & VA_MASK; i <= VA_MASK; i++) {/* load data */ if ((wd = get_word (fileref, &ldr)) < 0) return SCPE_OK;