DCPU assembler, linker, emulator, debugger and profiler.
Go JavaScript Other
Switch branches/tags
Nothing to show
Latest commit 955d4a6 Jun 1, 2013 @jteeuwen Fixes some minor bugs.
Failed to load latest commit information.



This repository contains DCPU utilities and code. Among wich are a parser, assembler and linker for a custom DCPU assembly language. Along with a graphical emulator/debugger/profiler.

The toolchain defined in this project, closely mimics the build setup for the Go programming language. The Assembly source itself borrows a number of aspects from Go. E.g.: the way it defines packages and imports.

For more information about the language itself, refer to parser/LANGUAGE.md. For examples, refer to the standard library code at: github.com/jteeuwen/dcpulib

Click here for a screenshot of the running emulator.

Commandline tools

  • dcpu-emu: This is a graphical emulator with all known hardware components implemented. It doubles as a debugger and code profiler.
  • dcpu-asm: Commandline assembler. Compiles source into package archives.
  • dcpu-link: Commandline linking tool. Combines package archives into executable programs for the DCPU.
  • dcpu-list: The list command lists all availale packages under the given import paths.
  • dcpu-deps: The deps command lists all dependencies for the given packages.
  • dcpu-ar: The ar command performs various operations on compiled archives.


  • parser: Lexer and AST parser for the assembly language.
  • archive: File format definition for compiled package archives.
  • asm: Defines an assembler which turns an AST into a compiled package archive.
  • path: The path package exposes functions to perform common operations on import paths.

Misc stuff

  • dcpu.lang: This file is a DCPU syntax file for GtkSourceView compatible editors (like Gedit). It should be installed in the language-specs directory. For me this is at: /usr/share/gtksourceview-3.0/language-specs/.
  • fontedit: This is an HTML5-based font editor for LEM1802 fonts.

Refer to the README of each individual tool for more info.


$ go get github.com/jteeuwen/dcpu/...

The commandline programs will be installed where ever your $GOBIN points to.

All DCPU tools in this repository operate within the directory pointed to by the $DCPUROOT environment variable. This must therefore be set before using the tools:

export DCPUROOT=$HOME/dcpu

Refer to ENV.md for more information on $DCPUROOT.

All DCPU source code, compiled packages and binaries will live in this directory. The behaviour of all this very similar to that of the Go tool chain.

DCPU source code must be placed in $DCPUROOT/src. All compiled packages will be placed in $DCPUROOT/pkg and the linked programs are placed in $DCPUROOT/bin. The directory structure you use in $DCPUROOT/src, must reflect the import path for your package. Again, this mimics the way the Go tool chain behaves.

For example, a package with the import path dcpu/lem1802 has its source located in $DCPUROOT/src/dcpu/lem1802. Once compiled, its archive is located at $DCPUROOT/pkg/dcpu/lem1802.a. It can be imported in your DCPU programs with the following import statement:

import "dcpu/lem1802"

Refer to PACKAGE.md for more information on import paths.

All test cases in this repository, refer to DCPU assembly in an external repository. The code from this repository must be placed in your $DCPUROOT. This is not an ideal situation, but I much prefer to keep the DCPU code separated from this repository. It can be acquired as follows:

git clone https://github.com/jteeuwen/dcpulib.git

Apart from test code, it contains a rudimentary standard code library we can use in our DCPU programs.


An example for compiling & running a program is as follows: This assumes the existence of package sources in $DCPUROOT/src/test/hw/.

$ dcpu-asm test/hw    # Assemble package test/hw and dependencies.
$ dcpu-link test/hw   # Link package test/hw into an executable.
$ dcpu-emu test/hw    # Run test/hw on the emulator.

An even simpler approach is to just call the emulator with the target path. The emulator knows how to rebuild code when necessary. In fact, the emulator can reload sources at runtime. This allows us to modify programs, while not having to restart the emulator every time.

$ dcpu-emu test/hw    # Run test/hw on the emulator.


The emulator depends on the following packages:

go get github.com/go-gl/gl
go get github.com/go-gl/glfw
go get github.com/go-gl/glh
go get github.com/nsf/termbox-go
go get github.com/nsf/tulib
go get github.com/jteeuwen/keyboard/termbox
go get github.com/jteeuwen/linewrap


DCPU, 0x10c and related materials are Copyright 2012 Mojang.

Unless otherwise stated, all of the work in this project is subject to a 1-clause BSD license. Its contents can be found in the enclosed LICENSE file.