/// <summary> /// Initializes a new instance of the <see cref="PC"/> class. /// </summary> public PC() { this.SetupContainerGraph(); this.processor = this.container.GetInstance <IProcessor>(); this.memory = this.container.GetInstance <IEmulatedMemory>(); this.state = this.container.GetInstance <IProcessorState>(); }
/// <inheritdoc/> public override void PerformAction( IParsedInstruction instruction, IEmulatedMemory memory, IProcessorState state, IALU alu) { ushort addressA = (ushort)state.Registers[instruction.Register1]; ushort addressB = (ushort)state.Registers[instruction.Register2]; byte a = 0; byte b = 0; for (ushort i = 0; i < instruction.Immediate; i++) { a = (byte)memory.GetValue(0, (ushort)(addressA + i)); b = (byte)memory.GetValue(0, (ushort)(addressB + i)); if (a != b) { break; } } state.High = a > b; state.Equal = a == b; state.Low = !state.High; }
/// <summary> /// Initializes a new instance of the <see cref="Processor"/> class. /// </summary> /// <param name="parsedInstruction">Parsed instruction.</param> /// <param name="memory">Memory.</param> /// <param name="alu">ALU.</param> /// <param name="state">Processor state.</param> public Processor(IParsedInstruction parsedInstruction, IEmulatedMemory memory, IALU alu, IProcessorState state) { this.parsedInstruction = parsedInstruction; this.memory = memory; this.alu = alu; this.state = state; }
/// <summary> /// Performs actions. /// </summary> /// <param name="instruction">Parsed instruction.</param> /// <param name="memory">Memory.</param> /// <param name="state">Processor state.</param> /// <param name="alu">ALU.</param> public void PerformActions(IParsedInstruction instruction, IEmulatedMemory memory, IProcessorState state, IALU alu) { foreach (var action in this.actions) { action.PerformAction(instruction, memory, state, alu); } }
/// <inheritdoc/> public override void PerformAction( IParsedInstruction instruction, IEmulatedMemory memory, IProcessorState state, IALU alu) { alu.PerformAction(this.calculation, instruction.Immediate); }
/// <inheritdoc/> public void PutData( IParsedInstruction instruction, IEmulatedMemory memory, IProcessorState state, IALU alu, long value) { throw new NotImplementedException(); }
/// <inheritdoc/> public void PutData( IParsedInstruction instruction, IEmulatedMemory memory, IProcessorState state, IALU alu, long value) { memory.SetValue(instruction.Width, (ulong)value, (ushort)state.Registers[instruction.Register1]); }
/// <inheritdoc/> public void PutData( IParsedInstruction instruction, IEmulatedMemory memory, IProcessorState state, IALU alu, long value) { alu.StageValue(0, value); }
/// <inheritdoc/> public void PutData( IParsedInstruction instruction, IEmulatedMemory memory, IProcessorState state, IALU alu, long value) { state.ProgramCounter = (ushort)value; }
/// <inheritdoc/> public void PutData( IParsedInstruction instruction, IEmulatedMemory memory, IProcessorState state, IALU alu, long value) { state.Registers[instruction.Register2] = value; }
/// <inheritdoc/> public void PutData( IParsedInstruction instruction, IEmulatedMemory memory, IProcessorState state, IALU alu, long value) { memory.SetValue(instruction.Width, (ulong)value, instruction.Address); }
/// <inheritdoc/> public override void PerformAction( IParsedInstruction instruction, IEmulatedMemory memory, IProcessorState state, IALU alu) { long value = this.from.GetData(instruction, memory, state, alu); this.to.PutData(instruction, memory, state, alu, value); }
/// <inheritdoc/> public override void PerformAction( IParsedInstruction instruction, IEmulatedMemory memory, IProcessorState state, IALU alu) { if (state.Low & this.low || state.Equal & this.equal || state.High & this.high) { this.action.PerformAction(instruction, memory, state, alu); } }
/// <inheritdoc/> public override void PerformAction( IParsedInstruction instruction, IEmulatedMemory memory, IProcessorState state, IALU alu) { long a = state.Registers[instruction.Register1]; long b = state.Registers[instruction.Register2]; state.High = a > b; state.Equal = a == b; state.Low = !state.High; }
/// <inheritdoc/> public long GetData(IParsedInstruction instruction, IEmulatedMemory memory, IProcessorState state, IALU alu) { return(state.Registers[instruction.Register2]); }
/// <inheritdoc/> public long GetData(IParsedInstruction instruction, IEmulatedMemory memory, IProcessorState state, IALU alu) { return(state.ProgramCounter + instruction.Offset); }
/// <inheritdoc/> public long GetData(IParsedInstruction instruction, IEmulatedMemory memory, IProcessorState state, IALU alu) { return((long)memory.GetValue(instruction.Width, instruction.Address)); }
/// <summary> /// Performs processor action. /// </summary> /// <param name="instruction">Parsed instruction.</param> /// <param name="memory">Memory.</param> /// <param name="state">Processor state.</param> /// <param name="alu">ALU.</param> public abstract void PerformAction( IParsedInstruction instruction, IEmulatedMemory memory, IProcessorState state, IALU alu);
/// <inheritdoc/> public long GetData(IParsedInstruction instruction, IEmulatedMemory memory, IProcessorState state, IALU alu) { return(instruction.Address); }
/// <inheritdoc/> public long GetData(IParsedInstruction instruction, IEmulatedMemory memory, IProcessorState state, IALU alu) { return((long)memory.GetValue(instruction.Width, (ushort)state.Registers[instruction.Register1])); }