Beginning to add Program Counter and Stack Pointer

Beginning to add initil Instruction Set
This commit is contained in:
2026-05-31 21:29:23 -04:00
parent a958d11c4e
commit faa7801376
5 changed files with 84 additions and 30 deletions
+50 -1
View File
@@ -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;
}
}
}
}