Skip to content

oskar2517/logisim-compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logisim Compiler

Compiler for a simple programming language designed to run on my CPU made with Logisim evolution.

Example

Implementation of the insertion sort algorithm:

var arr:5;
arr[0] = 4;
arr[1] = 23;
arr[2] = 1;
arr[3] = 7;
arr[4] = 12;

var len;
len = 5;

var r;
var j;
var i;
var x;
i = 1;
while i < len {
    x = arr[i];
    j = i - 1;

    r = 0;
    if j > -1 {
        if arr[j] > x {
            r = 1;
        }
    }

    while r == 1 {
        arr[j + 1] = arr[j];
        j = j - 1;

        r = 0;
        if j > -1 {
            if arr[j] > x {
                r = 1;
            }
        }
    }

    arr[j + 1] = x;

    i = i + 1;
}

i = 0;
while i < len {
    show arr[i];

    i = i + 1;
}
demo.mp4

Retargetting the code generator

The code generator can be retargetted by modifying CompilerVisitor.hx. It implements the visitor pattern.

About

Compiler for my Logisim CPU

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages