Close

C compiler, Assembler, Simulator source code

A project log for Kobold K2 - RISC TTL Computer

A 16 bit RISC computer with video display, from just a few TTL and memory chips. Online C compiler and simulator available.

roelhroelh 08/18/2020 at 15:250 Comments

Today 20200818 I uploaded the source code of the software to the files section. All files should be placed on a webserver.

Compiler.php is programmed in PHP and has two big sections:

  1. Convert C source code to syntax tree (in an array-based format, described in the same file).
  2. Convert the syntax tree to an Abstract Syntax Tree (AST) with standardized JSON format.

Generator.js is programmed in Javascript, and also has two big sections:

  1. Analyze the AST and do several optimizations.
  2. Generate assembly code for the Kobold K2 CPU. The generator also does optimizations and can call the analyzer to assist in optimizing.

Simas_k2.js is programmed in Javascript, and has also two big sections:

  1. The assembly code (in most cases coming from the generator) is assembled, resulting in machine code.
  2. The CPU can be simulated. The machine code can also be downloaded to the K2 CPU.

Index.php is programmed mainly in HTML. It provides the IDE display and edit functions and calls the previous sections if needed. 

Also included are a demo function, and a few manuals that can be activated in the IDE.

Discussions