Skip to main content

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.

Release files for tsrkit-asm 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tsrkit-asm 0.1.0
File Size Uploaded
tsrkit_asm-0.1.0.tar.gz 33.9 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for tsrkit-asm 0.1.0
File
tsrkit_asm-0.1.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
tsrkit_asm-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details
tsrkit_asm-0.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ ARM64 Details
tsrkit_asm-0.1.0-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
tsrkit_asm-0.1.0-cp312-cp312-macosx_10_12_x86_64.whl CPython 3.12 CPython 3.12 macOS 10.12+ x86-64 Details

Total release size: 1.7 MB

Release files / tsrkit_asm-0.1.0.tar.gz

Download URL tsrkit_asm-0.1.0.tar.gz
Size 33.9 kB
Tags Source
SHA-256 checksum
How to use checksums
1495d47c3560d5cfb23a23dc463b96f9df7e1eb071ccedc555658f0a48c35e8f
BLAKE2b-256 checksum
How to use checksums
398d38bb6a757d1fcc44950772c5f52ad595543055dec657dbe1483dbf58dd09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / tsrkit_asm-0.1.0-cp312-cp312-win_amd64.whl

Download URL tsrkit_asm-0.1.0-cp312-cp312-win_amd64.whl
Size 221.3 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
783ebc4a2a16a31b26aa895f03d0684fd04ebda957197a383a9251af1207336a
BLAKE2b-256 checksum
How to use checksums
a2e65ff6035a4c0a4e8823cc946dd3cc31b13eead269f2ffa13612136071b865
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / tsrkit_asm-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL tsrkit_asm-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 375.6 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
fb6cfdc76799eddf7d70a419a9b0bb1a09af72a2eb5b1a7bdd59e8ec9f48b42e
BLAKE2b-256 checksum
How to use checksums
bf386358904ca844d85265667775241cb27ae5307601b4d930e9d9f7e196d95d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / tsrkit_asm-0.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL tsrkit_asm-0.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 377.3 kB
Tags CPython 3.12 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
d44aab1975cc8f8c1cb3b451bd88f59dd0575e8a194b4fa341149e300a4f8a7e
BLAKE2b-256 checksum
How to use checksums
b4049e22c920df07a361ddfe1244dda2e2c5f99f465d896b1f9d5fe1784331f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / tsrkit_asm-0.1.0-cp312-cp312-macosx_11_0_arm64.whl

Download URL tsrkit_asm-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Size 333.0 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
03c05df5b7e7ddb9ff72b0f7592dde1cba614c2bd4f4ad61b6dd30b2d767ac03
BLAKE2b-256 checksum
How to use checksums
3516a9944f12956d5dfa175e9822fd84a939f93c60d4a4f23338062e19a148b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / tsrkit_asm-0.1.0-cp312-cp312-macosx_10_12_x86_64.whl

Download URL tsrkit_asm-0.1.0-cp312-cp312-macosx_10_12_x86_64.whl
Size 338.7 kB
Tags CPython 3.12 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
bd5538ce6da68091f13c0c5d256fdb1c8c10554a05eaa12cea39f1ebde1971cb
BLAKE2b-256 checksum
How to use checksums
1e440a62f7cb67f54c56deda74a53f16220124f48d3bceec8c96aa3858785d30
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

0.1.0 This release

6 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page