Introduction
PyASM is a full-featured dynamic assembler written entirely in Python. By dynamic, I mean that it can be used to generate and execute machine code in python at runtime without requiring the generation of object files and linkage. It essentially allow 'inline' assembly in python modules on x86 platforms.
PyASM can also generate object files (for windows) like a traditional standalone assembler, although you're probably better off using one of the many freely available assemblers if this is you primary goal.
Installation
PyASM requires python 2.4 or later. To the best of my knowledge, the only 2.4 specific feature I've used is from x import (a,b,c), but I need to draw a line in the sand somewhere as far as the installations I'll test and support.
Linux Install:
- Download and extract pyasm-0.2.tar.gz
- python setup.py install
Windows Install:
- Download and run pyasm-0.2.win32-py2.4.exe
- A source distribution pyasm-0.2.zip is available, but you'll need VS7.0 to compile the excmem module.
Hello World!
A simple Windows version of a hello_world.py program is as follows:
#
# Hello World in assembly: hello_World.py
#
#
from pyasm import pyasm
pyasm(globals(),r"""
!CHARS hello_str 'Hello world!\n\0'
!PROC hello_world PYTHON
!ARG self
!ARG args
PUSH hello_str
CALL PySys_WriteStdout
ADD ESP, 0x4
MOV EAX,PyNone
ADD [EAX],1
!ENDPROC
""")
hello_world()
http://members.verizon.net/~olsongt/usersGuide.html
god job
ReplyDeletetnx