且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

JIT代码生成技术

更新时间:2023-11-10 18:06:04

您只需将程序计数器指向您要执行的代码。请记住,数据可以是数据或代码。在x86上,程序计数器是EIP寄存器。 EIP的IP部分代表指令指针。调用JMP指令以跳转到一个地址。跳转后,EIP将包含此地址。

You can just make the program counter point to the code you want to execute. Remember that data can be data or code. On x86 the program counter is the EIP register. The IP part of EIP stands for instruction pointer. The JMP instruction is called to jump to an address. After the jump EIP will contain this address.


这难道就像将助记符指令映射到二进制代码,并将其填充到一个char中一样*指针并将其强制转换为函数并执行?

Is it something as hacky as mapping the mnemonic instructions to binary codes, stuffing it into an char* pointer and casting it as a function and executing?

是。这是一种方法。产生的代码将转换为C中的功能指针

Yes. This is one way of doing it. The resulting code would be cast to a pointer to function in C.