flat assembler
Message board for the users of flat assembler.
Index
> High Level Languages > [ANNOUNCE] PyFASM64: Python to Pure x86_64 FASM Native Compiler + FASM Modern SDK |
| Author |
|
|
eminsk 07 Nov 2026, 14:19
[ANNOUNCE] PyFASM64: Python to Pure x86_64 FASM Native Compiler + FASM Modern SDK
Hello FASM Community! I would like to present PyFASM64 (GitHub: eminsk/pyfasm | PyPI: pyfasm64) and the companion FASM Modern SDK (GitHub: eminsk/fasm-modern-sdk). PyFASM64 is an open-source native compiler that translates Python code directly into pure x86_64 Flat Assembler (FASM) source code, emitting tiny, self-contained standalone binaries with zero virtual machine and zero runtime overhead. Why FASM as the Backend? Instead of relying on heavy C runtimes, LLVM, or bloated intermediate representations, PyFASM leverages the unmatched speed, compactness, and elegance of Flat Assembler. The emitted code is clean, human-readable x86_64 FASM assembly adhering to official calling conventions and system ABIs. Key Features:
Code Example & Generated x86_64 FASM Assembly: Python source (fibonacci.py): Code: def fib(n: int) -> int: if n <= 1: return n return fib(n - 1) + fib(n - 2) def main(): result = fib(35) print("Fibonacci(35) =", result) if __name__ == "__main__": main() Emitted pure x86_64 FASM assembly (fibonacci.asm): Code: fib: push rbp mov rbp, rsp sub rsp, 48 ; shadow space + local frame mov [rbp - 8], rcx ; argument n mov rax, [rbp - 8] cmp rax, 1 setle al movzx rax, al test rax, rax jz .recurse mov rax, [rbp - 8] ; base case: return n jmp .epilog_fib .recurse: mov rax, [rbp - 8] dec rax mov rcx, rax ; argument n - 1 sub rsp, 32 call fib add rsp, 32 push rax mov rax, [rbp - 8] sub rax, 2 mov rcx, rax ; argument n - 2 sub rsp, 32 call fib add rsp, 32 mov r11, rax pop rax add rax, r11 ; fib(n - 1) + fib(n - 2) .epilog_fib: mov rsp, rbp pop rbp ret Compiling and benchmark result: Code: # Compile directly with bundled FASM: pyfasm compile fibonacci.py -o fibonacci.exe --target win64 # Execution benchmark: # CPython 3.12: 1586 ms # PyFASM Native: 95 ms (16.7x faster!) # Binary size: 9 KB standalone PE+ executable (no external dependencies) Links & Resources:
Feedback, ideas, and suggestions from fellow assembly and compiler developers are very welcome! |
|||
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2026, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.