コード例 #1
0
        public void UnConditionalJumpTest()
        {
            var command = AssemblyExecutableCommand.GetCommandFromName("jmp 100", context);

            command.Execute();

            Assert.IsTrue(context.GetRegisterByName("ip").GetValues().ToHexString() == "0100");
        }
コード例 #2
0
        public void JNZCondJump()
        {
            context.GetFlagByName("zf").Set();
            context.GetRegisterByName("ip").SetValue(new byte[] { 0x01, 0x00 });

            var command = AssemblyExecutableCommand.GetCommandFromName("jnz 400", context);

            command.Execute();

            Console.WriteLine(context.GetRegisterByName("ip").Value.ToHexString());
        }
コード例 #3
0
        public void AddTests()
        {
            string[] commands = { "add ax,00ff", "add bx,ax", "add [200],bx" };

            foreach (var command in commands)
            {
                var cmd = AssemblyExecutableCommand.GetCommandFromName(command, context);

                cmd.Execute();

                Console.WriteLine($"AX: {context.GetRegisterByName("ax").Value.ToHexString()} BX: {context.GetRegisterByName("bx").Value.ToHexString()} [200]: {context.MainMemory.Dump(200,2)}");
            }
        }
コード例 #4
0
        public void IndirectReferenceMov()
        {
            string[] commands = { "mov ax,0200", "mov [ax],ffff" };

            foreach (string command in commands)
            {
                var cmd = AssemblyExecutableCommand.GetCommandFromName(command, context);

                cmd.Execute();

                Console.WriteLine(context.GetRegisterByName("ax").Value.ToHexString());

                Console.WriteLine(context.MainMemory.Dump(200, 2));
            }
        }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
        // [TestMethod]
        public void MovCommands()
        {
            string[] commands = { "mov ax,fff1", "mov bx,5f65", "mov [200],ax", "mov cx,[200]" };

            foreach (var command in commands)
            {
                var cmd = AssemblyExecutableCommand.GetCommandFromName(command, context);

                cmd.Execute();

                Console.WriteLine(context.GetRegisterByName("ax").Value.ToHexString());
                Console.WriteLine(context.GetRegisterByName("bx").Value.ToHexString());
                Console.WriteLine(context.GetRegisterByName("cx").Value.ToHexString());
            }

            Console.WriteLine(context.MainMemory.Dump(200, 10));
        }
コード例 #7
0
        public void MOVTest()
        {
            var cmd = AssemblyExecutableCommand.GetCommandFromName("mov ax,bx", context);

            Console.WriteLine(cmd.GetType().FullName);
        }
コード例 #8
0
        public static void Execute(string str, ApplicationContext ctx)
        {
            AssemblyExecutableCommand cmd = GetCommandFromName(str, ctx);

            cmd.Execute(); // Executed on given Context reference!
        }