中的使用
我正在寻找一个好的Python汇编生成模块。我找到了这个:PyAsm
但是效果不太好。我想执行和生成汇编可执行文件的简单操作,如加,减,除和乘。就像反射。. net中的Emit库。
我在Linux (Ubuntu 12.10 64位)和Python2.7下开发。
例如,当我尝试用PyAsm编译这个简单的子代码时,它给了我一个"分段错误(核心转储)"。:
from ctypes import c_int
from pyasm import Program
from pyasm.instructions import push, mov, ret, pop, sub
from pyasm.registers import eax, esp, ebp
def test():
prog = Program(
push(ebp),
mov(ebp, esp),
mov(eax, ebp.addr+8),
sub(eax, 10),
pop(ebp),
ret(),
)
fun = prog.compile(c_int, [c_int])
assert fun(1234) == 1224
if __name__ == '__main__':
test()
不仅仅是一个很棒的名字:https://github.com/Maratyszcza/PeachPy
查看它在:http://www.yeppp.info