Skip to content

glouw/c8c

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Screenshot

c8c aims to be a small typeless programming language for the CHIP-8 virtual machine:

r = { 0x80, 0x40, 0x20, 0x10 };
l = { 0x20, 0x40, 0x80, 0x10 };

main()
{
    auto x = 0, xmax = 64, dx = 4;
    auto y = 0, ymax = 32, dy = 4;
    while(y < ymax)
    {
        if(rand() & 0x1)
        {
            draw(x, y, r);
        }
        else
        {
            draw(x, y, l);
        }
        if((x += dx) == xmax)
        {
            x = 0;
            y += dy;
        }
    }
    while(1)
    {
        // Never leave main.
    }
}

Screenshot

mul(a, b)
{
    if(b == 0)
    {
        return 0;
    }
    return a + mul(a, b - 1);
}

main()
{
    putchar(24, 13, mul(9, 9));
    while(1)
    {
        // Never leave main.
    }
}

Screenshot

Just run:

make

This will build the CHIP-8 virtual machine, binner, assembler, and compiler. The compiler will then build all the unit tests (tc8c) and example code pieces (examples).

To run a compiled binary, invoke the virtual machine:

./emu examples/maze.bin

Hit the END key to exit.

To build your own c8 code, piecewise invoke the toolchain:

./c8c main.c8 main.asm

./asm main.asm main.hex

./bin main.hex main.bin

./emu main.bin