I am looking for a nice build assembly module for Python. I found this: PyAsm
But that does not work. I want to execute and generate an assembly executable for simple operations like add, sub, divide and multiply. Something like the Reflection.Emit library in .NET.
I am developing on Linux (Ubuntu 12.10 64bit) and Python2.7.
For example, when I try to compile this simple subcode using PyAsm, it gives me a โcore dumpedโ error:
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()
source share