This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

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
  • Backends: 6500, arm, avr, msp430, risc-v, stm8, x86_64, xtensa

Warning

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

Api

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
bytearray(b'[ARH\xbf*\x00\x00\x00\x00\x00\x00\x00')

Example of the low level api usage:

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

Documentation

Documentation can be found here:

Release History

Release History

This version
History Node

0.5.3

History Node

0.5.2

History Node

0.5.1

History Node

0.5

History Node

0.4.0

History Node

0.3.0

History Node

0.2.0

History Node

0.1.0

History Node

0.0.5

History Node

0.0.4

History Node

0.0.3

History Node

0.0.2

History Node

0.0.1

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
ppci-0.5.3-py3-none-any.whl (348.7 kB) Copy SHA256 Checksum SHA256 3.6 Wheel Apr 27, 2017
ppci-0.5.3.tar.gz (322.5 kB) Copy SHA256 Checksum SHA256 Source Apr 27, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting