我正在为Python寻找一个好的程序集生成模块。 我找到了这个: PyAsm
但效果不好。 我想执行并生成程序集可执行文件,用于简单的操作,如加法、减法、除法和乘法。 有点像反射。发射.NET中的库。在
我在Linux(Ubuntu12.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中的用法
相关问题 更多 >
编程相关推荐