Exemplo n.º 1
0
        public static Action<CpuThreadState> CreateDelegateForString(this CpuProcessor CpuProcessor, String Assembly, bool BreakPoint = false)
        {
            CpuProcessor.MethodCache.Clear();

            Assembly += "\r\nbreak\r\n";
            var MemoryStream = new MemoryStream();
            MemoryStream.PreservePositionAndLock(() =>
            {
                var MipsAssembler = new MipsAssembler(MemoryStream);

                MipsAssembler.Assemble(Assembly);
            });

            //Console.WriteLine(Assembly);

            return (_CpuThreadState) =>
            {
                _CpuThreadState.PC = 0;

                //Console.WriteLine("PC: {0:X}", _CpuThreadState.PC);
                try
                {
                    while (true)
                    {
                        //Console.WriteLine("PC: {0:X}", _CpuThreadState.PC);
                        var Delegate = CpuProcessor.CreateDelegateForPC(MemoryStream, _CpuThreadState.PC);
                        _CpuThreadState.StepInstructionCount = 1000000;
                        Delegate.Delegate(_CpuThreadState);
                    }
                }
                catch (PspBreakException)
                {
                }
            };
        }
Exemplo n.º 2
0
 public static PspMethodStruct CreateAndCacheDelegateForPC(this CpuProcessor CpuProcessor, Stream MemoryStream, uint EntryPC)
 {
     var Delegate = CpuProcessor.MethodCache.TryGetMethodAt(EntryPC);
     if (Delegate == null)
     {
         Delegate = CpuProcessor.CreateDelegateForPC(MemoryStream, EntryPC);
         CpuProcessor.MethodCache.SetMethodAt(EntryPC, Delegate);
     }
     return Delegate;
 }
Exemplo n.º 3
0
        public static Action<CpuThreadState> CreateDelegateForString(this CpuProcessor CpuProcessor, String Assembly, bool BreakPoint = false)
        {
            var MemoryStream = new MemoryStream();
            MemoryStream.PreservePositionAndLock(() =>
            {
                var MipsAssembler = new MipsAssembler(MemoryStream);

                MipsAssembler.Assemble(Assembly);
            });
            var Delegate = CpuProcessor.CreateDelegateForPC(MemoryStream, 0);
            return (_CpuThreadState) =>
            {
                _CpuThreadState.StepInstructionCount = 1000000;
                Delegate(_CpuThreadState);
            };
        }