PDP8: Fix Boot doesn't work if IB or saved_DF are previously set wrong (#72). From Bob Supnik

All bootstraps now pass this test case:

d pc 77777
boot <device>
This commit is contained in:
Mark Pizzolato 2013-09-18 11:11:10 -07:00
parent 735c589d07
commit 6d8565dc94
11 changed files with 63 additions and 43 deletions

View file

@ -1,6 +1,6 @@
/* pdp8_cpu.c: PDP-8 CPU simulator
Copyright (c) 1993-2011, Robert M Supnik
Copyright (c) 1993-2013, 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 central processor
17-Sep-13 RMS Fixed boot in wrong field problem (Dave Gesswein)
28-Apr-07 RMS Removed clock initialization
30-Oct-06 RMS Added idle and infinite loop detection
30-Sep-06 RMS Fixed SC value after DVI overflow (Don North)
@ -323,7 +324,8 @@ t_stat reason;
/* Restore register state */
if (build_dev_tab ()) return SCPE_STOP; /* build dev_tab */
if (build_dev_tab ()) /* build dev_tab */
return SCPE_STOP;
PC = saved_PC & 007777; /* load local copies */
IF = saved_PC & 070000;
DF = saved_DF & 070000;
@ -1366,6 +1368,15 @@ sim_brk_types = sim_brk_dflt = SWMASK ('E');
return SCPE_OK;
}
/* Set PC for boot (PC<14:12> will typically be 0) */
void cpu_set_bootpc (int32 pc)
{
saved_PC = pc; /* set PC, IF */
saved_DF = IB = pc & 070000; /* set IB, DF */
return;
}
/* Memory examine */
t_stat cpu_ex (t_value *vptr, t_addr addr, UNIT *uptr, int32 sw)

View file

@ -1,6 +1,6 @@
/* pdp8_ct.c: PDP-8 cassette tape simulator
Copyright (c) 2006-2011, Robert M Supnik
Copyright (c) 2006-2013, 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,9 +25,10 @@
ct TA8E/TU60 cassette tape
17-Sep-07 RMS Changed to use central set_bootpc routine
13-Aug-07 RMS Fixed handling of BEOT
06-Aug-07 RMS Foward op at BOT skips initial file gap
30-May-2007 RMS Fixed typo (Norm Lastovica)
30-May-07 RMS Fixed typo (Norm Lastovica)
Magnetic tapes are represented as a series of variable records
of the form:
@ -718,13 +719,12 @@ static const uint16 boot_rom[] = {
t_stat ct_boot (int32 unitno, DEVICE *dptr)
{
size_t i;
extern int32 saved_PC;
extern uint16 M[];
if ((ct_dib.dev != DEV_CT) || unitno) /* only std devno */
return STOP_NOTSTD;
for (i = 0; i < BOOT_LEN; i++)
M[BOOT_START + i] = boot_rom[i];
saved_PC = BOOT_START;
cpu_set_bootpc (BOOT_START);
return SCPE_OK;
}

View file

@ -1,6 +1,6 @@
/* pdp8_defs.h: PDP-8 simulator definitions
Copyright (c) 1993-2012, Robert M Supnik
Copyright (c) 1993-2013, 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,8 +23,9 @@
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from Robert M Supnik.
18-Sep-13 RMS Added set_bootpc prototype
18-Apr-12 RMS Removed separate timer for additional terminals;
added clock_cosched prototype
Added clock_cosched prototype
22-May-10 RMS Added check for 64b definitions
21-Aug-07 RMS Added FPP8 support
13-Dec-06 RMS Added TA8E support
@ -210,4 +211,6 @@ typedef struct {
t_stat set_dev (UNIT *uptr, int32 val, char *cptr, void *desc);
t_stat show_dev (FILE *st, UNIT *uptr, int32 val, void *desc);
void cpu_set_bootpc (int32 pc);
#endif

View file

@ -1,6 +1,6 @@
/* pdp8_df.c: DF32 fixed head disk simulator
Copyright (c) 1993-2011, Robert M Supnik
Copyright (c) 1993-2013, 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 @@
df DF32 fixed head disk
17-Sep-13 RMS Changed to use central set_bootpc routine
03-Sep-13 RMS Added explicit void * cast
15-May-06 RMS Fixed bug in autosize attach (Dave Gesswein)
07-Jan-06 RMS Fixed unaligned register access bug (Doug Carman)
04-Jan-04 RMS Changed sim_fsize calling sequence
@ -249,7 +251,7 @@ t_stat df_svc (UNIT *uptr)
{
int32 pa, t, mex;
uint32 da;
int16 *fbuf = uptr->filebuf;
int16 *fbuf = (int16 *) uptr->filebuf;
UPDATE_PCELL; /* update photocell */
if ((uptr->flags & UNIT_BUF) == 0) { /* not buf? abort */
@ -335,17 +337,16 @@ static const uint16 dm4_rom[] = {
t_stat df_boot (int32 unitno, DEVICE *dptr)
{
size_t i;
extern int32 saved_PC;
if (sim_switches & SWMASK ('D')) {
for (i = 0; i < DM4_LEN; i = i + 2)
M[dm4_rom[i]] = dm4_rom[i + 1];
saved_PC = DM4_START;
cpu_set_bootpc (DM4_START);
}
else {
for (i = 0; i < OS8_LEN; i++)
M[OS8_START + i] = os8_rom[i];
saved_PC = OS8_START;
cpu_set_bootpc (OS8_START);
}
return SCPE_OK;
}

View file

@ -1,6 +1,6 @@
/* pdp8_dt.c: PDP-8 DECtape simulator
Copyright (c) 1993-2011, Robert M Supnik
Copyright (c) 1993-2013, 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,7 +25,8 @@
dt TC08/TU56 DECtape
23-Jun-06 RMS Fixed switch conflict in ATTACH
17-Sep-13 RMS Changed to use central set_bootpc routine
23-Jun-06 RMS Fixed switch conflict in ATTACH
07-Jan-06 RMS Fixed unaligned register access bug (Doug Carman)
16-Aug-05 RMS Fixed C++ declaration and cast problems
25-Jan-04 RMS Revised for device debug support
@ -380,7 +381,8 @@ int32 pulse = IR & 07;
int32 old_dtsa = dtsa, fnc;
UNIT *uptr;
if (pulse & 01) AC = AC | dtsa; /* DTRA */
if (pulse & 01) /* DTRA */
AC = AC | dtsa;
if (pulse & 06) { /* select */
if (pulse & 02) /* DTCA */
dtsa = 0;
@ -1011,7 +1013,8 @@ return SCPE_OK;
int32 dt_gethdr (UNIT *uptr, int32 blk, int32 relpos, int32 dir)
{
if (relpos >= DT_HTLIN) relpos = relpos - (DT_WSIZE * DTU_BSIZE (uptr));
if (relpos >= DT_HTLIN)
relpos = relpos - (DT_WSIZE * DTU_BSIZE (uptr));
if (dir) { /* reverse */
switch (relpos / DT_WSIZE) {
case 6: /* rev csm */
@ -1176,7 +1179,6 @@ static const uint16 boot_rom[] = {
t_stat dt_boot (int32 unitno, DEVICE *dptr)
{
size_t i;
extern int32 saved_PC;
if (unitno) /* only unit 0 */
return SCPE_ARG;
@ -1185,7 +1187,7 @@ if (dt_dib.dev != DEV_DTA) /* only std devno */
dt_unit[unitno].pos = DT_EZLIN;
for (i = 0; i < BOOT_LEN; i++)
M[BOOT_START + i] = boot_rom[i];
saved_PC = BOOT_START;
cpu_set_bootpc (BOOT_START);
return SCPE_OK;
}

View file

@ -1,6 +1,6 @@
/* pdp8_pt.c: PDP-8 paper tape reader/punch simulator
Copyright (c) 1993-2011, Robert M Supnik
Copyright (c) 1993-2013, 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 @@
ptr,ptp PC8E paper tape reader/punch
17-Mar-13 RMS Modified to use central set_bootpc routine
25-Apr-03 RMS Revised for extended file support
04-Oct-02 RMS Added DIBs
30-May-02 RMS Widened POS to 32b
@ -279,13 +280,12 @@ static const uint16 boot_rom[] = {
t_stat ptr_boot (int32 unitno, DEVICE *dptr)
{
size_t i;
extern int32 saved_PC;
extern uint16 M[];
if (ptr_dib.dev != DEV_PTR) /* only std devno */
return STOP_NOTSTD;
for (i = 0; i < BOOT_LEN; i++)
M[BOOT_START + i] = boot_rom[i];
saved_PC = BOOT_START;
cpu_set_bootpc (BOOT_START);
return SCPE_OK;
}

View file

@ -1,6 +1,6 @@
/* pdp8_rf.c: RF08 fixed head disk simulator
Copyright (c) 1993-2011, Robert M Supnik
Copyright (c) 1993-2013, 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 @@
rf RF08 fixed head disk
17-Sep-13 RMS Changed to use central set_bootpc routine
03-Sep-13 RMS Added explicit void * cast
15-May-06 RMS Fixed bug in autosize attach (Dave Gesswein)
07-Jan-06 RMS Fixed unaligned register access bug (Doug Carman)
04-Jan-04 RMS Changed sim_fsize calling sequence
@ -302,7 +304,7 @@ return AC;
t_stat rf_svc (UNIT *uptr)
{
int32 pa, t, mex;
int16 *fbuf = uptr->filebuf;
int16 *fbuf = (int16 *) uptr->filebuf;
UPDATE_PCELL; /* update photocell */
if ((uptr->flags & UNIT_BUF) == 0) { /* not buf? abort */
@ -399,19 +401,18 @@ static const uint16 dm4_rom[] = {
t_stat rf_boot (int32 unitno, DEVICE *dptr)
{
size_t i;
extern int32 saved_PC;
if (rf_dib.dev != DEV_RF) /* only std devno */
return STOP_NOTSTD;
if (sim_switches & SWMASK ('D')) {
for (i = 0; i < DM4_LEN; i = i + 2)
M[dm4_rom[i]] = dm4_rom[i + 1];
saved_PC = DM4_START;
cpu_set_bootpc (DM4_START);
}
else {
for (i = 0; i < OS8_LEN; i++)
M[OS8_START + i] = os8_rom[i];
saved_PC = OS8_START;
cpu_set_bootpc (OS8_START);
}
return SCPE_OK;
}

View file

@ -1,6 +1,6 @@
/* pdp8_rk.c: RK8E cartridge disk simulator
Copyright (c) 1993-2011, Robert M Supnik
Copyright (c) 1993-2013, 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 @@
rk RK8E/RK05 cartridge disk
17-Sep-13 RMS Changed to use central set_bootpc routine
18-Mar-13 RMS Raised RK_MIN so that RKLFMT will work (Mark Pizzolato)
25-Apr-03 RMS Revised for extended file support
04-Oct-02 RMS Added DIB, device number support
06-Jan-02 RMS Changed enable/disable support
@ -121,7 +123,7 @@
((rk_cmd & RKC_IE) != 0)) \
int_req = int_req | INT_RK; \
else int_req = int_req & ~INT_RK
#define RK_MIN 45
#define RK_MIN 50
#define MAX(x,y) (((x) > (y))? (x): (y))
extern uint16 M[];
@ -451,13 +453,12 @@ static const uint16 boot_rom[] = {
t_stat rk_boot (int32 unitno, DEVICE *dptr)
{
size_t i;
extern int32 saved_PC;
if (rk_dib.dev != DEV_RK) /* only std devno */
return STOP_NOTSTD;
for (i = 0; i < BOOT_LEN; i++)
M[BOOT_START + i] = boot_rom[i];
M[BOOT_UNIT] = (unitno & RK_M_NUMDR) << 1;
saved_PC = BOOT_START;
cpu_set_bootpc (BOOT_START);
return SCPE_OK;
}

View file

@ -1,6 +1,6 @@
/* pdp8_rl.c: RL8A cartridge disk simulator
Copyright (c) 1993-2011, Robert M Supnik
Copyright (c) 1993-2013, 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 @@
rl RL8A cartridge disk
17-Sep-13 RMS Changed to use central set_bootpc routine
25-Oct-05 RMS Fixed IOT 61 decode bug (David Gesswein)
16-Aug-05 RMS Fixed C++ declaration and cast problems
04-Jan-04 RMS Changed attach routine to use sim_fsize
@ -690,7 +691,6 @@ static const uint16 boot_rom[] = {
t_stat rl_boot (int32 unitno, DEVICE *dptr)
{
size_t i;
extern int32 saved_PC;
if (unitno) /* only unit 0 */
return SCPE_ARG;
@ -699,6 +699,6 @@ if (rl_dib.dev != DEV_RL) /* only std devno */
rl_unit[unitno].TRK = 0;
for (i = 0; i < BOOT_LEN; i++)
M[BOOT_START + i] = boot_rom[i];
saved_PC = BOOT_START;
cpu_set_bootpc (BOOT_START);
return SCPE_OK;
}

View file

@ -25,6 +25,7 @@
rx RX8E/RX01, RX28/RX02 floppy disk
17-Sep-13 RMS Changed to use central set_bootpc routine
03-Sep-13 RMS Added explicit void * cast
15-May-06 RMS Fixed bug in autosize attach (Dave Gesswein)
04-Jan-04 RMS Changed sim_fsize calling sequence
@ -735,7 +736,6 @@ static const uint16 boot2_rom[] = {
t_stat rx_boot (int32 unitno, DEVICE *dptr)
{
size_t i;
extern int32 saved_PC;
extern uint16 M[];
if (rx_dib.dev != DEV_RX) /* only std devno */
@ -743,13 +743,13 @@ if (rx_dib.dev != DEV_RX) /* only std devno */
if (rx_28) {
for (i = 0; i < BOOT2_LEN; i++)
M[BOOT2_START + i] = boot2_rom[i];
saved_PC = BOOT2_ENTRY;
cpu_set_bootpc (BOOT2_ENTRY);
}
else {
for (i = 0; i < BOOT_LEN; i++)
M[BOOT_START + i] = boot_rom[i];
M[BOOT_INST] = unitno? 07024: 07004;
saved_PC = BOOT_ENTRY;
cpu_set_bootpc (BOOT_ENTRY);
}
return SCPE_OK;
}

View file

@ -1,6 +1,6 @@
/* pdp8_td.c: PDP-8 simple DECtape controller (TD8E) simulator
Copyright (c) 1993-2011, Robert M Supnik
Copyright (c) 1993-2013, 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,8 +28,9 @@
td TD8E/TU56 DECtape
17-Sep-13 RMS Changed to use central set_bootpc routine
23-Mar-11 RMS Fixed SDLC to clear AC (from Dave Gesswein)
23-Jun-06 RMS Fixed switch conflict in ATTACH
23-Jun-06 RMS Fixed switch conflict in ATTACH
16-Aug-05 RMS Fixed C++ declaration and cast problems
09-Jan-04 RMS Changed sim_fsize calling sequence, added STOP_OFFR
@ -100,7 +101,7 @@
/* 16b, 18b, 36b DECtape constants */
#define D18_WSIZE 6 /* word sizein lines */
#define D18_WSIZE 6 /* word size in lines */
#define D18_BSIZE 384 /* block size in 12b */
#define D18_TSIZE 578 /* tape size */
#define D18_LPERB (DT_HTLIN + (D18_BSIZE * DT_WSIZE) + DT_HTLIN)
@ -741,7 +742,6 @@ static const uint16 boot_rom[] = {
t_stat td_boot (int32 unitno, DEVICE *dptr)
{
size_t i;
extern int32 saved_PC;
if (unitno)
return SCPE_ARG; /* only unit 0 */
@ -750,7 +750,7 @@ if (td_dib.dev != DEV_TD8E)
td_unit[unitno].pos = DT_EZLIN;
for (i = 0; i < BOOT_LEN; i++)
M[BOOT_START + i] = boot_rom[i];
saved_PC = BOOT_START;
cpu_set_bootpc (BOOT_START);
return SCPE_OK;
}
@ -910,7 +910,8 @@ int32 td_set_mtk (int32 code, int32 u, int32 k)
{
int32 i;
for (i = 5; i >= 0; i--) tdb_mtk[u][k++] = (code >> i) & 1;
for (i = 5; i >= 0; i--)
tdb_mtk[u][k++] = (code >> i) & 1;
return k;
}