/* Main instruction fetch/decode loop */ while (reason == 0) { /* loop until halted */ // clean SIMH loop exit code here // SIMH clock queue code here /* ---PiDP add--------------------------------------------------------------------------------------------- */ // handle PiDP-8/i Sing Step and Sing Inst switch behavior here /* ---PiDP end---------------------------------------------------------------------------------------------- */ this_Major_State = next_Major_State; switch (this_Major_State) { case FETCH_state: // fetch state for all instructions, regardless of op code // perform actual instruction fetch here // handle SIMH breakpoint here // handle SIMH history here op_code = (IR >> 9) & 07; switch (op_code) { case 4: // special JMS-specific on top of AND, TAD, DCA, ISZ action here // intentional fall-through for JMS case 0:case 1:case 2:case 3: // Fetch state for MRIs: AND, TAD, ISZ, DCA, JMS // handle current page / zero page with direct / indirect here if (IR & 0400) /* indirect or direct? */ next_Major_State = DEFER_state; /* indirect */ else next_Major_State = EXECUTE_state; /* direct */ break; // end of case op_code 0..4: AND, TAD, ISZ, DCA, JMS case 5: // Fetch state for JMP, including emulating timeshare control // handle current page / zero page with direct / indirect here if (IR & 0400) /* direct or indirect? */ next_Major_State = DEFER_state; /* indirect JMP */ else { // handle direct jump and timeshare control } /* end direct JMP */ break; // end of case op_code 5: JMP case 6: // Fetch state for IOTs // handle all IOTs including timeshare control card break; // end of case op_code 6: IOT case 7: // Fetch state for OPRs // handle all Operate group 1, 2, 3 standard, and 3 EAE variations // group 3 EAE includes Mode A and Mode B emulation break; // end of case op_code 7 } // end of switch (op_code) break; // end of case FETCH_state case DEFER_state: // handle DEFER major state for MRIs and JMP if (((IR >> 9) & 07) != 5) /* MRI or JMP? */ next_Major_State = EXECUTE_state; /* it's a MRI */ else { if (UF) { /* it's a JMP, user mode? */ // handle timeshare control } } next_Major_State = FETCH_state; } break; // end of case DEFER_state case EXECUTE_state: // handle EXECUTE major state for MRIs and JMS if (((IR >> 9) & 07) < 4) { /* AND .. DCA, or is it JMS? */ if (IR & 00400) /* it is AND .. DCA, direct or indirect? */ MA = DF | (MA & 07777); /* indirect, use DF */ else MA = IF | (MA & 07777); /* direct, use IF */ MB = M[MA]; /* get the data word */ switch ((IR >> 9) & 07) { case 0: /* AND */ // execute AND here break; case 1: /* TAD */ // execute TAD here break; case 2: /* ISZ */ // execute ISZ here break; case 3: /* DCA */ // execute DCA here break; } // end of switch ((IR >> 9) & 07) } else { // execute JMS here, including timeshare control } next_Major_State = FETCH_state; break; // end of case EXECUTE_state } // end of switch (Major_State) /* ---PiDP add--------------------------------------------------------------------------------------------- */ // Update the front panel with this Major State's ending state. /* ---PiDP end---------------------------------------------------------------------------------------------- */ // handle hardware device interrupt here } /* end while (reason == 0) */