本文整理汇总了C#中Compiler.Mov方法的典型用法代码示例。如果您正苦于以下问题:C# Compiler.Mov方法的具体用法?C# Compiler.Mov怎么用?C# Compiler.Mov使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Compiler
的用法示例。
在下文中一共展示了Compiler.Mov方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateMethod
private IntPtr CreateMethod(IntPtr stub)
{
Compiler compiler = new Compiler();
compiler.NewFunction(CallingConvention.Default, typeof(Func<int>));
GPVar x = compiler.NewGP(VariableType.INT32);
compiler.Mov(x, 2);
compiler.Ret(x);
compiler.EndFunction();
return compiler.Make();
}
示例2: Main
private static void Main(string[] args)
{
TestExceptionHandling test = new TestExceptionHandling();
test.RunTest();
Compiler compiler = new Compiler();
CallingConvention callingConvention = CallingConvention.Default;
compiler.NewFunction(callingConvention, typeof(Func<int>));
GPVar var = compiler.NewGP();
compiler.Mov(var, 3);
compiler.Ret(var);
compiler.EndFunction();
IntPtr ptr = compiler.Make();
Method1 method = (Method1)Marshal.GetDelegateForFunctionPointer(ptr, typeof(Method1));
int result = method();
Console.WriteLine(result);
IntPtr method2Ptr = CreateMethodStub();
TestMethod method2 = (TestMethod)Marshal.GetDelegateForFunctionPointer(method2Ptr, typeof(TestMethod));
Console.WriteLine(method2());
}
示例3: GenerateLoadExceptionMessage
private static void GenerateLoadExceptionMessage(Compiler c, GPVar dst, GPVar exceptionVariable)
{
c.Mov(dst, Mem.dword_ptr(exceptionVariable, ExceptionData_CodeOffset));
}
示例4: GenerateLoadCurrentException
private static void GenerateLoadCurrentException(Compiler c, GPVar dst, GPVar threadDataVariable)
{
GenerateLoadThreadData(c, dst, threadDataVariable);
c.Mov(dst, Mem.sysint_ptr(dst, ThreadData_ExceptionDataOffset));
}
示例5: GenerateLoadThreadData
private static void GenerateLoadThreadData(Compiler c, GPVar dst, GPVar threadDataVariable)
{
c.Mov(dst, threadDataVariable);
}
示例6: GenerateNewException
private static void GenerateNewException(Compiler c, GPVar dst, Imm code)
{
GPVar var = c.NewGP();
c.Mov(var, code);
CompilerFunctionCall call = c.Call(AllocateExceptionFunction, CallingConvention.Default, typeof(Func<int, IntPtr>));
call.SetArgument(0, var);
call.SetReturn(dst);
}
示例7: GenerateWriteLine
private static void GenerateWriteLine(Compiler c, Imm value)
{
GPVar var = c.NewGP();
c.Mov(var, value);
GenerateWriteLine(c, var);
}
示例8: BuildCpuIdFunction
private static CpuIdMethod BuildCpuIdFunction()
{
Compiler compiler = new Compiler();
compiler.NewFunction(CallingConvention.Default, typeof(Action<IntPtr, IntPtr, IntPtr, IntPtr>));
compiler.Function.SetHint(FunctionHints.Naked, true);
GPVar eaxPtr = compiler.ArgGP(0);
GPVar ebxPtr = compiler.ArgGP(1);
GPVar ecxPtr = compiler.ArgGP(2);
GPVar edxPtr = compiler.ArgGP(3);
GPVar eax = compiler.NewGP();
GPVar ebx = compiler.NewGP();
GPVar ecx = compiler.NewGP();
GPVar edx = compiler.NewGP();
compiler.Mov(eax, Mem.dword_ptr(eaxPtr));
compiler.Cpuid(eax, ebx, ecx, edx);
compiler.Mov(Mem.dword_ptr(eaxPtr), eax);
compiler.Mov(Mem.dword_ptr(ebxPtr), ebx);
compiler.Mov(Mem.dword_ptr(ecxPtr), ecx);
compiler.Mov(Mem.dword_ptr(edxPtr), edx);
compiler.Ret();
compiler.EndFunction();
CpuIdMethod cpuId = (CpuIdMethod)Marshal.GetDelegateForFunctionPointer(compiler.Make(), typeof(CpuIdMethod));
return cpuId;
}