public void AddLargeNumTest() { CPU target = new CPU(); string[] codelines = new string[] { // 2000 + 100*250 "LOAD R0,2000", "ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250", "ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250", "ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250", "ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250", "ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250", "ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250", "ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250", "ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250", "ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250", "ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250" }; int startAddress = 0; target.LoadMemory(codelines, startAddress); target.Run(startAddress); Assert.AreEqual(27000, target.GetRegisterValue(0)); }
public void AddNegNumTest() { CPU target = new CPU(); string[] codelines = new string[] { "LOAD R0,-500", "ADD 250" }; int startAddress = 0; target.LoadMemory(codelines, startAddress); Assert.AreNotEqual(0, target.Memory.GetWord(0).UValue); Assert.AreNotEqual(0, target.Memory.GetWord(2).UValue); Assert.AreEqual(0, target.Memory.GetWord(4).UValue); target.Run(startAddress); Assert.AreEqual(-250, target.GetRegisterValue(0)); }
public void LoadMemoryTest() { CPU target = new CPU(); string[] codelines = new string[] { "ADD R1", "ADD 500", "ADD R2" }; int startAddress = 0; target.LoadMemory(codelines, startAddress); Assert.AreNotEqual(0, target.Memory.GetWord(0).UValue); // ADD R1 Assert.AreNotEqual(0, target.Memory.GetWord(2).UValue); // ADD 500 Assert.AreNotEqual(0, target.Memory.GetWord(4).UValue); // ADD R2 Assert.AreEqual(0, target.Memory.GetWord(6).UValue); }