예제 #1
0
        public void OneOperandTest()
        {
            var converter = new AssemblyConverter();

            string firstInstruction = "INC R5";
            string machineCode      = converter.AssemblyConvert(firstInstruction);

            Assert.NotEmpty(machineCode);

            Assert.Equal(16, machineCode.Length);

            Assert.Equal("1110010100000000", machineCode);
        }
예제 #2
0
        public void TestOneLine()
        {
            var converter = new AssemblyConverter();

            string firstInstruction = "PUSH R6";
            string machineCode      = converter.AssemblyConvert(firstInstruction);

            Assert.NotEmpty(machineCode);

            Assert.Equal(16, machineCode.Length);

            Assert.Equal("0000011000000000", machineCode);
        }
예제 #3
0
        public void TestMov()
        {
            var converter = new AssemblyConverter();

            string firstInstruction = "MOV R0, R7";
            string machineCode      = converter.AssemblyConvert(firstInstruction, true);

            Assert.NotEmpty(machineCode);

            Assert.Equal(4, machineCode.Length);

            Assert.Equal("80E0", machineCode);
        }
예제 #4
0
        public void JumpTest()
        {
            var converter = new AssemblyConverter();

            string firstInstruction = "JZ R7";
            string machineCode      = converter.AssemblyConvert(firstInstruction);

            Assert.NotEmpty(machineCode);

            Assert.Equal(16, machineCode.Length);

            Assert.Equal("0100111100000000", machineCode);
        }
예제 #5
0
        public void TestShift()
        {
            var converter = new AssemblyConverter();

            string instruction = "SHL R3, A";

            string machineCode = converter.AssemblyConvert(instruction, hex: true);

            Assert.NotEmpty(machineCode);

            Assert.Equal(4, machineCode.Length);

            Assert.Equal("B314", machineCode);
        }
예제 #6
0
        public void EATest()
        {
            var converter = new AssemblyConverter();

            string firstInstruction = "LDD R1, 0128F";
            string machineCode      = converter.AssemblyConvert(firstInstruction);

            Assert.NotEmpty(machineCode);

            Assert.Contains("\n", machineCode);

            var    lines = machineCode.Split('\n');
            string part1 = machineCode.Substring(0, machineCode.IndexOf('\n'));

            Assert.Equal(16, part1.Length);

            //Assert.Equal("0011100100000001‬", part1);

            //Assert.Equal("1001010001111000", lines[1]);
        }