Esempio n. 1
0
        public void MemoryAssembleableCommandTestMOV()
        {
            var cmd = new AssemblableCommand(context, "mov ax,[100]");

            context.MainMemory.SetValues(300, cmd.Assemble());

            Assert.IsTrue(context.MainMemory.Dump(300, 3) == "A1-00-01");
        }
Esempio n. 2
0
        public void ImmediateAssembleableCommandTestSIMOV()
        {
            var cmd = new AssemblableCommand(context, "mov si,B7");

            context.MainMemory.SetValues(300, cmd.Assemble());

            Assert.IsTrue(context.MainMemory.Dump(300, 3) == "BE-B7-00");
        }
Esempio n. 3
0
        public void ImmediateMemoryCommandTestMOV()
        {
            var cmd = new AssemblableCommand(context, "mov [0123],00FF");

            context.MainMemory.SetValues(300, cmd.Assemble());

            Assert.IsTrue(context.MainMemory.Dump(300, 6) == "C7-06-23-01-FF-00");
        }
        public void INCDECTest()
        {
            Memory mem = new Memory(new byte[] { 0x40 });

            AssemblableCommand cmd = Disassembler.Dissassemble(DebugCommandsTests.context, mem.ExtractMemoryPointer(0, 1));

            Console.WriteLine(cmd.ToString());
            Assert.IsTrue(cmd.ToString() == "inc ax");
        }
        public void MediumMOVTest()
        {
            Memory mem = new Memory(new byte[] { 0xb8, 0xaa, 0xff });

            AssemblableCommand cmd = Disassembler.Dissassemble(DebugCommandsTests.context,
                                                               mem.ExtractMemoryPointer(0, 3));

            Assert.IsTrue(cmd.ToString() == "mov ax,FFAA");
        }
        public void SimpleMOVDisTest()
        {
            Memory mem = new Memory(new byte[] { 0x89, 0xd8 });

            AssemblableCommand cmd = Disassembler.Dissassemble(DebugCommandsTests.context,
                                                               mem.ExtractMemoryPointer(0, 2));

            Assert.IsTrue(cmd.ToString() == "mov ax,bx");
        }
Esempio n. 7
0
        public void DefaultAssembleableCommandTestMOV()
        {
            var cmd = new AssemblableCommand(context, "mov ax,bx");

            cmd.Assemble();

            context.MainMemory.SetValues(300, cmd.Assemble());

            Assert.IsTrue(context.MainMemory.Dump(300, 2) == "89-D8");
        }
        public void REGIMMMOVTest()
        {
            Memory mem = new Memory(new byte[] { 0xbb, 0x56, 0x78 });

            AssemblableCommand cmd = Disassembler.Dissassemble(DebugCommandsTests.context,
                                                               mem.ExtractMemoryPointer(0, 3));

            Console.WriteLine(cmd.ToString());
            Assert.IsTrue(cmd.ToString() == "mov bx,7856");
        }
        public void REGMEMMOVTest()
        {
            Memory mem = new Memory(new byte[] { 0xa1, 0x00, 0x02 });

            AssemblableCommand cmd = Disassembler.Dissassemble(DebugCommandsTests.context,
                                                               mem.ExtractMemoryPointer(0, 3));

            Console.WriteLine(cmd.ToString());
            Assert.IsTrue(cmd.ToString() == "mov ax,[0200]");
        }
        public void DoubleParameterMOVTest()
        {
            Memory mem = new Memory(new byte[] { 0xc7, 0x06, 0x00, 0x01, 0xaa, 0xff });

            AssemblableCommand cmd = Disassembler.Dissassemble(DebugCommandsTests.context,
                                                               mem.ExtractMemoryPointer(0, 6));

            Console.WriteLine(cmd.ToString());
            Assert.IsTrue(cmd.ToString() == "mov [0100],FFAA");
        }
        private void TCommand(List <string> debugCommandParameters, params string[] input)
        {
            int startLocation;

            try {
                if (debugCommandParameters.Count == 0)
                {
                    startLocation =
                        //BitConverter.ToInt32( MySupport.Normalize(Context.GetRegisterByName("ip").Value.Reverse().ToArray()), 0);
                        Convert.ToInt32(
                            MySupport.Normalize(context.GetRegisterByName("ip").Value.ToArray()).ToHexString(), 16);
                }
                else
                {
                    startLocation = Convert.ToInt32(debugCommandParameters[0], 16);
                    context.GetRegisterByName("ip")
                    .SetValue(MySupport.Normalize(BitConverter.GetBytes(startLocation).Reverse().ToArray()));
                }

                AssemblableCommand nextCommand = Disassembler.DisassembleNextCommand(context,
                                                                                     context.MainMemory.ExtractMemoryPointer(
                                                                                         Convert.ToInt32(
                                                                                             MySupport.NormlizeForHex(context.GetRegisterByName("ip").Value).ToArray().ToHexString(),
                                                                                             16),
                                                                                         16));

                if (nextCommand.selectedCommand == CommandTemplate.UNKNOWN)
                {
                    ConsoleLogger.Write("Comando non riconoscuto", "ERROR", ConsoleColor.Red);
                    return;
                }

                AssemblyExecutableCommand cmd = AssemblyExecutableCommand.GetCommandFromName(nextCommand.ToString(),
                                                                                             context);

                context.Registers[context.Registers.FindIndex(e => e.Name == "ip")] += new byte[]
                { 0x0, (byte)nextCommand.Length };


                cmd.Execute();

                this.RCommand(null);
            }
            catch (Exception e) {
                ConsoleLogger.Write("Error: " + e.Message + " CLASS: " + e.ToString(), "ERROR", ConsoleColor.Red);
            }
        }
        private void UCommand(IReadOnlyList <string> debugCommandParameters, params string[] input)
        {
            if (debugCommandParameters.Count != 1)
            {
                return;
            }
            int index = int.Parse(debugCommandParameters[0], NumberStyles.HexNumber);

            MemoryRangePointer pointer = context.MainMemory.ExtractMemoryPointer(index, 50);

            var indexList = new List <int>();

            List <AssemblableCommand> cmds = Disassembler.MultiCommandDisassembler(context, pointer, ref indexList);

            for (var i = 0; i < cmds.Count; i++)
            {
                AssemblableCommand cmd = cmds[i];
                if (cmd.ToString().TrimEnd() != "????")
                {
                    Console.WriteLine($"{(indexList[i] + index):X4} => {cmd.ToString()}");
                }
            }
        }