Python Bindings for Polkavm-Assembler, a Runtime assembler for PolkaVM
Project description
TSRKit ASM: PolkaVM Assembler Python Bindings
Python bindings for the PolkaVM runtime assembler, providing high-performance x86-64 assembly generation capabilities.
Features
- Runtime Assembly Generation: Generate x86-64 machine code at runtime
- Label Support: Forward declaration and resolution of jump/call targets
- Full Instruction Set: Support for common x86-64 instructions including:
- Basic operations (NOP, RET, SYSCALL)
- Register operations (PUSH, POP, MOV)
- Arithmetic (ADD, SUB, AND, OR, XOR, CMP)
- Control flow (JMP, CALL, conditional jumps)
- Type Safety: Complete type stubs for excellent IDE support
- High Performance: Built on Rust for maximum speed
Installation
pip install tsrkit-asm
Quick Start
from tsrkit_asm import PyAssembler
# Create an assembler instance
asm = PyAssembler()
# Generate a simple function that adds two numbers
asm.mov_reg_imm64(py_asm.RAX, 42)
asm.mov_reg_imm64(py_asm.RBX, 13)
asm.add_reg_reg(64, py_asm.RAX, py_asm.RBX)
asm.ret()
# Get the machine code
machine_code = asm.finalize()
print(f"Generated {len(machine_code)} bytes of machine code")
Advanced Usage
Using Labels for Control Flow
from tsrkit_asm import PyAssembler
asm = PyAssembler()
# Create labels for a loop
loop_start = asm.forward_declare_label()
loop_end = asm.forward_declare_label()
# Initialize counter in RAX
asm.mov_reg_imm64(py_asm.RAX, 10)
# Loop start
asm.define_label(loop_start)
asm.sub_reg_imm(py_asm.RAX, 1)
asm.cmp_reg_imm(py_asm.RAX, 0)
asm.jne_label32(loop_start)
# Loop end
asm.define_label(loop_end)
asm.ret()
machine_code = asm.finalize()
License
This project is licensed under Apache-2.0.
Contributing
Contributions are welcome! Please see the main PolkaVM repository for contribution guidelines.
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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tsrkit_asm-0.1.0.tar.gz.
File metadata
- Download URL: tsrkit_asm-0.1.0.tar.gz
- Upload date:
- Size: 33.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1495d47c3560d5cfb23a23dc463b96f9df7e1eb071ccedc555658f0a48c35e8f
|
|
| MD5 |
de4d6041f7e08dc5fe5a961cedbe883f
|
|
| BLAKE2b-256 |
398d38bb6a757d1fcc44950772c5f52ad595543055dec657dbe1483dbf58dd09
|
File details
Details for the file tsrkit_asm-0.1.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: tsrkit_asm-0.1.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 221.3 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
783ebc4a2a16a31b26aa895f03d0684fd04ebda957197a383a9251af1207336a
|
|
| MD5 |
5fbdca87007c129bcb320292a99bf8be
|
|
| BLAKE2b-256 |
a2e65ff6035a4c0a4e8823cc946dd3cc31b13eead269f2ffa13612136071b865
|
File details
Details for the file tsrkit_asm-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: tsrkit_asm-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 375.6 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb6cfdc76799eddf7d70a419a9b0bb1a09af72a2eb5b1a7bdd59e8ec9f48b42e
|
|
| MD5 |
a18fe170e4d689092815cf2622d281bd
|
|
| BLAKE2b-256 |
bf386358904ca844d85265667775241cb27ae5307601b4d930e9d9f7e196d95d
|
File details
Details for the file tsrkit_asm-0.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: tsrkit_asm-0.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 377.3 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d44aab1975cc8f8c1cb3b451bd88f59dd0575e8a194b4fa341149e300a4f8a7e
|
|
| MD5 |
de8f32a81e9e6dca5df3be77573d9839
|
|
| BLAKE2b-256 |
b4049e22c920df07a361ddfe1244dda2e2c5f99f465d896b1f9d5fe1784331f0
|
File details
Details for the file tsrkit_asm-0.1.0-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: tsrkit_asm-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 333.0 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03c05df5b7e7ddb9ff72b0f7592dde1cba614c2bd4f4ad61b6dd30b2d767ac03
|
|
| MD5 |
74fb1849512841735a833dd99f88fa98
|
|
| BLAKE2b-256 |
3516a9944f12956d5dfa175e9822fd84a939f93c60d4a4f23338062e19a148b6
|
File details
Details for the file tsrkit_asm-0.1.0-cp312-cp312-macosx_10_12_x86_64.whl.
File metadata
- Download URL: tsrkit_asm-0.1.0-cp312-cp312-macosx_10_12_x86_64.whl
- Upload date:
- Size: 338.7 kB
- Tags: CPython 3.12, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd5538ce6da68091f13c0c5d256fdb1c8c10554a05eaa12cea39f1ebde1971cb
|
|
| MD5 |
e4071ff5f17bd4d3e10648456b2e08ca
|
|
| BLAKE2b-256 |
1e440a62f7cb67f54c56deda74a53f16220124f48d3bceec8c96aa3858785d30
|