Introduction¶
The ppci (pure python compiler infrastructure) project is a compiler written entirely in python.
The project contains:
- A compiler, an assembler, a linker and a build system
- Language front-ends: Brainfuck, c3
- Backends: 6500, arm, avr, msp430, ricv-v, x86_64
An example usage of the low level encoding api:
>>> from ppci.arch.x86_64 import instructions, registers
>>> i = instructions.Pop(registers.rbx)
>>> i.encode()
b'['
Another example:
>>> 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')
And yet another example:
>>> 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])
Warning
This project is in alpha state and not ready for production use!