Your security, networking, programming, and application news source.

Wednesday, November 26, 2008

Assembly Programming in Python!


CorePy 1.0 Officially Released! (Nov 17, 2008)

  <CorePy> is a <Python> package that allows executing assembly instructions for x86, Cell BE, and PowerPC processors (32 and 64 bit) from within Python. It is an open source project available under a BSD license

  CorePy's usage is comparable to inline assembly in other languages, but provides much more control than most provide.

"high-performance applications that take advantage of advanced processor features, including multiple cores and vector instruction sets (SSE, VMX, SPU), usually inaccessible from high-level languages."

  CorePy works by using an ISA, a library of architecture instruction sets, to build a list of instructions in a InstructionStream. This is called a synthetic program and is converted to a stream of reusable processor instructions. These synthetic programs can be executed by the processor synchronously or asynchronously, passing parameters to and from other synthetic programs.

  A print function is built in that supports plugins for printing the instruction stream out to assembly. Nasm seems to be ready, but GAS-compatible output seems to be incomplete.

A simple example from the website:

# Load the x86_64 instructions and environment
>>> import corepy.arch.x86_64.isa as x86
>>> import corepy.arch.x86_64.platform as x86_env
Platform: linux.spre_linux_x86_64_64

# Create a simple synthetic program
>>> code = x86_env.InstructionStream()
>>> code.add(, 12))

# Execute the synthetic program
>>> proc = x86_env.Processor()
>>> result = proc.execute(code, mode='int')
>>> print result


<Download Page>

No comments:

Post a Comment