Run machine code directly in Python
Project description
pyas
Run machine code directly in Python
Have you ever realized you can't remember how to add numbers in Python but you do remember how to do it in assembly and convert it to machine code?
If the answer is yes this is the package for you, using pyas
you will be able to run machine code directly from within Python!
- currently this only supports Linux
Installation
From PyPI
pip3 install pyas
From GitHub
pip3 install git+https://github.com/donno2048/pyas
Usage / Example
from pyas import function
add_one = function(
'8b c7' # mov eax, edi
'83 c0 01' # add eax, 1
'c3' # ret
)
return_same = function(
'''
8b c7 # mov eax, edi
c3 // ret
'''
)
print(add_one(10), "=", return_same(10), "+ 1")
# output: 11 = 10 + 1
add_numbers = lambda i: function(
'''
8b c7 ; mov eax, edi
83 c0 %.2x # add eax, i
c3 // ret
'''
%i
)
print(add_numbers(4)(10), "=", "10 + 4")
# output: 14 = 10 + 4
Comments are noted with ;
, #
and //
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyas-1.0.2.tar.gz
(2.7 kB
view hashes)
Built Distribution
pyas-1.0.2-py3-none-any.whl
(2.9 kB
view hashes)