#define ASMAssembler x86::Assembler
#define ASMBuilder x86::Builder
#define ASMCompiler x86::Compiler
using namespace x86;
typedef int(*_Func1)(void);
void test1()
{
JitRuntime runtime;//JIT
CodeHolder code;//代码
//代码与JIT绑定
code.init(runtime.codeInfo());
//代码 与 平台绑定 X86汇编
ASMAssembler myAsm(&code); //X86汇编
//利用CALL 获取返回地址 eax=返回地址
myAsm.mov(eax,x86::ptr(esp));
myAsm.ret();
//myAsm.add(x86::eax, 1);
//myAsm.ret();
_Func1 Func1;
runtime.add(&Func1, &code);
int ret =Func1();
printf("ret:0x %x", ret);
runtime.release(Func1);
}
Func1:
00130000 8B 04 24 mov eax,dword ptr [esp]
00130003 C3 ret