Skip to content
This repository

LLVM backend for dcpu-16 processor

branch: dcpu16

Merge pull request #194 from Blei/fix-register-size

Register sizes are in bits. Divide
latest commit ae6b01fecd
Philipp Brüschweiler Blei authored July 05, 2012
Octocat-spinner-32 autoconf Merge branch 'master' into dcpu16 July 04, 2012
Octocat-spinner-32 bindings [python] Add negative MemoryBuffer testcase March 22, 2012
Octocat-spinner-32 cmake Merge branch 'master' into dcpu16 July 04, 2012
Octocat-spinner-32 docs Document the llvm.fabs intrinsic. July 03, 2012
Octocat-spinner-32 examples Move llvm/Support/IRBuilder.h -> llvm/IRBuilder.h June 29, 2012
Octocat-spinner-32 include Merge branch 'master' into dcpu16 July 04, 2012
Octocat-spinner-32 lib Register sizes are in bits. Divide by 8. July 05, 2012
Octocat-spinner-32 projects Remove 'check-dg', a wrapper around 'check-local-dg' which was just June 28, 2012
Octocat-spinner-32 runtime Free the allocated filename. Found by clang static analyzer. June 15, 2012
Octocat-spinner-32 test Fix test failures. Currently, test/CodeGen/X86/early-ifcvt.ll fails, … July 04, 2012
Octocat-spinner-32 tools Merge branch 'master' into dcpu16 July 04, 2012
Octocat-spinner-32 unittests Merge branch 'master' into dcpu16 July 04, 2012
Octocat-spinner-32 utils Merge branch 'master' into dcpu16 July 04, 2012
Octocat-spinner-32 .gitignore Merge with LLVM upstream (build is broken now) May 11, 2012
Octocat-spinner-32 CMakeLists.txt Merge branch 'master' into dcpu16 July 04, 2012
Octocat-spinner-32 CREDITS.TXT Alphabetize. June 19, 2012
Octocat-spinner-32 LICENSE.TXT Add YAML parser to Support. April 03, 2012
Octocat-spinner-32 LLVMBuild.txt LLVMBuild: Introduce a common section which currently has a list of the December 12, 2011
Octocat-spinner-32 Makefile Do not install llvm-config-host for cross-builds of clang. rdar://113… May 09, 2012
Octocat-spinner-32 Makefile.common [docs] Remove unsupported references to ExtraSource variable. May 15, 2012
Octocat-spinner-32 Makefile.config.in Remove autoconf support for runtest and tclsh, some of the last vestigal June 27, 2012
Octocat-spinner-32 Makefile.rules Remove 'check-dg', a wrapper around 'check-local-dg' which was just June 28, 2012
Octocat-spinner-32 README.md DCPU16: Fixed small typo in the README.md May 16, 2012
Octocat-spinner-32 README.txt Testing commit access May 24, 2012
Octocat-spinner-32 configure Merge branch 'master' into dcpu16 July 04, 2012
Octocat-spinner-32 llvm.spec.in Tidy up. s/Low Level Virtual Machine/LLVM/. January 25, 2012
README.md

LLVM backend for DCPU-16

DCPU-16 is the processor from Mojang's new game 0x10c. This project has a goal to make a full-featured LLVM backend for DCPU-16 and port Clang to support this architecture.

Currently llvm backend and Clang support are nearly fully implemented.

Simple C SDK

You can download a simple C SDK, which includes clang with the binutils port for dcpu16. It is Makefile based and contains a very simple C test program to demonstrate how you can develop your own program.

Download

You can find different precompiled packages for linux here.

There is also a very simple build script, which will assemble all needed parts for building the SDK yourself.

Please, let us know, if it does not work for you.

Building

First, of all, you need to install prerequisites:

sudo apt-get install gcc g++ git subversion git-svn make\
 perl gawk expect tcl texinfo bison autoconf automake cmake

Note, that when your python executable points to python3 (you can check that by running python --version) you have to replace "cmake .." with "cmake -DPYTHON_EXECUTABLE=/path/to/python2 .." in the following steps (path is /usr/bin/python2 in most cases)

Next, get the sources and build it:

git clone git://github.com/llvm-dcpu16/llvm-dcpu16.git # Checkout LLVM
cd llvm-dcpu16/tools
git clone git://github.com/llvm-dcpu16/clang.git # Checkout Clang
mkdir ../cbuild
cd ../cbuild
cmake ..
make -j4

Using LLVM-DCPU16

Consider the following C file:

fib.c:

int fib(int n) {
  int cur = 1;
  int prev = 1;
  for (int i = 0; i < n; i++) {
    int next = cur+prev;
    prev = cur;
    cur = next;
  }
  return cur;
}

int main(void) {
  return fib(5);
}

Now, let's translate C to DCPU16 assembly:

bin/clang -ccc-host-triple dcpu16 -S fib.c -o fib.s

We generate DCPU16 v1.7 ASM with GAS compatible syntax. Most online assemblers won't work. Please use the binutils port for DCPU16 to assemble and link your program and then use an DCPU16 v1.7 compatible emulator to test your program.

Enjoy and, please, report bugs!

Something went wrong with that request. Please try again.