예제 #1
0
        private void Step()
        {
            if (state.Halt)
            {
                Logger.Error("Program reached HALT State. Please reassemble the program");
                return;
            }

            switch (state.InstructionExecutionStep)
            {
            case 0:
            {
                var mir = MIR.Instance;
                var mar = MAR.Instance;
                var mpm = new MPM();
                mir.Value = mpm[mar.Value];
                state.InstructionExecutionStep = 1;
                break;
            }

            case 1:
            {
                ALU.DoOperation();
                MIR.Instance.CheckForOtherOperationsAndExecuteIfPresent();
                Memory.CheckForOperationAndExecuteIfPresent();
                MAR.Instance.PrepareForNextMicroInstruction();
                state.InstructionExecutionStep = 0;
                break;
            }

            default:
            {
                throw new Exception("STATE OUT OF RANGE");
            }
            }
        }