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
For examples, refer to the standard library code at:
Click here for a screenshot of the running emulator.
- 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.
- 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:
- 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
$DCPUROOT environment variable. This must therefore be set before
using the tools:
Refer to ENV.md for more information on
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
$DCPUROOT/bin. The directory structure you use in
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
$DCPUROOT/src/dcpu/lem1802. Once compiled, its archive is located
$DCPUROOT/pkg/dcpu/lem1802.a. It can be imported in your DCPU programs
with the following import statement:
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
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
$ 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.