Coder Social home page Coder Social logo

dumb16-compiler's Introduction

Dumb compiler for Dumb SoC

Dumb compiler is a C compiler, assembler and disassembler for Dumb SoC.

C and assembly langages

You can build this kind of c files:

int fibo(int n);

int main(void) {
  int n = fibo(4);
  return 0;
}

int fibo(int n) {
  if (n == 0) {
    if (n == 1) {
      return 1;
    }
    return 0;
  }
  if (n == 1) {
    return 1;
  } else {
    return fibo(n - 1) + fibo(n - 2);
  }
}

You can assemble this kind of assembly file :

rom:
  afc r0, '-'
  afc r1, '-'
  afc r2, $loop_init
  afc r7, $0x0f00 // white style
  afc r8, $0x9f00 // blink style
loop_init:
  add r0, r0, r7
  add r1, r1, r8
  afc r12, $0x4fa0
  afc r11, $0x4000 // video memory
  afc r13, $0x2
  afc r14, $0x4100
  afc r15, $0x4120
loop_start:
  sub r10, r12, r11
  jmz *loop_end, r10
if:
  sub r10, r14, r11
  jmz *else, r10
then:
if2:
  sub r10, r15, r11
  jmz *else2, r10
then2:
  stp (r11), r0 // Write 'a' to the vga memory
  jmp *end_if2
else2:
  stp (r11), r1 // Write blink 'a' to the vga memory
end_if2:
  jmp *end_if
else:
  stp (r11), r1 // Write blink 'a' to the vga memory
end_if:
  add r11, r11, r13
  jmp *loop_start
loop_end:

Workflow

The worklow is as follows:

        ------------          -------------
C in -> | Compiler | -> As -> | Assembler | -> Bin out
        ------------          -------------

Have fun !

dumb16-compiler's People

Contributors

bntmorgan avatar

Watchers

James Cloos avatar  avatar

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.