sim_instr does not completely follow the outline in the SIMH v3
developer docs. It does not decrease sim_interval in readin mode.
Fixing this, I cleaned up some other things:
- Move the decrease of sim_interval to after the check for breakpoints,
but before the check for ios. This ensures that sim_interval will
decrease any time an instruction executes in normal mode, or readin
mode executes, or ios is set and the CPU is waiting for ios to clear.
(Except the CPU should be clearing ios itself, not waiting for ios to
clear, but that fix requires a complete redesign of the I/O routines
and belongs in another branch.)
- Correctly handle all four combinations of mod_tst and mod_rdin.
- When changing from readin mode to normal mode, if cpu_set_mode returns
an error, stop with the same error. If cpu_set_mode returns SCPE_OK,
either stop or continue execution, depending on the word read from tape.
- In petr_boot and in the readin mode code in sim_instr, if the
PETR is not attached to a file, return SCPE_UNATT. Never try to read
from an unattached unit; I believe this reads standard input and
prevents ^E from working.
Overall control structure inside the while (reason == 0) loop:
- When stopping due to an error, break out of the while loop where
possible.
- After handling "ios is set", continue, don't run readin/test/normal-
mode code.
- After handling one readin operation, if the code didn't break out
of the while loop, continue, don't run normal-mode code.