Skip to content

Blecki/DCPUB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ceb330a · Sep 23, 2017
Sep 23, 2017
Sep 23, 2017
Sep 23, 2017
Feb 2, 2016
Apr 6, 2012
Apr 6, 2012
Feb 2, 2016
Feb 2, 2016
May 5, 2016
Feb 3, 2016
Apr 11, 2012
Mar 17, 2016
Feb 8, 2013

Repository files navigation

DCPUB

DCPUB is a language similar to B. This compiler targets the 1.7 DCPU-16 specification.

Features

  • A straight forward language with familiar C-like syntax.
  • Predictable and effecient assembly generation.
  • Top-level code. Execution of a DCPUB program begins at the top of the file, not in an arbitrary main function. This allows library code to initialize static variables without resorting to hacks to insert code at program start.
  • Separate preprocessor. The preprocessor is a separate executable. You can choose to invoke it or not, and you can modify its output before you compile it.
  • A minimalist standard library including display and keyboard abstractions, a memory allocator, and a basic implementation of printf.
  • Peephole optimizations. Supply the '-peepholes definition-file' switch to the compiler to enable peephole optimizations with a definition file you supply. A basic definition file is included in the binary release.

Installation

Download Latest Version

Included in this archive:

  • DCPUB Compiler
  • DCPUB Preprocessor
  • Sample code

On Linux and Mac, install Mono and prepend all commands with mono.

Building from Source

DCPUB is written in C#, and may be built with Microsoft.NET on Windows, or Mono on Linux/Mac.

MS.NET: Add Microsoft.NET to your %PATH% and run msbuild from the root of the repository.

Mono: Run xbuild from the root of the repository.

Usage

b - Compiler

Compiles DCPUB source to assembly or machine language.

b [flags] in-file [out-file]

Flags:

  • -b --binary : Emit a binary, machine-language file. If not supplied, emit unassembled DCPU assembly.
  • -be --big-endian : Emit in big endian. Only valid if paired with -binary. If not supplied, binary output will be in little endian.
  • (-p | --peepholes) filename : Specify a peephole definition file.
  • (-in | --input-file) filename : Specify the file to be compiled. If used, don't include input file at end of arguments.
  • (-out | --out-file) filename : Specify the file to write the compiled program to. If not present, default is 'input.bin' or 'input.dasm' depending on presence of --binary switch.

pre - Preprocessor

Expands macros and file inclusions

pre input.b output.b

pre has no switches or options.

Preprocessor directives will cause errors in the compiler. If they are used in the program, it must be preprocessed first.

Getting help

If you find bugs, need assistance, or otherwise encounter trouble, feel free to make an issue on GitHub.