By Pierre Sarrazin

CMOC is a 6809-generating cross-compiler for a subset of the C language. It produces assembler code for the Motorola 6809 processor in the Color Computer .BIN format, as well as the Motorola SREC. and Vectrex formats It runs under GNU/Linux and other Unix-like environments. It requires the LWTOOLS assembler (lwasm) and linker, by William Astle.

The most significant difference between CMOC and a complete C compiler is the absence of bit fields. Floats are only usable under Color Basic. CMOC does not come with the complete Standard C library, only with a few functions that serve as a starting kit.

CMOC is free software distributed under the GNU General Public License, version 3 or later, except for the files of the USim simulator, which is used for testing.

The current version is 0.1.55. It was released on 2018-10-14.

Release notes for 0.1.55:

Release notes for 0.1.54:

  • The compiler now tolerates the use of NULL (e.g., (void *) 0) in contexts that expect a non-void pointer, e.g., int *p = NULL;
  • Additional optimizations of unsigned byte multiplications.
  • Added new function setPmodeGraphicsAddressEx(), which allows the caller to change the screen buffer address for pcls() without changing the currently displayed screen.

Release notes for 0.1.53:

  • Fixed an OS-9 extern array problem by fixing the way the compiler determines if a variable can go to the read-only section or not.
  • Added functions pmode(), screen(), rgb() and cmp() to the library that ships with CMOC. Function pcls() now takes only one argument.
  • Fixed the output format for Vectrex so that the resulting file is the loadable binary, with the proper header.

Release notes for 0.1.52:

  • Binary literals (e.g., 0b101010 for 42). Note that this feature is not part of Standard C.
  • Bit fields are now accepted by the compiler, but each field is allocated as a full char, int or long.
  • The manual now documents how to include an arbitrary binary file in the executable. (See the section "Merging a binary file with the executable".)
  • Several minor bug fixes. (See the NEWS file for details.)

Release notes for 0.1.51:

  • Fixed a bug that prevented defining a const long or real global with an initializer.
  • Fixed the determination of which globals go in the rodata section, in order to allow const arrays of function pointers.
  • Added command-line option --no-relocate to tell the compiler to assume that the program will only be loaded at the addresses specified by --org and --data. Not compatible with OS-9.
  • disk.h: Fixed the documentation of close(). Fixed the interface of getFileLength() and computeFileLength() so that they can return the file length in bytes.

I can be contacted (in French or English) at sarrazip at sarrazip dot com. (Questions regarding Vectrex-specific issues should be addressed to Johan Van den Brande.)



See MD5, SHA1 and SHA512 for signatures of these and other files.

Sample programs

decbfile (0.1.1) (Public domain)

Library that offers read/write access to files on a floppy disk in the Disk Basic format.

BGraph (0.1.0) (Public domain)

Graphics library that offers functions similar to Basic's LINE, DRAW and PAINT commands.

BSound (0.1.0) (Public domain)

Library that offers a function similar to Basic's PLAY command.

Color Eights (0.1.9) (GPLv3)

A card game derived from Crazy Eights that I wrote with CMOC. Uses the Cardgame library (see below).

Cardgame (0.1.7) (Public domain)

A card game library. Contains the generic code used by my Color Eights game: drawing and erasing cards (32x42 pixels), and drawing text (uppercase 32x24 grid), in a PMODE 4 screen. Beep and "white noise" functions. Rename cardgame.c to something else, fill main() and code other functions. The 8x8 text font can be reused independently, as done by cc3dblb (see below).

cc3dblb (0.1.1) (Public domain)

A skeleton for a CoCo 3 double-buffering game. Start a new game project by renaming the files, then recode the onFlip() function. Uses the 8x8 text font from the Cardgame library to print text on the graphics screen. Requires Cardgame and BGraph (see above).

DwTerm (by Michael Furman)

A DriveWire 4 Terminal Program for the Disk Basic environment. Can be used with other DriveWire-related programs written by Michael.

CoCo MiniLisp (by Jamie Cho)

A port of Rui Ueyama's MiniLisp. Version 0.5.0, released in October 2017, uses CMOC's support for 32-bit arithmetic.

xdaliclock port (by Jamie Cho)

A port of Jamie Zawinski's xdaliclock to the CoCo.

Splinter (by Jamie Cho)

A CoCo 3 break-the-bricks video game written by Jamie Cho with CMOC. Splinter features colorful 320x192 graphics and smooth animation.

hirestxt: 51x24 text screen (0.3.0) (Public domain)

A library that redirects printf() to a software 51x24 black-on-green PMODE 4 text screen. (A sample program is included.) Optionally supports several VT52 terminal sequences (disable this with #define HIRESTEXT_NO_VT52). Useful to get true lowercase, including Latin-1 accented characters, on all CoCos.

Color Verbiste (0.1.5) (GPLv3)

A partial CoCo port of my French conjugator. Requires hirestxt. There is a precompiled disk image. Details on the Verbiste home page and its CoCo section.

nobasic (0.1.8) (Public domain*)

A program that puts the CoCo in all-RAM mode, overwrites the Basic interpreter, moves the program and the stack to the end of the 64K of RAM and redirects the 60 Hz interrupt, as an example of a program that can use the entire 64K of RAM. Contains a disk sector read demo and a CoCo 3 graphics demo. This version requires CMOC 0.1.51 or later, as it is split in two C files (nobasic.c and dskcon.c) and uses the const keyword. *Some code in dskcon.c comes from DECB.

autostart.c (0.1.2) (Public domain)

A program to be compiled as a boot loader that goes on track 34, so that the CoCo's DOS command will execute it. (The autostart.bin file is not meant to be loaded with LOADM.) The program feeds Color Basic's console input with the command RUN"*.BAS" in order to run that Basic program automatically. Install this on a disk image with this command: install-coco-boot-loader foo.dsk autostart.bin

FuncPlot (0.2.2) (GPLv3)

Demo program that plots a mathematical function in PMODE 4 graphics. The program implements an expression parser and an RPN interpreter to evaluate the user's function across an interval. Requires hirestxt.

Demo of Basic variable access from a CMOC program (Public domain)

(Updated 2018-04-03.) This archive contains a .dsk image file that contains VARPTR.BAS and VARPTR.BIN. Type RUN"VARPTR" on a CoCo. The archive also contains the C source file, which is compilable under CMOC. The Basic and C listings can be studied to learn how to access Basic variables from a CMOC binary.

parse-coco-bin (Public domain)

A Perl script that lists the blocks of a CoCo Disk Basic .BIN file, along with the entry point.

Bouncy Ball (by Lee Patterson)

A game for all CoCos. (It does not come with the source code.)

CoCoTair: an 8080 emulator (by Mark Sherman)

This was Mark's Retrochallenge in 2017. This emulator can be used to run Altair BASIC.


See the manual that comes with CMOC.

As of January 2018, I am developing CMOC on an Ubuntu 14.04 GNU/Linux system using GCC 4.8.4.

Building on Mac OS X 10.10

The configure script should recognize that it is running on a Mac OS X system, but if it does not, the following instructions may help.

Thanks to Jamie Cho for these Mac instructions.

Glen Hewlett has posted an article on his blog about using CMOC from Mac OS or Linux.

Other resources

Last update to this page: 2018-10-16 20:41:33 EST5EDT