예제 #1
0
 public void TestAddSub()
 {
     Assert.AreEqual("Register: a = -7, b = -14",
                     AssemblerInterpreter.Interpret("\n; Add Test\nmov a, -10\nmov b, a\ninc a\ndec b\nadd a, 2\nadd b, -3\nmsg 'Register: a = ', a, ', b = ', b\nend\n"));
     Assert.AreEqual("Register: a = -5, b = -17",
                     AssemblerInterpreter.Interpret("\n; Sub Test\nmov a, -10\nmov b, a\ninc a\ndec b\nadd a, 2\nadd b, -3\nsub a, -2\nsub b, 3\nmsg 'Register: a = ', a, ', b = ', b\nend\n"));
 }
예제 #2
0
 public void TestIncDec()
 {
     Assert.AreEqual("Register: 6",
                     AssemblerInterpreter.Interpret("\n; First Test from Part 1\nmov a, 5\ninc a\ndec a\ninc a\nmsg 'Register: ', a\nend\n"));
     Assert.AreEqual("Register: a = -9, b = -11",
                     AssemblerInterpreter.Interpret("\n; Second Test from Part 1\nmov a, -10\nmov b a\ninc a\ndec b\nmsg 'Register: a = ', a, ', b = ', b\nend\n"));
 }
예제 #3
0
 public void TestNull()
 {
     Assert.AreEqual(null, AssemblerInterpreter.Interpret("\n; Null Test"));
 }
예제 #4
0
 public void TestBlankSubroutine()
 {
     Assert.AreEqual("Register: a = -1, b = -34",
                     AssemblerInterpreter.Interpret("\n; Sub Test\nmov a, -10\nmov b, a\ninc a\ndec b\nadd a, 2\nadd b, -3\nsub a, -2\nsub b, 3\ndiv a, 5\nmul b, 2\nnop:\nret\nmsg 'Register: a = ', a, ', b = ', b\nend\n"));
 }