Exemple #1
0
 /// <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;
 }
Exemple #2
0
        /// <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;
        }
Exemple #3
0
 /// <inheritdoc/>
 public override void PerformAction(
     IParsedInstruction instruction,
     IEmulatedMemory memory,
     IProcessorState state,
     IALU alu)
 {
     alu.PerformAction(this.calculation, instruction.Immediate);
 }
Exemple #4
0
 /// <inheritdoc/>
 public void PutData(
     IParsedInstruction instruction,
     IEmulatedMemory memory,
     IProcessorState state,
     IALU alu,
     long value)
 {
     memory.SetValue(instruction.Width, (ulong)value, instruction.Address);
 }
Exemple #5
0
 /// <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)
 {
     state.ProgramCounter = (ushort)value;
 }
 /// <inheritdoc/>
 public void PutData(
     IParsedInstruction instruction,
     IEmulatedMemory memory,
     IProcessorState state,
     IALU alu,
     long value)
 {
     state.Registers[instruction.Register2] = value;
 }
Exemple #8
0
 /// <inheritdoc/>
 public void PutData(
     IParsedInstruction instruction,
     IEmulatedMemory memory,
     IProcessorState state,
     IALU alu,
     long value)
 {
     throw new NotImplementedException();
 }
Exemple #9
0
 /// <inheritdoc/>
 public void PutData(
     IParsedInstruction instruction,
     IEmulatedMemory memory,
     IProcessorState state,
     IALU alu,
     long value)
 {
     alu.StageValue(0, value);
 }
Exemple #10
0
        /// <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);
        }
Exemple #11
0
 /// <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);
     }
 }
Exemple #12
0
        /// <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]);
 }
 /// <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);
     }
 }
Exemple #15
0
 /// <inheritdoc/>
 public long GetData(IParsedInstruction instruction, IEmulatedMemory memory, IProcessorState state, IALU alu)
 {
     return((long)memory.GetValue(instruction.Width, (ushort)state.Registers[instruction.Register1]));
 }
 /// <inheritdoc/>
 public long GetData(IParsedInstruction instruction, IEmulatedMemory memory, IProcessorState state, IALU alu)
 {
     return(state.ProgramCounter + instruction.Offset);
 }
Exemple #17
0
 /// <inheritdoc/>
 public long GetData(IParsedInstruction instruction, IEmulatedMemory memory, IProcessorState state, IALU alu)
 {
     return(instruction.Address);
 }
Exemple #18
0
 /// <inheritdoc/>
 public long GetData(IParsedInstruction instruction, IEmulatedMemory memory, IProcessorState state, IALU alu)
 {
     return((long)memory.GetValue(instruction.Width, instruction.Address));
 }
Exemple #19
0
 /// <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);