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
+21 -1
View File
@@ -2,6 +2,26 @@ namespace CPUSimulation
{
public class Utils
{
static Random _random = new Random();
public static Word GenerateRandomWord(int byteCount)
{
byteCount = _random.Next(1, byteCount + 1);
//Console.WriteLine($"Generating random word with {byteCount} bytes.");
Byte[] bytes = new Byte[byteCount];
for (int i = 0; i < byteCount; i++)
{
bytes[i] = GenerateRandomByte();
}
return new Word(bytes);
}
public static Byte GenerateRandomByte()
{
Bit[] bits = new Bit[8];
for (int i = 0; i < 8; i++)
{
bits[i] = new Bit(_random.Next(2) == 1);
}
return new Byte(bits);
}
}
}