Skip to main content

A compiler for ARM, X86, MSP430, xtensa and more implemented in pure Python

Project description

The ppci (pure python compiler infrastructure) project is a compiler written entirely in python. It contains language front-ends as well as machine code generation functionality. With this library you can generate (working!) machine code within python!

The project contains the following:

  • A Compiler, an assembler, a linker and a build system
  • Language front-ends: Brainfuck, c3, C, WASM
  • Backends: 6500, arm, avr, msp430, openrisc, risc-v, stm8, x86_64, xtensa


This project is in alpha state and not ready for production use!

You can try out ppci at


Api example to compile c3 code:

>>> import io
>>> from ppci.api import c3c, link
>>> source_file = io.StringIO("""
... module main;
... function void print(string txt) {
... }
... function void main() {
...  print("Hello world");
... }""")
>>> obj = c3c([source_file], [], 'arm')
>>> obj = link([obj])

Example how to assemble some assembly code:

>>> import io
>>> from ppci.api import asm
>>> source_file = io.StringIO("""section code
... pop rbx
... push r10
... mov rdi, 42""")
>>> obj = asm(source_file, 'x86_64')
>>> obj.get_section('code').data

Example of the low level api usage:

>>> from ppci.arch.x86_64 import instructions, registers
>>> i = instructions.Pop(registers.rbx)
>>> i.encode()


Documentation can be found here:

gitter appveyor codecov docstate travis codacygrade codacycoverage downloads conda

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for ppci, version 0.5.6
Filename, size File type Python version Upload date Hashes
Filename, size ppci-0.5.6-py3-none-any.whl (641.6 kB) File type Wheel Python version 3.7 Upload date Hashes View hashes
Filename, size ppci-0.5.6.tar.gz (452.5 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page