High-Performance Runtime Assembler for Python
JIT Compilation • x86_64 & ARM64 • Virtual Memory
Runtime assembly compilation and execution with native performance. Write assembly code and execute it instantly.
Full support for both x86_64 and aarch64 (ARM64) architectures with automatic detection.
10MB simulated memory space for data manipulation with full read/write capabilities.
Load and save binary files directly to/from memory with seamless integration.
Built with Rust and PyO3 for maximum performance while maintaining Python simplicity.
# Install via pip pip install tigerasm # Or build from source git clone https://github.com/yourusername/tigerasm cd tigerasm pip install maturin maturin develop --release
from tigerasm import TigerASM # Create assembler instance asm = TigerASM() asm.setup("x86_64") # Write assembly code asm.asm(""" mov rax, 42 add rax, 8 ret """) # Execute and get result asm.execute() print(f"Result: {asm.get('rax')}")
Calculate (10 + 20) × 3 using assembly instructions
from tigerasm import TigerASM asm = TigerASM() asm.setup("x86_64") # Calculate (10 + 20) * 3 asm.asm(""" mov rax, 10 add rax, 20 mov rbx, 3 imul rax, rbx ret """) asm.execute() print(f"Result: {asm.get('rax')}") # Output: Result: 90
Sum numbers from 1 to 10 using a loop structure
asm = TigerASM() asm.setup("x86_64") # Sum numbers 1 to 10 asm.asm(""" mov rax, 0 ; sum accumulator mov rcx, 1 ; counter loop_start: add rax, rcx ; add counter to sum inc rcx ; increment counter cmp rcx, 11 ; compare with 11 jl loop_start ; jump if less than ret """) asm.execute() print(f"Sum 1-10: {asm.get('rax')}")
Read and manipulate data stored in virtual memory
asm = TigerASM() asm.setup("x86_64") # Write data to memory asm.write_mem(0x1000, 42, 8) asm.write_mem(0x1008, 58, 8) # Set base address register asm.mov("rax", 0x1000) # Read and sum values from memory asm.asm(""" mov rbx, [rax] ; Load first value mov rcx, [rax + 8] ; Load second value add rbx, rcx ; Sum them mov rax, rbx ; Return in rax ret """) asm.execute() print(f"Sum: {asm.get('rax')}")
Calculate the length of a null-terminated string in memory
asm = TigerASM() asm.setup("x86_64") # Write string to memory text = b"Hello, TigerASM!\x00" asm.write_bytes(0x2000, text) # Count string length asm.asm(""" mov rsi, 0x2000 ; String address xor rax, rax ; Length counter count_loop: mov bl, [rsi + rax] ; Load byte test bl, bl ; Check if zero jz done ; Exit if zero inc rax ; Increment counter jmp count_loop done: ret """) asm.execute() print(f"String length: {asm.get('rax')}")
Perform bit manipulation and shift operations
asm = TigerASM() asm.setup("x86_64") asm.asm(""" mov rax, 0b11110000 mov rbx, 0b10101010 and rax, rbx ; AND operation or rax, 0b00001111 ; OR with mask mov rax, 1 shl rax, 4 ; Shift left by 4 (multiply by 16) ret """) asm.execute() print(f"Result: {asm.get('rax')}") print(f"Binary: {bin(asm.get('rax'))}")
Load a binary file and calculate its checksum
asm = TigerASM() asm.setup("x86_64") # Load binary data bytes_loaded = asm.load_binary_file("input.bin", 0x10000) # Calculate checksum asm.asm(f""" mov rsi, 0x10000 ; Data address mov rcx, {bytes_loaded} ; Byte count xor rax, rax ; Checksum accumulator checksum_loop: test rcx, rcx jz checksum_done mov bl, [rsi] ; Load byte add rax, rbx ; Add to checksum inc rsi dec rcx jmp checksum_loop checksum_done: ret """) asm.execute() checksum = asm.get('rax') print(f"Checksum: {checksum:#x}")
Calculate the nth Fibonacci number using recursion
asm = TigerASM() asm.setup("x86_64") # Calculate 10th Fibonacci number iteratively asm.asm(""" mov rcx, 10 ; n = 10 mov rax, 0 ; fib(0) mov rbx, 1 ; fib(1) cmp rcx, 0 je done fib_loop: dec rcx cmp rcx, 0 je done mov rdx, rax ; temp = fib(n-2) mov rax, rbx ; fib(n-2) = fib(n-1) add rbx, rdx ; fib(n-1) = fib(n-1) + fib(n-2) jmp fib_loop done: mov rax, rbx ret """) asm.execute() print(f"Fibonacci(10): {asm.get('rax')}")
Find the maximum value in an array stored in memory
asm = TigerASM() asm.setup("x86_64") # Create array in memory array = [5, 12, 7, 23, 9, 15, 3, 18] for i, val in enumerate(array): asm.write_mem(0x3000 + i * 8, val, 8) # Find maximum value asm.asm(f""" mov rsi, 0x3000 ; Array address mov rcx, {len(array)} ; Array length mov rax, [rsi] ; Initialize max with first element find_max: dec rcx cmp rcx, 0 je max_done add rsi, 8 ; Move to next element mov rbx, [rsi] ; Load element cmp rbx, rax ; Compare with max jle find_max ; Skip if not greater mov rax, rbx ; Update max jmp find_max max_done: ret """) asm.execute() print(f"Maximum value: {asm.get('rax')}")
Build a basic JIT compiler that compiles and executes mathematical expressions at runtime
from tigerasm import TigerASM class SimpleJIT: def __init__(self): self.asm = TigerASM() self.asm.setup("x86_64") def compile_expression(self, expr): # Simple expression parser: "a + b * c" # Supports: +, -, *, with operator precedence tokens = expr.replace('(', '').replace(')', '').split() self.asm.clear() code = [] # Simple RPN (Reverse Polish Notation) evaluator # Convert: "2 + 3 * 4" -> handles precedence if '*' in tokens: # Handle multiplication first (precedence) idx = tokens.index('*') left = int(tokens[idx-1]) right = int(tokens[idx+1]) code.append(f"mov rax, {left}") code.append(f"mov rbx, {right}") code.append("imul rax, rbx") # Handle remaining addition if idx > 1 and tokens[idx-2] == '+': first = int(tokens[0]) code.append(f"add rax, {first}") else: # Simple addition/subtraction num1 = int(tokens[0]) op = tokens[1] num2 = int(tokens[2]) code.append(f"mov rax, {num1}") if op == '+': code.append(f"add rax, {num2}") elif op == '-': code.append(f"sub rax, {num2}") code.append("ret") self.asm.asm('\n'.join(code)) def execute(self): self.asm.execute() return self.asm.get('rax') # Usage example jit = SimpleJIT() # Compile and execute: 5 + 3 * 4 = 17 jit.compile_expression("5 + 3 * 4") print(f"Result: {jit.execute()}") # Compile different expression: 100 - 25 = 75 jit.compile_expression("100 - 25") print(f"Result: {jit.execute()}")
TigerASM is built with cross-platform compatibility in mind, supporting multiple architectures and operating systems for maximum flexibility.
Complete support for Intel and AMD 64-bit processors with full instruction set implementation.
Native support for ARM 64-bit architecture, perfect for Apple Silicon and ARM servers.
Intel Core, AMD Ryzen, Apple M-series
x86_64 and ARM64 laptops, MacBooks
AWS, Azure, GCP, DigitalOcean
Data center x86_64 and ARM64 servers
Raspberry Pi 4/5, NVIDIA Jetson
Docker, Kubernetes, LXC
For building from source, you'll need the following tools:
Install via: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
PyO3 build tool for Rust-Python bindings
Required for linking native code
Included with most Python installations
Intel Core i5+ or AMD Ryzen 5+
Native ARM64 compilation
AWS EC2, Azure VM, GCP Compute
Raspberry Pi 4/5
pip install tigerasmpip install tigerasmpip install tigerasmpip install tigerasmpip install tigerasmFind answers to common questions about TigerASM, installation, usage, and troubleshooting.
TigerASM is a high-performance runtime assembler for Python that allows you to write and execute assembly code directly in your Python programs. It supports both x86_64 and ARM64 architectures with JIT (Just-In-Time) compilation, virtual memory management, and full register control.
TigerASM is ideal for:
TigerASM is stable and well-tested for x86_64 and ARM64 architectures. However, as with any low-level tool, thorough testing in your specific use case is recommended. It's currently best suited for performance optimization, educational projects, and prototyping rather than safety-critical applications.
TigerASM is unique because it:
Installation is simple via pip:
For building from source:
Minimum:
Recommended: 4+ core CPU, 2 GB RAM, Python 3.10 or 3.11
TigerASM supports:
Yes! TigerASM works perfectly with virtual environments:
TigerASM auto-detects your architecture by default. You can explicitly set it:
Use asm.get_arch() to check the current architecture.
TigerASM supports a comprehensive instruction set including:
See the Instructions section for the complete list.
TigerASM provides 10 MB of virtual memory (10,485,760 bytes) for your programs. This is sufficient for most use cases. You can:
alloc()read_mem() and write_mem()Yes! TigerASM provides several debugging tools:
dump_regs() - Display all register valuesget(register) - Check specific register valuesread_mem() - Inspect memory contentsget_arch() - Verify architectureYou can also print intermediate values and step through execution by breaking your code into smaller segments.
TigerASM is very fast:
Performance is comparable to hand-written C/C++ for the assembly portions.
This error occurs if you're not on x86_64 or ARM64. TigerASM only supports 64-bit architectures. Check your system:
Should output: "x86_64", "AMD64", "arm64", or "aarch64"
Common issues:
ret instructionThis happens when accessing memory outside the 10MB range:
memory_size() to verify boundsalloc() for safe memory allocationIf building from source fails:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shrustup updatesudo apt install build-essentialxcode-select --installFloating-point support is not currently implemented. TigerASM focuses on integer operations. For floating-point math, use Python's native capabilities or libraries like NumPy alongside TigerASM.
Direct calls are not supported, but you can:
Check out Example 9 (Simple JIT Compiler) in the Examples section! The basic approach:
asm.asm() to load the codeexecute() to run itEach TigerASM instance is independent. For multi-threaded use:
Yes! Use the install() method:
Note: The saved file is platform-specific and may not be directly executable outside TigerASM.
Support channels:
Absolutely! Contributions are welcome:
TigerASM is released under the MIT License. You can use it freely in personal and commercial projects, with attribution.
Community channels are being set up! Check the GitHub repository for the latest links to Discord, Slack, or other community platforms.
Can't find what you're looking for? Reach out to us!