public void CreateDelegateTest() { var CpuThreadState = new CpuThreadState(); var CompilerState = new CompilerState(); CpuThreadState.r1 = 1000000000000000000; CompilerState.SaveGpr(0, () => { CompilerState.LoadGpr(1); CompilerState.LoadImm(999); CompilerState.Emit(OpCodes.Add); }); CompilerState.Ret(); CompilerState.CreateDelegate()(CpuThreadState); Assert.AreEqual(1000000000000000999, CpuThreadState.r0); }
static void Test2() { //new DisassemblerTest().DissasembleTest(); /* Console.WriteLine(Disassembler.DissasembleSimple(0x3D608202)); Console.WriteLine(Disassembler.DissasembleSimple(0x7C7E1B78)); Console.WriteLine(Disassembler.DissasembleSimple(0x7FA53214)); Console.WriteLine(Disassembler.DissasembleSimple(0x7D8802A6)); */ Console.WriteLine(Disassembler.DissasembleSimple(0x4E800020)); var CpuThreadState = new CpuThreadState(); var CompilerState = new CompilerState(); var Compiler = new Compiler(CompilerState); CompilerState.CurrentInstruction = 0x7D8802A6; Compiler.mflr(); var Delegate = CompilerState.CreateDelegate(); CpuThreadState.lr = 999; Delegate(CpuThreadState); Console.WriteLine("{0}, {1}", CpuThreadState.lr, CpuThreadState.r12); }