Compiling C programs for the old Radio Shack TRS-80 Color Computer running under RSDOS using MacOS or Linux

Below I will explain how to easily setup an environment for compiling C language programs and executing them on a TRS-80 Color Computer.

After compiling the latest MAME on my Raspberry Pi I started getting into retro computing.  This led me back to using MAME to emulate my favourite old computer the TRS-80 Color Computer (also known as the CoCo).  I thought maybe I could port some newer games to it and thought it would be neat to use C on the CoCo.  The CoCo has had ‘C’ under OS-9 but I’ve never really enjoyed OS-9 like I did RSDOS.  RSDOS is where I learned to program BASIC and assembly and that was what I enjoyed most about my CoCo.

I’ve dabbled with ‘C’ language for years but can’t wrap my head around the structured format especially arrays and pointers.  But I think playing with them and seeing how the code runs on my CoCo will give me an added incentive to finally grasp ‘C’.  At least that’s the plan…

I learned that there is a ‘C’ compiler called CMOC written by Pierre Sarrazin that actually takes ‘C’ source code and compiles it and the output can be executed on a CoCo under RSDOS.  CMOC can compile code for other 6809 environments but it is geared towards the CoCo.  The latest update was only a month ago so Pierre is still actively improving the compiler even though it is already quite complete.

I have setup a nice little compiling environment on my Mac that I will explain how to replicate below.  This environment makes it easy to write ‘C’ programs and execute them on MAME emulating a CoCo under RSDOS.

The steps below should work similarly for Linux, but this is how I setup my Mac.

-Compile MAME and make sure it includes the TOOLs so you will be able to manipulate computer disk images with the command imgtool.

-Copy mame and imgtool to your /usr/local/bin/ folder (so they can be executed from anywhere on your computer.)

cp mame /usr/local/bin/
cp imgtool /usr/local/bin/

Get the latest CMOC
Download the latest version of CMOC from Pierre’s website
As of this writing it is cmoc-0.1.33.tar.gz
Uncompress the file and install:

tar zxvf cmoc-0.1.33.tar.gz
cd cmoc-0.1.33
export CPPFLAGS="-D__unix"
export LDFLAGS="-framework CoreFoundation"
make install

It will now be installed into your commands path on the Mac this is /usr/local/bin/cmoc The header “.h” files will be installed in the folder /usr/local/share/cmoc

Next we install LWTOOLS. To get the latest version use Mercurial on Mac install mercurial using BREW

brew install mercurial
hg clone
cd hg
make install

Create a folder where you want to create your ‘C’ programs

mkdir coco_c
cd coco_c

In this folder we will configure mame to emulate a CoCo 2 & 3 with Disk Basic. First reset mame’s config file to the default

mame -cc

Make a roms folder and copy the CoCo roms to it. These are the current files that work with MAME 0.178. “coco.7z coco3_hdb1.7z coco_fdc.7z coco_fdc_v11.7z” (I still have my CoCo hardware so I legally can use these files. Please don’t ask me for copies)
For completeness the ROM CRCs required are:

$mame -listroms coco
ROMs required for driver "coco".
Name Size Checksum
bas10.rom 8192 CRC(00b50aaa) SHA1(1f08455cd48ce6a06132aea15c4778f264e19539)
$ mame -listroms coco2
ROMs required for driver "coco2".
Name Size Checksum
bas12.rom 8192 CRC(54368805) SHA1(0f14dc46c647510eb0b7bd3f53e33da07907d04f)
extbas11.rom 8192 CRC(a82a6254) SHA1(ad927fb4f30746d820cb8b860ebb585e7f095dea)
disk11.rom 8192 CRC(0b9c5415) SHA1(10bdc5aa2d7d7f205f67b47b19003a4bd89defd1)
$ mame -listroms coco3
ROMs required for driver "coco3".
Name Size Checksum
coco3.rom 32768 CRC(b4c88d6c) SHA1(e0d82953fb6fd03768604933df1ce8bc51fc427d)
disk11.rom 8192 CRC(0b9c5415) SHA1(10bdc5aa2d7d7f205f67b47b19003a4bd89defd1)

Use the imgtool command to create a RSDOS blank disk image called disk0.dsk

imgtool create coco_jvc_rsdos disk0.dsk

Use Brew to install nano

brew install nano

Use nano to copy the following bash file to compile and test your programs with CMOC and MAME


Copy the following into nano



cmoc --verbose "$name".c

echo "Run program with MAME?"
read yn

if [ "$yn" = "y" ]; then
 #copy program to disk image disk0.dsk
 imgtool put coco_jvc_rsdos disk0.dsk "$name".bin "$name".bin

 #start mame as coco3
 mame -window -natural coco3 -flop1 disk0.dsk
 echo "exited."

Press CTRL-X, Y, Return

Make the command executable

chmod +x

Use nano to create a test file, a little hello world ‘C’ source code called hello.c

nano hello.c
#include <coco.h>
#include <stdarg.h>

int main()
 printf("Hello World");
 return 0;

Press CTRL-X, Y, Return

Compile and EXECute it using (leave off the .c on the end of your source code filename):

./ hello

If the compile went well and no errors were present you can run the program by pressing ‘y’ and hit Return.  This should start up mame in a window in CoCo 3 disk mode with your new program copied to the disk image called disk0.dsk.  In the CoCo 3 mode type


You should see the program run on your CoCo screen.  🙂

The CMOC has great documentation and the libraries can already use the hires graphic modes of the CoCo 2 and CoCo 3.  There are some great example programs on he CMOC website.  The compiler currently can’t use floating point variables but there is a workaround if you look through the source code of the program on the CMOC website called FuncPlot.  It has a library that uses Extended Basic’s own floating point math functions to work with floating point numbers.

Happy CoCo programming…


This entry was posted in CoCo Programming. Bookmark the permalink.

1 Response to Compiling C programs for the old Radio Shack TRS-80 Color Computer running under RSDOS using MacOS or Linux

  1. w4jbm says:

    Just getting started with my CoCo and this is just what I was looking for to help set up a xdev system. I’ve had about the same experience with C but will see if I can pick it up. Thanks!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s