SCP: Fixed bug in byte deposits if aincr > 1

The PDP11 and VAX have length switches - B, W, and (VAX) L - to
override the default parsing of numberic display or input as words
(PDP11) or longwords (VAX CPU) or bytes (VAX byte devices).
This worked fine if every value is filled in. On the PDP11:

sim> ideposit -b 0-3
0:    1
1:    2
2:    3
3:    4
sim>

But if the user skips an input, IDEPOSIT advances by 2, not 1:

sim> ideposit -b 0-3
0:    1
1:    (cr)
3:    4
sim>

This change now produces the correct behavior.

PDP-11 simulator V3.12-2
sim> id -b 0-3
0:      1
1:
2:      3
3:      4
sim>
This commit is contained in:
Bob Supnik 2022-06-17 08:23:29 -07:00 committed by Mark Pizzolato
parent 5543e137f8
commit cc6f8ee8ee

23
scp.c
View file

@ -1,6 +1,6 @@
/* scp.c: simulator control program /* scp.c: simulator control program
Copyright (c) 1993-2016, Robert M Supnik Copyright (c) 1993-2022, Robert M Supnik
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
@ -23,6 +23,7 @@
used in advertising or otherwise to promote the sale, use or other dealings used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from Robert M Supnik. in this Software without prior written authorization from Robert M Supnik.
21-Oct-21 RMS Fixed bug in byte deposits if aincr > 1
08-Mar-16 RMS Added shutdown flag for detach_all 08-Mar-16 RMS Added shutdown flag for detach_all
20-Mar-12 MP Fixes to "SHOW <x> SHOW" commands 20-Mar-12 MP Fixes to "SHOW <x> SHOW" commands
06-Jan-12 JDB Fixed "SHOW DEVICE" with only one enabled unit (Dave Bryan) 06-Jan-12 JDB Fixed "SHOW DEVICE" with only one enabled unit (Dave Bryan)
@ -550,7 +551,7 @@ t_stat ex_reg (FILE *ofile, t_value val, int32 flag, REG *rptr, uint32 idx);
t_stat dep_reg (int32 flag, CONST char *cptr, REG *rptr, uint32 idx); t_stat dep_reg (int32 flag, CONST char *cptr, REG *rptr, uint32 idx);
t_stat exdep_addr_loop (FILE *ofile, SCHTAB *schptr, int32 flag, const char *cptr, t_stat exdep_addr_loop (FILE *ofile, SCHTAB *schptr, int32 flag, const char *cptr,
t_addr low, t_addr high, DEVICE *dptr, UNIT *uptr); t_addr low, t_addr high, DEVICE *dptr, UNIT *uptr);
t_stat ex_addr (FILE *ofile, int32 flag, t_addr addr, DEVICE *dptr, UNIT *uptr); t_stat ex_addr (FILE *ofile, int32 flag, t_addr addr, DEVICE *dptr, UNIT *uptr, int32 dfltinc);
t_stat dep_addr (int32 flag, const char *cptr, t_addr addr, DEVICE *dptr, t_stat dep_addr (int32 flag, const char *cptr, t_addr addr, DEVICE *dptr,
UNIT *uptr, int32 dfltinc); UNIT *uptr, int32 dfltinc);
void fprint_fields (FILE *stream, t_value before, t_value after, BITFIELD* bitdefs); void fprint_fields (FILE *stream, t_value before, t_value after, BITFIELD* bitdefs);
@ -9731,7 +9732,7 @@ t_stat exdep_addr_loop (FILE *ofile, SCHTAB *schptr, int32 flag, const char *cpt
t_addr low, t_addr high, DEVICE *dptr, UNIT *uptr) t_addr low, t_addr high, DEVICE *dptr, UNIT *uptr)
{ {
t_addr i, mask; t_addr i, mask;
t_stat reason; t_stat reason, dfltinc;
int32 saved_switches = sim_switches; int32 saved_switches = sim_switches;
if (uptr->flags & UNIT_DIS) /* disabled? */ if (uptr->flags & UNIT_DIS) /* disabled? */
@ -9739,22 +9740,25 @@ if (uptr->flags & UNIT_DIS) /* disabled? */
mask = (t_addr) width_mask[dptr->awidth]; mask = (t_addr) width_mask[dptr->awidth];
if ((low > mask) || (high > mask) || (low > high)) if ((low > mask) || (high > mask) || (low > high))
return SCPE_ARG; return SCPE_ARG;
dfltinc = parse_sym ("0", 0, uptr, sim_eval, sim_switches);
if (dfltinc > 0) /* parse_sym doing nums? */
dfltinc = 1 - dptr->aincr; /* no, use std dflt incr */
for (i = low; i <= high; ) { /* all paths must incr!! */ for (i = low; i <= high; ) { /* all paths must incr!! */
reason = get_aval (i, dptr, uptr); /* get data */ reason = get_aval (i, dptr, uptr); /* get data */
sim_switches = saved_switches; sim_switches = saved_switches;
if (reason != SCPE_OK) /* return if error */ if (reason != SCPE_OK) /* return if error */
return reason; return reason;
if (schptr && !test_search (sim_eval, schptr)) if (schptr && !test_search (sim_eval, schptr))
i = i + dptr->aincr; /* sch fails, incr */ i = i + (1 - dfltinc); /* sch fails, incr */
else { /* no sch or success */ else { /* no sch or success */
if (flag != EX_D) { /* ex, ie, or id? */ if (flag != EX_D) { /* ex, ie, or id? */
reason = ex_addr (ofile, flag, i, dptr, uptr); reason = ex_addr (ofile, flag, i, dptr, uptr, dfltinc);
sim_switches = saved_switches; sim_switches = saved_switches;
if (reason > SCPE_OK) if (reason > SCPE_OK)
return reason; return reason;
} }
else else
reason = 1 - dptr->aincr; /* no, dflt incr */ reason = dfltinc; /* no, dflt incr */
if (flag != EX_E) { /* ie, id, or d? */ if (flag != EX_E) { /* ie, id, or d? */
reason = dep_addr (flag, cptr, i, dptr, uptr, reason); reason = dep_addr (flag, cptr, i, dptr, uptr, reason);
sim_switches = saved_switches; sim_switches = saved_switches;
@ -10019,12 +10023,13 @@ put_rval_pcchk (rptr, idx, val, TRUE);
addr = address to examine addr = address to examine
dptr = pointer to device dptr = pointer to device
uptr = pointer to unit uptr = pointer to unit
dfltinc = default increment
Outputs: Outputs:
return = if > 0, error status return = if > 0, error status
if <= 0,-number of extra addr units retired if <= 0,-number of extra addr units retired
*/ */
t_stat ex_addr (FILE *ofile, int32 flag, t_addr addr, DEVICE *dptr, UNIT *uptr) t_stat ex_addr (FILE *ofile, int32 flag, t_addr addr, DEVICE *dptr, UNIT *uptr, int32 dfltinc)
{ {
t_stat reason; t_stat reason;
int32 rdx; int32 rdx;
@ -10034,12 +10039,12 @@ if (sim_vm_fprint_addr)
else fprint_val (ofile, addr, dptr->aradix, dptr->awidth, PV_LEFT); else fprint_val (ofile, addr, dptr->aradix, dptr->awidth, PV_LEFT);
fprintf (ofile, ":\t"); fprintf (ofile, ":\t");
if (!(flag & EX_E)) if (!(flag & EX_E))
return (1 - dptr->aincr); return dfltinc;
GET_RADIX (rdx, dptr->dradix); GET_RADIX (rdx, dptr->dradix);
if ((reason = fprint_sym (ofile, addr, sim_eval, uptr, sim_switches)) > 0) { if ((reason = fprint_sym (ofile, addr, sim_eval, uptr, sim_switches)) > 0) {
fprint_val (ofile, sim_eval[0], rdx, dptr->dwidth, PV_RZRO); fprint_val (ofile, sim_eval[0], rdx, dptr->dwidth, PV_RZRO);
reason = 1 - dptr->aincr; reason = dfltinc;
} }
if (flag & EX_I) if (flag & EX_I)
fprintf (ofile, "\t"); fprintf (ofile, "\t");