Beginning to add Program Counter and Stack Pointer
Beginning to add initil Instruction Set
This commit is contained in:
@@ -2,6 +2,55 @@ namespace CPUSimulation
|
||||
{
|
||||
public class CU // Control Unit
|
||||
{
|
||||
|
||||
Dictionary<string, string> _instructionSet;
|
||||
Dictionary<string, Word> _registers;
|
||||
public CU(int numberOfMemoryBanks)
|
||||
{
|
||||
_instructionSet = new Dictionary<string, string>();
|
||||
_instructionSet.Add("00000", "NOP");
|
||||
_instructionSet.Add("00001", "LOAD");
|
||||
_instructionSet.Add("00010", "STORE");
|
||||
_instructionSet.Add("00011", "ADD");
|
||||
_instructionSet.Add("00100", "SUB");
|
||||
_instructionSet.Add("00101", "JUMP");
|
||||
_instructionSet.Add("00110", "JUMPIFZERO");
|
||||
_instructionSet.Add("00111", "JUMPIFNEG");
|
||||
_instructionSet.Add("01000", "AND");
|
||||
_instructionSet.Add("01001", "OR");
|
||||
_instructionSet.Add("01010", "XOR");
|
||||
_instructionSet.Add("01011", "NOT");
|
||||
_instructionSet.Add("01100", "SHL");
|
||||
_instructionSet.Add("01101", "SHR");
|
||||
_instructionSet.Add("01110", "INC");
|
||||
_instructionSet.Add("01111", "DEC");
|
||||
|
||||
_registers = new Dictionary<string, Word>();
|
||||
for (int i = 0; i < numberOfMemoryBanks; i++)
|
||||
{
|
||||
_registers.Add($"R{i}", new Word(new Byte[0]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal class ProgramCounter
|
||||
{
|
||||
Int16 _value;
|
||||
public ProgramCounter()
|
||||
{
|
||||
_value = 0;
|
||||
}
|
||||
public void Increment()
|
||||
{
|
||||
_value++;
|
||||
}
|
||||
public void SetValue(Int16 value)
|
||||
{
|
||||
_value = value;
|
||||
}
|
||||
public Int16 GetValue()
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user