From 387ae9aa5320e07c562e1228e7e9c0ae2d64cf40 Mon Sep 17 00:00:00 2001 From: Richard Cornwell Date: Mon, 30 Jan 2017 20:45:10 -0500 Subject: [PATCH] KA10: Fixed single step. Added boot to Papertape. Fixed RIM Loader. --- PDP10/ka10_cpu.c | 14 ++++++++---- PDP10/ka10_pt.c | 57 ++++++++++++++++++++++++++++++++++++++++++------ PDP10/ka10_sys.c | 32 ++++++++++++++++++++++++--- 3 files changed, 89 insertions(+), 14 deletions(-) diff --git a/PDP10/ka10_cpu.c b/PDP10/ka10_cpu.c index 856f918..c996d70 100644 --- a/PDP10/ka10_cpu.c +++ b/PDP10/ka10_cpu.c @@ -1341,8 +1341,14 @@ int sac_inh; /* Inihibit saving AC after instruction */ int f; /* Temporary variables */ int flag1; int flag3; +int instr_count = 0; /* Number of instructions to execute */ uint32 IA; +if (sim_step != 0) { + instr_count = sim_step; + sim_cancel_step(); +} + /* Build device table */ if ((reason = build_dev_tab ()) != SCPE_OK) /* build, chk dib_tab */ return reason; @@ -1365,8 +1371,7 @@ if ((reason = build_dev_tab ()) != SCPE_OK) /* build, chk dib_tab */ while ( reason == 0) { /* loop until ABORT */ if (sim_interval <= 0) { /* check clock queue */ if ((reason = sim_process_event()) != SCPE_OK) {/* error? stop sim */ - if (reason != SCPE_STEP || !BYF5) - return reason; + return reason; } } @@ -1450,8 +1455,7 @@ no_fetch: /* Handle events during a indirect loop */ if (sim_interval-- <= 0) { if ((reason = sim_process_event()) != SCPE_OK) { - if (reason != SCPE_STEP || !BYF5) - return reason; + return reason; } } } while (ind & !pi_rq); @@ -3806,6 +3810,8 @@ last: pi_restore = 0; } sim_interval--; + if (!pi_cycle && instr_count != 0 && --instr_count == 0) + return SCPE_STEP; } /* Should never get here */ diff --git a/PDP10/ka10_pt.c b/PDP10/ka10_pt.c index 34a7b19..1c9fe77 100644 --- a/PDP10/ka10_pt.c +++ b/PDP10/ka10_pt.c @@ -57,6 +57,7 @@ const char *ptp_description (DEVICE *dptr); t_stat ptr_devio(uint32 dev, uint64 *data); t_stat ptr_svc (UNIT *uptr); +t_stat ptr_boot(int32 unit_num, DEVICE * dptr); t_stat ptr_reset (DEVICE *dptr); t_stat ptr_attach (UNIT *uptr, CONST char *cptr); t_stat ptr_detach (UNIT *uptr); @@ -84,8 +85,7 @@ MTAB ptp_mod[] = { DEVICE ptp_dev = { "PTP", &ptp_unit, ptp_reg, ptp_mod, 1, 10, 31, 1, 8, 8, - NULL, NULL, &ptp_reset, - NULL, &ptp_attach, &ptp_detach, + NULL, NULL, &ptp_reset, NULL, &ptp_attach, &ptp_detach, &ptp_dib, DEV_DISABLE | DEV_DEBUG, 0, dev_debug, NULL, NULL, &ptp_help, NULL, NULL, &ptp_description }; @@ -109,8 +109,7 @@ MTAB ptr_mod[] = { DEVICE ptr_dev = { "PTR", &ptr_unit, ptr_reg, ptr_mod, 1, 10, 31, 1, 8, 8, - NULL, NULL, &ptr_reset, - NULL, &ptr_attach, &ptr_detach, + NULL, NULL, &ptr_reset, &ptr_boot, &ptr_attach, &ptr_detach, &ptr_dib, DEV_DISABLE | DEV_DEBUG, 0, dev_debug, NULL, NULL, &ptr_help, NULL, NULL, &ptr_description }; @@ -267,12 +266,12 @@ t_stat ptr_svc (UNIT *uptr) uptr->STATUS |= DONE_FLG; set_interrupt(PR_DEVNUM, uptr->STATUS); - if ((ptr_unit.flags & UNIT_ATT) == 0) /* attached? */ + if ((uptr->flags & UNIT_ATT) == 0) /* attached? */ return SCPE_UNATT; word = 0; while (count > 0) { - if ((temp = getc (ptr_unit.fileref)) == EOF) { - if (feof (ptr_unit.fileref)) { + if ((temp = getc (uptr->fileref)) == EOF) { + if (feof (uptr->fileref)) { uptr->STATUS &= ~TAPE_PR; break; } @@ -293,6 +292,50 @@ t_stat ptr_svc (UNIT *uptr) return SCPE_OK; } +uint64 +ptr_read_word(UNIT *uptr) { + int i, ch; + uint64 word; + + for(i = 0; i <= 6;) { + if ((ch = getc (uptr->fileref)) == EOF) { + if (ch & 0200) { + word <<= 6; + word |= (uint64)(ch & 077); + i++; + } + } + } + return word; +} + +/* Boot from given device */ +t_stat +ptr_boot(int32 unit_num, DEVICE * dptr) +{ + UNIT *uptr = &dptr->units[unit_num]; + uint64 word; + int wc, addr; + + if ((uptr->flags & UNIT_ATT) == 0) + return SCPE_UNATT; /* attached? */ + + word = ptr_read_word(uptr); + wc = (word >> 18) & RMASK; + addr = word & RMASK; + while (wc != 0) { + wc = (wc + 1) & RMASK; + addr = (addr + 1) & RMASK; + word = ptr_read_word(uptr); + if (addr < 020) + FM[addr] = word; + else + M[addr] = word; + } + PC = addr; + return SCPE_OK; +} + /* Reset routine */ diff --git a/PDP10/ka10_sys.c b/PDP10/ka10_sys.c index 09b21b7..1e47bd2 100644 --- a/PDP10/ka10_sys.c +++ b/PDP10/ka10_sys.c @@ -198,9 +198,26 @@ return word; #define AOB(x) FMASK & ((x) + 01000001LL) t_stat load_rim (FILE *fileref) { -uint64 count, cksm, data; -uint32 pa; -int32 op; +uint64 count, cksm, data; +t_bool its_rim; +uint32 pa; +int32 op, i, ldrc; + +data = getrimw (fileref); /* get first word */ +if ((data < 0) || ((data & AMASK) != 0)) /* error? SA != 0? */ + return SCPE_FMT; +ldrc = -((int32) ((data >> 18) & RMASK)); /* get loader count */ +if (ldrc == 016) /* 16? RIM10B */ + its_rim = FALSE; +else if (ldrc == 017) /* 17? ITS RIM */ + its_rim = TRUE; +else SCPE_FMT; /* unknown */ + +for (i = 0; i < ldrc; i++) { /* skip the loader */ + data = getrimw (fileref); + if (data < 0) + return SCPE_FMT; + } for ( ;; ) { /* loop until JRST */ count = cksm = getrimw (fileref); /* get header */ @@ -211,6 +228,15 @@ for ( ;; ) { /* loop until JRST */ data = getrimw (fileref); /* get data wd */ if (data == RIM_EOF) return SCPE_FMT; + if (its_rim) { /* ITS RIM? */ + cksm = (((cksm << 1) | (cksm >> 35)) + data) & FMASK; + /* add to rotated cksm */ + pa = ((uint32) count) & RMASK; /* store */ + } + else { /* RIM10B */ + cksm = (cksm + data) & FMASK; /* add to cksm */ + pa = ((uint32) count + 1) & RMASK; /* store */ + } cksm = cksm + data; /* add to cksm */ pa = ((uint32) count + 1) & RMASK; /* store */ M[pa] = data;