Skip to content
C to Assembly Compiler and Interpreter https://ctoassembly.com
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
WebContent
src/main/java/com/ctoassembly/compiler
LICENSE
README.md
pom.xml

README.md

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!

You can’t perform that action at this time.