/// <summary>
 /// This function rebinds the delegate function to each instruction in a program after it is loaded from a file.
 /// </summary>
 /// <param name="prog"> the program to bind its instruction delegates </param>
 private void BindInstructionDelegates(ref SimulatorProgram prog)
 {
     foreach (Instruction i in prog.Instructions)
     {
         i.BindDelegate();
     }
 }
Beispiel #2
0
 public SimulatorLabel(SimulatorProgram program, int logicalAddress, int physicalAddress, string name)
 {
     this.program         = program;
     this.logicalAddress  = logicalAddress;
     this.physicalAddress = physicalAddress;
     this.name            = name;
 }
 /// <summary>
 /// Constructor for execution unit that starts executing from the beginning of the program
 /// </summary>
 /// <param name="program"> the program to execute </param>
 /// <param name="clockSpeed"> the clock speed of the CPU </param>
 public ExecutionUnit(SimulatorProgram program, int clockSpeed)
 {
     try
     {
         this.program       = program;
         this.clockSpeed    = clockSpeed;
         currentIndex       = 0;
         logicalAddress     = currentIndex * 4;
         currentInstruction =
             program.Instructions.Where(x => x.LogicalAddress == logicalAddress).FirstOrDefault();
         stop = false;
         done = false;
         SpecialRegister.FindSpecialRegister("BR").SetRegisterValue(program.BaseAddress, EnumOperandType.ADDRESS);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.StackTrace);
         MessageBox.Show("Please load a program before running the CPU");
     }
 }