Giter Club home page Giter Club logo

ctoassembly's Introduction

C to Assembly - Compiler and Interpreter

http://ctoassembly.com

C to Assembly is an online compiler of micro-C code (a subset of C large enough for demonstration) and interpreter of hypothetical Assembly (micro-C is compiled to hypothetical Assembly which looks a lot like x86 asm).

See docs here:

Repo structure

  • src/main/java/com/ctoassembly/compiler - Java compiler (micro-C to hypothetical-asm)
    • Yeah, yeah, yeah, I am not joking - Java is compiling c to asm.
    • mycc.lex - scanner written in Backus-Naur form.
    • mycc.cup - LR parser that defines the grammar. All the code generation is executed from here (when a rule is matched), so it's a good starting point for reading code.
  • WebContent - JavaScript/Angular assembly interpreter
    • ccode.html - compiling happens here.
    • js/angular/controller.js - angular controller backing up the ccode.html. It calls the servlet holding the compiler, presents the asm code and interprets (executes) it line by line.
    • js/cpu.js - that's the javascript CPU
    • js/asmmetamodel.js - all asm instructions and their execution strategy is encapsulated here
    • js/ui.js - ui support (drawing and such)
    • js/constants.js - CPU constants
    • js/util.js - util support for everything above
    • js/prototype.js - useful javascript extensions that I used throughout the code

Todos

  • Enlarge the subset of C that the compiler can compile
  • Fix bugs

License

Apache 2.0

Free Software, Hell Yeah!

ctoassembly's People

Contributors

darijanrijan avatar

Stargazers

Matouš Blažek avatar Cristian Marcial avatar Trung Nguyen avatar Gokul Adethya avatar Gerald Gehrke avatar Juliano Amadeu avatar Giorgi Koguashvili avatar Zhao Zuohong avatar  avatar Vadim Petrov avatar Ralph Caraveo avatar Burak Emir avatar

Watchers

 avatar

ctoassembly's Issues

local installation

Hi Darijan

thanks for that very nice and educative compiler. I would like to use your compiler for a home-built cpu (where I can define the machine code on my own via micro code), and the very simple x86-like machine code seems perfect for that. However, I need to modify some constants such as size of stack etc, so I need to toach your code and need to run it locally on my PC. I am not an expert in html and Java, but if I download your code and start ccode.html, it just does not start to compile. Not sure if some files are missing. Actually I dont need the html environment, maybe I just can input a text file (with c code) to your Java compiler.

I would be happy for any help, thanks a lot
Klaus

bit shift

The bit shift operator only ever shifts by one. It ignores the second argument.

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.