Getting Started with Retro Computers - Writing Code for the SC131

picture of the SC131 Pocket Computer
The excellent SC131 from Stephen C Cousins (available on for < $100)

About a year ago, I built a SC131 Pocket Sized Computer designed and developed by Stephen C Cousins on Tindie. I soldered the kit and got it up and running, but left it alone for a long time. I bought it because I'm interested in learning how computers work at the fundamental level.

Part of this exercise is to write code in C and compile it to a HEX file suitable for uploading to the built-in Monitor on the SC131 (it uses RomWBW).

It's interesting to me to understand how a seemingly simple C program of printf("Hello, World!") becomes a series of 1's and 0's. By understanding the instruction set of the processor (the SC131 uses the Zilog Z-180), you can match the machine code to the instructions. It's probably easiest to start with the assembly code generated by the C code and then look the instructions up in a Z-180 reference manual to see the machine code, then compare that to the HEX file. Also, there's a specific format that the HEX file is in, so there are some specific arrangements of bits at the beginning.

That's the extent of what I've learned about the basics right now.

I wanted to go over how I got started writing a C program that runs on the SC131 (and probably other related Z180 targets).

I started by ordering the SC131 computer from Tindie and building it (it comes as an unassembled kit that requires soldering). I found the kit was easy to solder and worked the first time I powered it on. All of the components are through-hole, though there is one CPU socket that has some tight spots on it. I recommend using a flux pen (clean the board thoroughly after assembly so the flux doesn't interfere with the board components in the future).

Then I downloaded the z88dk from I always like to get the latest nightly build to make sure I'm up to date. I am using Windows, though the process should be comparable on Linux. Download and decompress the files into a folder. I create a folder on my root drive called C:\z88dk.

Add C:\z88dk\bin to your path system environment variable. (Linux instructions, Windows instructions)

Create a text file named hello.c in a development directory.

Open the file in a text editor (I used Visual Studio Code, but any simple editor will do). When you get more complicated with your programs, having a good development tool like VS Code or Atom will make your life easier.

here is the code that I used:

#include <stdio.h>
#define ASCII_ESC 27

void main() {
    // Clear the screen
    printf( "%c[2J", ASCII_ESC );
    // Say hello
    printf("Hello, World!");

Then, I opened a terminal (VS Code has a Terminal built in that opens up in the current directory).

In the terminal, type:

zcc +scz180 -subtype=hbios -clib=sdcc_iy -SO3 -v -m --list --max-allocs-per-node100000 hello.c -o hello -create-app
If you installed z88dk on Linux using snapd, then you'll need to use z88dk.zcc instead.

This will generate some intermediate files in the directory where you built the program.

Connect to your SC131 via a Terminal Emulator (I use TeraTerm and my screenshots will be from that).

First, let's get connected to the computer. Connect your SC131 via the Serial to USB adapter.

Open TeraTerm.

Click Serial and select the COM port where your computer is located. Mine is on COM4.

Screenshot of the new connection dialog for TeraTerm

Click OK

Choose Setup->Serial Port from the menu:

picture of the Setup menu on TeraTerm with the Serial Port option highlighted

Here are my settings (you may have a different serial port, but the other settings should match for the SC131).

screenshot of TeraTerm serial port setup screen


Port: COM Port where the SC131 is connected
Speed: 115,200 bps
Data: 8 bit
Parity: none
Stop bits: 1 bit
Flow control: RTS/CTS (SC131 supports this, so we should use it)

Click New Setting

Now click the RESET button on the front panel of your SC131.

Screenshot of RomWBW boot screen
Boot screen for RomWBW on the SC131

Type M for the monitor.

Screenshot of Monitor ready and 'L' command being executed

Type L (Load) and then press Enter.

We are now in loading mode. Click File->Send File from the TeraTerm menu.

Screenshot of TeraTerm file menu with "send file" highlighted

Then, choose the hello.ihx file from your development directory.

Screenshot of TeraTerm "send file" dialog with "hello.ihx" file highlighted

Click Open to send the file:

Screenshot of Progress bar for TeraTerm file send
Progress bar for TeraTerm file send

Once the file has been sent, you will see the Loaded response. This is where I ran into problems the first time I tried to load my program, and I got some great help on the retro-comp Google group (this is an awesome group full of experienced and helpful people who are always sharing their interesting ideas and amazing work on retro computer projects).

Screenshot of RomWBW Monitor Load confirmation

Our program begins at memory location 0x8000 ( I'm not sure exactly why this is, but I think it has something to do with the fact that that's where there's room for program memory. I'm still learning the intracacies of the processor).

Next, type R 8000 to run the program at memory location 8000.

Screenshot of Monitor showing "R 8000" as next command to run

Press Enter to run the program.

You should see the screen clear and the text Hello, World! displayed on the screen.

Screenshot of final resulting screen showing that the screen was cleared and the text "Hello, World!" was displayed

That's it. We have now created a C program and run it on the SC131.

Things get a lot more interesting when you start adding extra libraries like time and math.

I am a beginner when it comes to C, as I have been either a VB 6, or .NET (C#, VB.NET) developer for the past 22 years. I'm slowly learning how to use C to its fullest and this SC131 (and the SC126, a more advanced DIY computer kit) have made it a lot of fun to learn.