RunCPM

RunCPM is a Z80 emulator bundled with various versions of CP/M which run on the emulated Z80. It includes all the tools you need to explore Z80 assembly language programming (with access to the Grand Central's IO capabilities). Microsoft Basic is included and other languages are available online, including Modula-2 (an interesting language that was Niklaus Wirth's follow up to Pascal).

There are several different ways to build RunCPM: which one you use is determined by the platform you want to build it for. We'll use the Arduino approach to build it for the Grand Central so open the RunCPM.ino in the Arduino IDE. Before that you'll need the IDE set up to build for the Grand Central. See the Grand Central tutorial for details on doing that.

If you are new to the Arduino IDE, you may want to read the following tutorials:

 

Modifying RunCPM

To use RunCPM you'll need an MicroSD card. Follow the instructions in Getting Started section of the RunCPM Readme to set up the card. The contents of your card should be as shown below (with the card mounted on a linux workstation). The B directory isn't strictly required, but provides another virtual disk to play around with:

>:ls -R
.:
A CCP-CCPZ.60K CCP-DR.60K CCP-Z80.60K CCP-ZCP2.60K CCP-ZCP3.60K
B CCP-CCPZ.64K CCP-DR.64K CCP-Z80.64K CCP-ZCP2.64K CCP-ZCP3.64K

./A:
0

./A/0:
1STREAD.ME   CONSOLE8.Z80 INFO.Z80     RSTAT.COM    Z80ASM.COM
ASM.COM      DDT.COM      LOAD.COM     RSTAT.SUB    Z80ASM.PDF
BDOS.ASM     DISKDEF.LIB  LUA.COM      RSTAT.Z80    Z80CCP.ASM
BDOSEQU.LIB  DISPLAY.LIB  LUAINFO.LUA  STAT.COM     Z80CCP.SUB
BDOS.LUA     DUMP.ASM     LUA.SUB      SUBMIT.COM   ZCPR2.ASM
BDOS.SUB     DUMP.COM     LUA.Z80      SUBMITD.COM  ZCPR2.SUB
CAL.COM      ED.COM       LU.COM       SYSGEN.COM   ZCPR3.ASM
CCP.ASM      EXIT.COM     MAC.COM      TE.COM       ZCPR3.SUB
CCP.SUB      EXIT.SUB     MAKEFCB.LIB  UNARC.COM    ZEXALL.COM
CCP-ZCP3.BIN EXIT.Z80     MBASIC.COM   UNCR.COM     ZEXDOC.COM
CCPZ.SUB     FORMAT.COM   MLOAD.ASM    USQ.COM      ZSID.COM
CCPZ.Z80     FORMAT.SUB   MLOAD.COM    XMODEM.COM   ZTRAN.COM
CLEAN.SUB    FORMAT.Z80   MLOAD.DOC    XSUB.COM
CONSOLE7.COM HELLO.LUA    MOVCPM.COM   Z2HDR.LIB
CONSOLE7.Z80 INFO.COM     OPCODES.DOC  Z3BASE.LIB
CONSOLE8.COM INFO.SUB     PIP.COM      Z3HDR.LIB

./B:
0

./B/0:
>:

RunCPM is written to be very portable. Only a couple changes had to be made to get it running on the Grand Central.

The official RunCPM repo contains the GrandCentral related changes.

Changes to Support the Grand Central

Since the official repo now contains the Grand Central changes, this is for information/education and as a guide if you want to get it running on other M4 boards.

abstraction_arduino.h

This was just a matter of setting HostOs for the Grand Central:

Line 8 changes from:

#ifdef ARDUINO_SAM_DUE

to:

#if defined ARDUINO_SAM_DUE || defined ADAFRUIT_GRAND_CENTRAL_M4

RunCPM.ino

Similar to the above change, we need to add Grand Central support here as well. In particular, the specifics of the SD card and LED interfaces, as well as the board name. At about line 28 we add a branch to the board configuration #if structure:

#elif defined ADAFRUIT_GRAND_CENTRAL_M4
  #define USE_SDIO 0
  SdFat SD;
  #define SDINIT SDCARD_SS_PIN
  #define LED 13
  #define LEDinv 0
  #define BOARD "ADAFRUIT GRAND CENTRAL M4"

For reasons that aren't clear (possibly due to the separate SPI bus for the SD card) the SD card and file system has to be initialized a bit differently, so we have at about (after adding the above) line 108:

#if defined ADAFRUIT_GRAND_CENTRAL_M4
  if (SD.cardBegin(SDINIT, SD_SCK_MHZ(50))) {

    if (!SD.fsBegin()) {
      _puts("\nFile System initialization failed.\n");
      return;
    }
#else
  if (SD.begin(SDINIT)) {
#endif

The original line that the above replaces is:

if (SD.begin(SDINIT)) {

That's all it took to get RunCPM up and running. The terminal interface is via the USB connection which made it very easy. Not all terminal emulators will work perfectly, though. CP/M expects a VT100 type terminal, so not everything will work nicely (the author had some problems with MBASIC).

With the microSD card loaded/in-place and the Grand Central connected with board & port set appropriately, build and install onto the Grand Central. 

Now you can pretend to be a kid in the basement learning this strange new world of computing in the early 80s. Welcome to the author's childhood.

This guide was first published on Jan 29, 2019. It was last updated on Jan 29, 2019. This page (RunCPM) was last updated on Aug 19, 2019.