Coder Social home page Coder Social logo

jsdelivrbot / ppci-mirror Goto Github PK

View Code? Open in Web Editor NEW

This project forked from windelbouwman/ppci

0.0 1.0 0.0 11.42 MB

GIT Mirror of: A compiler for ARM, X86, MSP430, xtensa and more implemented in pure Python -->

Home Page: https://bitbucket.org/windel/ppci

License: BSD 2-Clause "Simplified" License

C 7.22% C++ 0.04% Python 88.62% HTML 0.01% JavaScript 0.07% Brainfuck 0.19% LLVM 0.36% Verilog 3.46% Assembly 0.01% Shell 0.03%

ppci-mirror's Introduction

Introduction

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

Warning

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

You can try out ppci at godbolt.org: https://godbolt.org/g/eooaPP

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:

gitter appveyor codecov docstate travis codacygrade codacycoverage downloads conda

ppci-mirror's People

Contributors

almarklein avatar jsdelivrbot avatar windelbouwman avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.