I'm searching for a good assembly generation module for Python. I have found this one: PyAsm
But it's not working well. I want to execute and generate assembly executable file for simple operations like add, sub, divide and multiply. Something like Reflection.Emit library in .NET.
I'm developing under Linux (Ubuntu 12.10 64bit) and Python2.7.
For example, when I try to compile this simple sub code with PyAsm it gives me a "Segmentation fault (core dumped)":
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()
Not just an awesome name: https://github.com/Maratyszcza/PeachPy
Looks at it's use in: http://www.yeppp.info
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With