public VirtualMachine(ushort[] givenInput, ushort[] expectedOutput) { Data = new Data(0); Processor = new Processor(Data, new TestingIODevice(givenInput, expectedOutput)); Disassembler = new Disassembler(Data); }
/// <summary> /// Constructs the object using the I/O Device and /// Data object with specified History size. /// </summary> /// <param name="historySize">History size for Data object.</param> public VirtualMachine(int historySize) { Data = new Data(historySize); Processor = new Processor(Data, new ConsoleIODevice()); Disassembler = new Disassembler(Data); }
/// <summary> /// Constructs the object using the specifyed custom Data storage and I/O device /// objects. /// </summary> /// <param name="data">The Data object that stores memory and registers</param> /// <param name="ioDevice">The I/O device to be used by the I/O instructions</param> public VirtualMachine(Data data, IIODevice ioDevice) { Data = data; Processor = new Processor(Data, ioDevice); Disassembler = new Disassembler(Data); }
/// <summary> /// Calculates the effects of the next instruction. /// </summary> /// <remarks> /// This calculation in advance allows breakpoints to be hit BEFORE the /// actual execution. /// </remarks> /// <returns>A value holding the effects of the instruction.</returns> protected DataDelta CalculateNextDelta() { Data data = Target.VirtualMachine.Data; if (_processor == null || _processor.Data != data) { _processor = new Processor(data, _nullDevice); } data.Commit(); // Commits any previous changes try { _processor.Step(); } // Execute next instruction (breakpoint probe). catch (Exception) { } DataDelta result = data.Delta; // Delta object holds the changes made by the probe if (!data.Uncommit()) // Uncommit restores previous Delta object from history and discards the probe changes. { // If uncommit fails, we need to manually discard probe changes by calling Rollback(). data.Rollback(); } return result; }