# RP2040 RunCPM Emulator with USB Keyboard & HDMI screen

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/121/873/medium800thumb/microcontrollers_PXL_20230613_194705372.TS-opt.jpg?1686689301)

The CP/M operating system was created in 1974 and ran on the 8080 and Z-80 microprocessors. Before the rise of the IBM PC & MS-DOS, it was considered a powerful operating system, especially for home computers.

There are a number of CP/M emulators & simulators. One of them, [RunCPM by MockbaTheBorg](https://github.com/MockbaTheBorg/RunCPM/), was previously [adapted to run on the RP2040 family of microcontrollers by guidol70](https://github.com/guidol70/RunCPM_RPi_Pico). This project adds USB for keyboard input & HDMI for display output. The resulting computer is entirely self-contained and doesn't need a host computer to operate.

This project uses two Adafruit Feathers. Why's that? Both the [digital video output](https://learn.adafruit.com/picodvi-arduino-library-video-out-for-rp2040-boards) and the [USB Host](https://learn.adafruit.com/adafruit-feather-rp2040-with-usb-type-a-host) are implemented using [the RP2040's powerful PIO peripheral](https://learn.adafruit.com/intro-to-rp2040-pio-with-circuitpython)—but each task requires almost all of the chip's capacity in order to do so. That made it necessary to split the project in half. One of the Feathers does the CPU and OS emulation plus the video signal generation. The other reads keystrokes and transmits them over a UART connection to the first board. It's not a Beowulf cluster, but it's still a cool technique to expand the capabilities in this project.

After putting the project together, you'll want to do something with it! There's a great deal of software for CP/M readily available on the internet. This guide will cover where to download some classic & modern CP/M software. With an assembler or a BASIC interpreter, you can even write your own new CP/M software right on the device.

## Parts
Featured
### Adafruit Feather RP2040 with DVI Output Port - Works with HDMI

[Adafruit Feather RP2040 with DVI Output Port - Works with HDMI](https://www.adafruit.com/product/5710)
Wouldn't it be cool if you could display images and graphics from a microcontroller directly to an HDMI monitor or television? We think so! So we designed this RP2040 Feather that has a digital video output (a.k.a DVI) that will work with any HDMI monitor or display. Note it doesn't do...

Out of Stock
[Buy Now](https://www.adafruit.com/product/5710)
[Related Guides to the Product](https://learn.adafruit.com/products/5710/guides)
![Video of DVI prototyping dev board sending graphic images to an HDMI monitor.](https://cdn-shop.adafruit.com/product-videos/640x480/5710-07.jpg)

Featured
### Adafruit Feather RP2040 with USB Type A Host

[Adafruit Feather RP2040 with USB Type A Host](https://www.adafruit.com/product/5723)
You're probably really used to microcontroller boards with USB, but what about a dev board with two? Two is more than one, so that makes it twice as good! And the&nbsp; **Adafruit Feather RP2040 with USB Host** is **&nbsp;** definitely double-the-fun of our other Feather...

Out of Stock
[Buy Now](https://www.adafruit.com/product/5723)
[Related Guides to the Product](https://learn.adafruit.com/products/5723/guides)
![Angled shot of black rectangular microcontroller with USB C and USB A connectors at both ends.](https://cdn-shop.adafruit.com/640x480/5723-00.jpg)

Featured
### Adalogger FeatherWing - RTC + SD Add-on For All Feather Boards

[Adalogger FeatherWing - RTC + SD Add-on For All Feather Boards](https://www.adafruit.com/product/2922)
A Feather board without ambition is a Feather board without FeatherWings! This is the **Adalogger FeatherWing** : it adds both a battery-backed Real Time Clock and micro SD card storage to any Feather main board. Using our [Feather...](https://www.adafruit.com/products/2830)

In Stock
[Buy Now](https://www.adafruit.com/product/2922)
[Related Guides to the Product](https://learn.adafruit.com/products/2922/guides)
![Adalogger FeatherWing with Real time clock and SD card slot.](https://cdn-shop.adafruit.com/640x480/2922-11.jpg)

Featured
### HDMI 5" Display Backpack - Without Touch

[HDMI 5" Display Backpack - Without Touch](https://www.adafruit.com/product/2232)
It's a mini panel-mountable HDMI monitor! So small and simple, you can use this display with any computer that has HDMI output, and the shape makes it easy to attach to a case or rail. This backpack features the TFP401 for decoding video and includes the attached display, so it's...

Out of Stock
[Buy Now](https://www.adafruit.com/product/2232)
[Related Guides to the Product](https://learn.adafruit.com/products/2232/guides)
![Top down view of a HDMI 5" Display Backpack - Without Touch connected to a Raspberry Pi powered by a USB. The HDMI screen displays a desktop image including the Raspberry Pi logo. ](https://cdn-shop.adafruit.com/640x480/2232-07.jpg)

Featured
### FeatherWing Tripler Mini Kit - Prototyping Add-on For Feathers

[FeatherWing Tripler Mini Kit - Prototyping Add-on For Feathers](https://www.adafruit.com/product/3417)
This is the **FeatherWing Tripler** - a prototyping add-on and more for all Feather boards. This is similar to our [FeatherWing Proto](https://www.adafruit.com/products/2884) except there are three! The magic of the Tripler comes when you want to connect your Feather to...

In Stock
[Buy Now](https://www.adafruit.com/product/3417)
[Related Guides to the Product](https://learn.adafruit.com/products/3417/guides)
![Triple prototyping feather wing PCB with socket headers installed](https://cdn-shop.adafruit.com/640x480/3417-05.jpg)

### SD/MicroSD Memory Card (8 GB SDHC)

[SD/MicroSD Memory Card (8 GB SDHC)](https://www.adafruit.com/product/1294)
Add mega-storage in a jiffy using this 8 GB class 4 micro-SD card. It comes with a SD adapter so you can use it with any of our shields or adapters. Preformatted to FAT so it works out of the box with our projects. Tested and works great with our <a...></a...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/1294)
[Related Guides to the Product](https://learn.adafruit.com/products/1294/guides)
![Hand removing/installing micro SD card from SD adapter](https://cdn-shop.adafruit.com/640x480/1294-03.jpg)

### 512MB micro SD Memory Card

[512MB micro SD Memory Card](https://www.adafruit.com/product/5252)
Add storage in a jiffy using this **512MB** microSD card. Preformatted to FAT32, so it works out of the packaging with our projects. Works great with any device in the Adafruit shop that uses microSD cards. Ideal for use with Feathers, data loggers, or small Linux SBCs (not good...

In Stock
[Buy Now](https://www.adafruit.com/product/5252)
[Related Guides to the Product](https://learn.adafruit.com/products/5252/guides)
![Angel shot of Small microSD card 512mb](https://cdn-shop.adafruit.com/640x480/5252-00.jpg)

### Mini Wireless Keyboard - Black w/ Batteries

[Mini Wireless Keyboard - Black w/ Batteries](https://www.adafruit.com/product/1737)
Add a good quality, slim keyboard to your Raspberry Pi, Beagle Bone Black or other mini-computer with this sleek black chiclet keyboard. It's a full QWERTY keyboard with a wireless USB dongle and is compatible with all operating systems. We tried many keyboards to find one that felt good...

In Stock
[Buy Now](https://www.adafruit.com/product/1737)
[Related Guides to the Product](https://learn.adafruit.com/products/1737/guides)
![Angled shot Mini Wireless Keyboard - Black w/ Batteries](https://cdn-shop.adafruit.com/640x480/1737-02.jpg)

### Pink and Purple Woven USB A to USB C Cable - 1 meter long

[Pink and Purple Woven USB A to USB C Cable - 1 meter long](https://www.adafruit.com/product/5153)
This cable is not only super-fashionable, with a woven pink and purple Blinka-like pattern, it's also made for USB C for our modernized breakout boards, Feathers, and more.&nbsp;&nbsp;[If you want something just like it but for Micro B, we...](https://www.adafruit.com/product/4111)

Out of Stock
[Buy Now](https://www.adafruit.com/product/5153)
[Related Guides to the Product](https://learn.adafruit.com/products/5153/guides)
![Angled shot of coiled pink and purple USB cable with USB A and USB C connectors.](https://cdn-shop.adafruit.com/640x480/5153-02.jpg)

### Fully Reversible Pink/Purple USB A to micro B Cable - 1m long

[Fully Reversible Pink/Purple USB A to micro B Cable - 1m long](https://www.adafruit.com/product/4111)
This cable is not only super-fashionable, with a woven pink and purple Blinka-like pattern, it's also fully reversible! That's right, you will save _seconds_ a day by not having to flip the cable around.

First let's talk about the cover and over-molding. We got these...

In Stock
[Buy Now](https://www.adafruit.com/product/4111)
[Related Guides to the Product](https://learn.adafruit.com/products/4111/guides)
![Fully Reversible Pink/Purple USB A to micro B Cable](https://cdn-shop.adafruit.com/640x480/4111-02.jpg)

### HDMI Flat Cable - 1 foot / 30cm long

[HDMI Flat Cable - 1 foot / 30cm long](https://www.adafruit.com/product/2197)
Connect two HDMI devices together and save space with this basic flat HDMI 1.4 cable. It has nice molded grips for easy installation, and is 1 foot long (~30 cm).

This cable is absolutely&nbsp; **perfect** &nbsp;for an LCD Raspberry Pi project. The cable is so thin and...

In Stock
[Buy Now](https://www.adafruit.com/product/2197)
[Related Guides to the Product](https://learn.adafruit.com/products/2197/guides)
![HDMI Flat Cable - 1foot / 30cm long](https://cdn-shop.adafruit.com/640x480/2197-00.jpg)

### Black Nylon Machine Screw and Stand-off Set – M2.5 Thread

[Black Nylon Machine Screw and Stand-off Set – M2.5 Thread](https://www.adafruit.com/product/3299)
Totaling 380 pieces, this **M2.5 Screw Set** &nbsp;is a must-have for your workstation.&nbsp;You'll have enough screws, nuts, and hex standoffs to fuel your maker tendencies&nbsp;for days on end! M2.5 size screws fit almost all of the Adafruit breakout/dev board mounting holes...

Out of Stock
[Buy Now](https://www.adafruit.com/product/3299)
[Related Guides to the Product](https://learn.adafruit.com/products/3299/guides)
![Black Nylon Screw and Stand-off Set with M2.5 Threads, kit box](https://cdn-shop.adafruit.com/640x480/3299-00.jpg)

# RP2040 RunCPM Emulator with USB Keyboard & HDMI screen

## Set Up Arduino

This project uses the Adafruit PicoDVI and USB Host Feather on the **_Earle Philhower III Arduino core_** for programming — an optional package that makes most RP2040 boards work in the Arduino environment. If you’ve previously followed any guides for Adafruit RP2040-based boards in Arduino, you likely already have this installed…just check that you’re up to date with the latest ( **3.2.1 or newer** ).

If that sounds unfamiliar, [this guide walks through the process](https://learn.adafruit.com/rp2040-arduino-with-the-earlephilhower-core/overview).

![](https://cdn-learn.adafruit.com/assets/assets/000/119/447/medium800/hdmi_boards-manager.png?1678812706)

Once installed, the Arduino IDE **Tools→Board** menu will include a rollover for “Raspberry Pi RP2040 Boards,” and you can find and select whatever board type you’re using (e.g. Feather RP2040 DVI or Raspberry Pi Pico).

Next, the **PicoDVI library** can be installed from the **Arduino Library Manager**. From the Sketch menu…

**Sketch→Include Library→Manage Libraries…**

Enter “ **picodvi** ” in the search field and look for **PicoDVI - Adafruit Fork** in the results. Click “Install,”.

Our version of PicoDVI depends on the **Adafruit\_GFX** library. The Library Manager _should_ install this automatically if not already present, but if using an older version of the Arduino IDE you might need to search for and install it manually.

![](https://cdn-learn.adafruit.com/assets/assets/000/119/415/medium800/hdmi_picodvi-install.png?1678732354)

This is the Adafruit “fork” of the original PicoDVI project, meaning as much of the original code is preserved with minimal changes. What we’ve done is add an Arduino-compliant C++ wrapper to make this command-line library work with the friendlier Arduino IDE, and implemented simple raster framebuffers for drawing. All the original stuff is there if you want to dig in and learn, though the original examples as written won’t build in the Arduino IDE.

[Here’s our fork on GitHub](https://github.com/adafruit/PicoDVI), and [Luke Wren’s original project](https://github.com/Wren6991/PicoDVI).

For the USB Keyboard Co-Processor, search for and install the **Pico PIO USB** library by sekigon-gonnoc. It depends on **Adafruit TinyUSB Library** which should be installed automatically unless you're on a very old version of the Arduino IDE.

![](https://cdn-learn.adafruit.com/assets/assets/000/121/496/medium800/microcontrollers_Screenshot_2023-06-02_10-15-39.png?1685719002)

Once you've installed the required libraries, you can close the library manager window and continue.

# RP2040 RunCPM Emulator with USB Keyboard & HDMI screen

## Set up the SD Card

The RunCPM emulator is very particular about how files are organized!

CP/M uses drive letters (A, B, ...) and user numbers (0, 1, ...). The structure of files on the SD card has to mimic this arrangement **and all filenames must be in upper case ASCII only, with no more than 8 letters in the filename and no more than 3 letters in the extension**.

So, for example, if you want the file "example.hex" to appear in the " **B**" drive for the default user (user zero), you would create the folder " **B/0**" and put the file in it as " **EXAMPLE.HEX".** A filename like "example.txt" (lowercase) "EXAMPLE.TEXT" (incorrect length of extension) or any filename that contains non-ASCII characters will not be accessible by RunCPM.

For a starter set of files, [grab the standard CP/M 2.2 files from retroarchive.org](http://www.retroarchive.org/cpm/os/STDCPM22.ZIP). Create the folder " **A/0"** , and copy the files from that zip to **A/0**. It's important that you don't create any other intermediate folders!

If you like the classic text adventure game Zork, [retroarchive has you covered](http://www.retroarchive.org/cpm/games/zork123_80.zip). You can follow a similar process but put these files a **B/0** on the SD card.

With that done, safely remove or eject the SD card from your computer and stick it in the adalogger's micro SD card slot.

For your convenience, and because some browsers don't like downloading from the non-https retroarchive site, you can also download using the links below:

[STDCPM22.ZIP](https://cdn-learn.adafruit.com/assets/assets/000/121/735/original/STDCPM22.ZIP?1686435827)
[zork123_80.zip](https://cdn-learn.adafruit.com/assets/assets/000/121/736/original/zork123_80.zip?1686435852)
Once you're done, the folder & file structure should look like this:

![](https://cdn-learn.adafruit.com/assets/assets/000/121/778/medium800/microcontrollers_cpmtree.png?1686611330)

# RP2040 RunCPM Emulator with USB Keyboard & HDMI screen

## Soldering and Wiring

(New to soldering? [There's a guide for that](https://learn.adafruit.com/collins-lab-soldering)!)

Solder male headers on the two Feathers and the FeatherWing, with the long pins sticking out the bottom. (Also shown: The Micro SD card & wireless keyboard receiver have been inserted.)

![microcontrollers_PXL_20230612_212721085.jpg](https://cdn-learn.adafruit.com/assets/assets/000/121/770/medium640/microcontrollers_PXL_20230612_212721085.jpg?1686609427)

Solder female headers on the top of the FeatherWing Tripler, noting the small outlines which show where the long & the short headers must be placed. (Also shown: these are the locations where you'll later screw the tripler into the 3D printed bracket.)

![microcontrollers_PXL_20230612_212643091.jpg](https://cdn-learn.adafruit.com/assets/assets/000/121/771/medium640/microcontrollers_PXL_20230612_212643091.jpg?1686609988)

Insert the boards in the feather tripler, double checking orientation and position. The order can be whatever you like. Take care, and make sure all the pins make good contact. If the connections are "off by one", the electronics can become damaged.

![microcontrollers_PXL_20230613_192330865.jpg](https://cdn-learn.adafruit.com/assets/assets/000/121/866/medium640/microcontrollers_PXL_20230613_192330865.jpg?1686696293)

There are several cable connections needed. Connect a USB C power / data cable to **just one of the feathers**. The second feather receives power via the Feather Tripler.

When you upload code to one of the feathers, make sure the USB C cable is plugged into the correct one. If you make a mistake, no fear: just re-program both feathers to get the software back in the right place.

![microcontrollers_runcpm-usbccable.jpg](https://cdn-learn.adafruit.com/assets/assets/000/121/867/medium640/microcontrollers_runcpm-usbccable.jpg?1686692044)

Connect a HDMI cable from the HDMI Feather to the HDMI monitor of your choice. Here, it's connected to the 5" display backpack.

![microcontrollers_runcpm-hdmicable.jpg](https://cdn-learn.adafruit.com/assets/assets/000/121/868/medium640/microcontrollers_runcpm-hdmicable.jpg?1686703552)

The 5" Display Backpack receives power from a USB Micro B cable.

![microcontrollers_runcpm-microbcable.jpg](https://cdn-learn.adafruit.com/assets/assets/000/121/869/medium640/microcontrollers_runcpm-microbcable.jpg?1686692651)

Insert the SD card and USB keyboard (shown here is the receiver for a wireless keyboard).

![microcontrollers_runcpm-sdcard.jpg](https://cdn-learn.adafruit.com/assets/assets/000/121/870/medium640/microcontrollers_runcpm-sdcard.jpg?1686692537)

![microcontrollers_runcpm-kbdreceiver.jpg](https://cdn-learn.adafruit.com/assets/assets/000/121/871/medium640/microcontrollers_runcpm-kbdreceiver.jpg?1686703732)

# RP2040 RunCPM Emulator with USB Keyboard & HDMI screen

## Code the Emulator

## Compiling the Emulator Code
Begin by grabbing the code. Unzip it in your Arduino folder, then open it with the Arduino IDE.

[Download Ardiuno Sketch Source Code (zip)](https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/runcpm-rp2040-dvi-usb/runcpm-pico/runcpm-pico.ino)
Under Tools, there are a number of selections you have to make:

- For board, choose "Adafruit Feather DVI"
- For optimization, choose "Optimize even more (-O3)"
- For flash speed choose "W25Q080 QSPI /4"
- For USB stack choose "Adafruit TinyUSB"

&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/121/731/medium800/microcontrollers_settings-runcpm.png?1686431007)

## Booting Up

Now, plug your Adafruit Feather DVI in to your computer with a USB cable while holding down the BOOT button on the Feather to enter bootloader mode. Then select "upload sketch" in Arduino. Once the sketch is uploaded, plug the video out on the Feather to a monitor using a HDMI cable and reset the Feather with the reset button. You will see the RunCPM boot screen.

Using the Serial Monitor in Arduino you can run CP/M commands like "DIR". Follow the next steps so that you can use a USB keyboard connected to the Feather USB Host instead of the serial connection.

![](https://cdn-learn.adafruit.com/assets/assets/000/121/732/medium800/microcontrollers_Screenshot_2023-06-10_16-07-19.png?1686431266)

## A Note about Overclocking

Generating digital video signals takes a lot of oomph! This sketch overclocks your RP2040 board to 148MHz, and increases the core voltage to 1.20V. **T**** he software documented here pushes the RP2040 microcontroller beyond its design specifications. Just like PC overclocking, there’s some risk of reduced component lifespan, though the extent (if any) can’t be precisely quantified and could vary from one chip to another. Proceed at your own discretion.** It also makes CP/M emulation blisteringly fast compared to the 4MHz Z80A!

# RP2040 RunCPM Emulator with USB Keyboard & HDMI screen

## Code the Keyboard Converter

A retro computer is no fun without a way to type into it. Happily, the Adafruit Host Feather can be used to convert almost any USB keyboard into a keyboard for the RunCPM emulator.

Start by grabbing the keyboard converter sketch from GitHub:

[Keyboard Converter Arduino Sketch](https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/runcpm-rp2040-dvi-usb/keyboard-copro/keyboard-copro.ino)
Now, make the appropriate settings in the Tools menu:

- For board, choose "Adafruit Feather RP2040 USB Host"
- For USB stack choose "Adafruit TinyUSB"

![](https://cdn-learn.adafruit.com/assets/assets/000/121/780/medium800/microcontrollers_Screenshot_2023-06-10_16-08-58.png?1686612291)

Un-plug the emulator/video feather from your computer and plug the USB Host feather into your computer using a USB cable while holding down the BOOT button. **It's important that the correct board is plugged in at this step, so that the correct board is updated!** Select "upload sketch".

After the upload is complete, open the serial monitor and plug a compatible USB keyboard into the USB A port on the USB Host Feather. When you type letters on the keyboard, they will be shown on the serial monitor window. The bytes are also being transmitted on the board's RX pin for RunCPM to receive.

Note that due to technical limitations, a keyboard's capslock and numlock LEDs (if present) will not light, but these keys do function in the normal fashion.

The keyboard is set to a QWERTY US English layout and can only be changed by editing the source code and recompiling.

![](https://cdn-learn.adafruit.com/assets/assets/000/121/733/medium800/microcontrollers_Screenshot_2023-06-10_16-10-56.png?1686431465)

# RP2040 RunCPM Emulator with USB Keyboard & HDMI screen

## 3D Printing and Assembly

If you're using your RunCPM emulator with the 5" Display Backpack, there's a 3D printable bracket you can mount everything to.

Print the bracket on its side, as shown. Use a layer height of 0.2mm to 0.3mm. On most printers, no support is required. PLA and PETG are very suitable for this print. Use the download button below to grab the 3D printable STL file as well as the FreeCad design file:

[cpmish-display-backpack-bracket.zip](https://cdn-learn.adafruit.com/assets/assets/000/121/775/original/cpmish-display-backpack-bracket.zip?1686610411)
![](https://cdn-learn.adafruit.com/assets/assets/000/121/776/medium800/microcontrollers_printing2.png?1686610523)

From the M2.5 mounting hardware box, pick out:

- 16 of the M2.5 x 4mm Screws (the shortest screw)
- 8 of the 6mm long F-F hex standoffs (the shortest standoff)

Begin by installing the stand-offs:

- The outermost 4 holes are for the display.&nbsp; At each position, insert a screw from the back and tighten a stand-off on the front.
- The remaining holes support a number of different boards & configurations. Find the inner columns of 6 holes each and place stand-offs on the back in the first and last positions, fastening from the front with screws.

Next, attach the display on the front with the connectors on the right and hand-tighten the 4 screws on the front.

![microcontrollers_PXL_20230612_212628664.jpg](https://cdn-learn.adafruit.com/assets/assets/000/121/773/medium640/microcontrollers_PXL_20230612_212628664.jpg?1686610241)

Finally, remove the boards from the feather tripler and attach the Feather tripler on the back side of the bracket, orienting it so that the DVI connector will be on the same edge as the display. Counting from the bottom of the tripler, screw in the first and fourth sets of holes into the standoffs.

Re-install the Feathers and FeatherWing, connect the display, keyboard and power. Then power on!

![microcontrollers_PXL_20230612_213244150.jpg](https://cdn-learn.adafruit.com/assets/assets/000/121/774/medium640/microcontrollers_PXL_20230612_213244150.jpg?1686610230)

# RP2040 RunCPM Emulator with USB Keyboard & HDMI screen

## Using CP/M

![](https://cdn-learn.adafruit.com/assets/assets/000/121/779/medium800/microcontrollers_PXL_20230612_225951247.jpg?1686611425)

CP/M is a text-oriented, command-line interface. Only a few simple utilities were included with the original base system.

The original CP/M manuals are online. [This version has been scanned and is pretty easy on the eyes](http://www.cpm.z80.de/manuals/cpm22-m.pdf) but has occasional weird mistakes introduced by the optical character recognition process. There's also a [good quality scan on archive.org](https://archive.org/details/CPM_Operating_System_Manual/). If you want to get in depth about how to use **ED** , **PIP** , **ASM** , and the rest, this is a good place to start.

Similar to MS-DOS, you can select among drives with the commands "A:" and "B:". If you followed the instructions when setting up the SD card, the A: drive will be filled with the CP/M operating system and some utilities; the B: drive has several games in the Zork series.

Most references will show the CP/M prompt as `A>` or `B>` but RunCPM also displays the "user number", which defaults to 0: `A0>` or `B0>`. (Drives can actually go up to letter "P", which is the 16th letter)

Another feature of RunCPM is that when searching for a program, **A0** is searched after the current drive and user are searched, so think of **A0** as the place you install programs.

The easiest way to move and copy files is probably to put the SD card in a real computer and use the file manager on that computer. In CP/M the multi-purpose program **PIP** could be used to copy a file to a new name or to a new drive. For example, to copy the program **ASM.COM** from the **A** drive to the **B** drive, you would write

`PIP B:=A:ASM.COM`

The command **REN** renames files, for instance if you need to correct a mis-typed filename:

`REN EXAMPLE.TXT=EXMAPLE.TXT`

To erase (delete) a file, use the **ERA** command (the extension **$$$** is often used for temporary files):

`ERA TEMPFILE.$$$`

## ED.COM, the CP/M editor

The original CP/M editor, **ED** , is a line oriented editor that feels very primitive by modern standards. Have you encountered a joke about how the classic Unix editor **vi** is for beginners? **ED** says "hold my beverage!"

- To begin inserting lines, use the "i" command
- When done inserting lines, use Ctrl+Z on its own line to return to command mode
- Write your file & exit with the "e" command.

Here's a sample **ED** session, with the parts that the user types shown in `bold code` and the stuff that RunCPM prints in `regular code`:

`RunCPM [v6.0] => CCP:[INTERNAL v3.0] TPA:64K`

`B0>ed hello.txt `  
`     : *i`  
`    1:  now is the time for all cool people`  
`    2:  to write text in ED.COM `  
`    3:  and then save it to disk`  
`    4:  (type ctrl-z here)`  
`     : *e`

`RunCPM [v6.0] => CCP:[INTERNAL v3.0] TPA:64K`

`B0>type hello.txt`  
`now is the time for all cool people`  
`to write text in ED.COM `  
`and then save it to disk`

It's also possible to read back a file and make changes, but showing how to use&nbsp; **ED** fluently is outside the scope of this guide.

## ASM.COM, the CP/M assembler

Using ED, or by preparing the file on your host computer and copying it, put the following content into **HELLO.ASM** on the B drive for user 0 ( **B\0\HELLO.ASM** is the path on the host computer):

```auto
bdos    equ     0005H
        org     0100H
;
        lxi     d,message
        mvi     c,9
        call    bdos
        ret
;
message db 'Hello world.', 10, 13, '$'
```

Like most CP/M programs, this program begins (has its **or** i **g** in) at the hex address 0100 (256 in decimal). It calls into the operating system ("bdos", at address 0005 hex) with the command register set to 9 (print string), and the address argument set to the message. bdos command 9 prints each byte starting at its address argument until a "$" is encountered. 10 and 13 represent the "carriage return" and "line feed" special characters. When **call bdos** finishes, the program exits by running the **ret** urn instruction.

Note that in order for this file to work properly, it has to be created with "DOS-style line endings", or CRLF line endings. This may require special settings in your text editor, so feel free to grab a correct copy using the link below.

[hello_asm.zip](https://cdn-learn.adafruit.com/assets/assets/000/121/737/original/hello_asm.zip?1686435971)
Now, assemble it to create hello.hex, which you can show with the **TYPE** command:

```auto
B0>asm hello

CP/M ASSEMBLER - VER 2.0
0118
000H USE FACTOR
END OF ASSEMBLY

CPM [v6.0] => CCP:[INTERNAL v3.0] TPA:64K

B0>type hello.hex

:100100001109010E09CD0500C948656C6C6F207797
:080110006F726C642E0A0D24CD
:0000000000
```

To convert it to an executable program, load it using the debugger **DDT** , then immediately exit DDT by jumping to the warm start address 0 with the **g0** command, and finally save the program using the **SAVE** command (the count argument, **1** , is the number of 128-byte units occupied by the program). After doing this, it is possible to run the **HELLO.COM** program:

```auto
B0>ddt hello.hex

DDT VERS 2.2
NEXT  PC
0118 0000
-g0



RunCPM [v6.0] => CCP:[INTERNAL v3.0] TPA:64K

B0>save 1 hello.com

..
B0>hello

Hello world.
```

(In real CPM usage, it would be more typical for the **LOAD** program to be used instead of the **DDT** program, but for an unknown reason this did not work in RunCPM when the author tested it, so the method using **DDT** is shown instead.)

You can also develop CP/M software on your host computer with software suites like the [z88 development kit](https://z88dk.org/site/) or the [Amsterdam Compiler Kit](https://github.com/davidgiven/ack), though this is beyond the scope of this guide.

# RP2040 RunCPM Emulator with USB Keyboard & HDMI screen

## Playing Zork

I think it's time to admit it: The real goal all along was to play games. That's comparatively simple, simply change to the **B:** drive and run the command **ZORK1** :

```terminal
A0>B:
B0>zork1
ZORK I: The Great Underground Empire
Copyright (c) 1981, 1982, 1983 Infocom, Inc. All rights
reserved.
ZORK is a registered trademark of Infocom, Inc.
Revision 88 / Serial number 840726

West of House
You are standing in an open field west of a white house, with
a boarded front door.
There is a small mailbox here.

>open mailbox
Opening the small mailbox reveals a leaflet.

>take
(leaflet)
Taken.
```

I hope you don't mind a spoiler about this game: I've never won it myself, but I've been told it's important to pick up that leaflet, it'll be useful later.

# RP2040 RunCPM Emulator with USB Keyboard & HDMI screen

## RunCPM on the Fruit Jam

![zork on fruit jam](https://cdn-learn.adafruit.com/assets/assets/000/138/991/medium800/microcontrollers_Screenshot_2025-08-12_130138.png?1755018127 )

The Fruit Jam sports an HSTX connector for digital video, two USB ports, and a microSD card slot. Better yet, because of the RP2350's HSTX peripheral, a single microcontroller can perform the video and USB tasks at the same time.

You can use this pre-compiled UF2 file to load the firmware onto your Fruit Jam:

[runcpm-fruitjam.uf2](https://cdn-learn.adafruit.com/assets/assets/000/138/992/original/runcpm-fruitjam.uf2?1755019255)
Otherwise, you can compile the code in the Arduino IDE&nbsp;by&nbsp;[setting up Arduino](https://learn.adafruit.com/rp2040-runcpm-emulator-with-usb-keyboard-hdmi-screen/set-up-arduino), and adding the [Adafruit-DVI-hstx library](https://github.com/adafruit/adafruit-dvi-hstx) through the library manager. While you're at it, make sure the Adafruit GFX library is up to date. There is a special version of the code [available on GitHub here](https://github.com/adafruit/Adafruit_Learning_System_Guides/tree/main/runcpm-rp2350-hstx-usb/runcpm-pico).

[RunCPM Emulator Source Code on GitHub](https://github.com/adafruit/Adafruit_Learning_System_Guides/tree/main/runcpm-rp2350-hstx-usb/runcpm-pico)
Once the firmware is all set on your Fruit Jam, either with the UF2 or manual compilation, you can:

1. Follow the steps for [setting up your SD card](https://learn.adafruit.com/admin/guides/3823/editor/26690), then insert it into your Fruit Jam.
2. Plug a standard keyboard into one of the USB ports.
3. Plug an HDMI cable into the HSTX DVI port on the Fruit Jam. When it comes to the display, you'll need one&nbsp;[supporting 1280x720 resolution](https://www.adafruit.com/product/1667). Plug it into the DVI port.

After following these steps, restart the Fruit Jam. You should get a text display on your monitor & be able to type with your keyboard.

Featured
### Adafruit Fruit Jam - Mini RP2350 Computer

[Adafruit Fruit Jam - Mini RP2350 Computer](https://www.adafruit.com/product/6200)
We were catching up on a recent [hackaday hackchat with eben upton](https://hackaday.io/event/202122-raspberry-pi-hack-chat-with-eben-upton)&nbsp;and learned some fun facts: such as the DVI hack for the RP2040 was inspired by <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/6200)
[Related Guides to the Product](https://learn.adafruit.com/products/6200/guides)
![Angled shot of assembled mini computer PCB with plate.](https://cdn-shop.adafruit.com/640x480/6200-10.jpg)

Featured
### 7" Display 1280x800 (720p) IPS + Speakers - HDMI/VGA/NTSC/PAL

[7" Display 1280x800 (720p) IPS + Speakers - HDMI/VGA/NTSC/PAL](https://www.adafruit.com/product/1667)
Yes, this is an adorable small HDMI television with incredibly high resolution **and built in 3W stereo speakers**! We tried to get the smallest possible HDMI/VGA display with high-res, high-contrast visibility. The visible display measures only 7" (17.8cm) diagonal, and the TFT comes...

In Stock
[Buy Now](https://www.adafruit.com/product/1667)
[Related Guides to the Product](https://learn.adafruit.com/products/1667/guides)
![Front view of assembled and powered on HDMI 4 Pi - 7" Display. The monitor displays a desktop background with a raspberry logo.](https://cdn-shop.adafruit.com/640x480/1667-00.jpg)

Featured
### USB Type A to Type C Cable - approx 1 meter / 3 ft long

[USB Type A to Type C Cable - approx 1 meter / 3 ft long](https://www.adafruit.com/product/4474)
As technology changes and adapts, so does Adafruit. This&nbsp;&nbsp; **USB Type A to Type C** cable will help you with the transition to USB C, even if you're still totin' around a USB Type A hub, computer or laptop.

USB C is the latest industry-standard connector for...

In Stock
[Buy Now](https://www.adafruit.com/product/4474)
[Related Guides to the Product](https://learn.adafruit.com/products/4474/guides)
![Angled shot of a coiled black, USB-C to USB-A cable.](https://cdn-shop.adafruit.com/640x480/4474-02.jpg)


## Guide Products

### Adafruit Feather RP2040 with DVI Output Port - Works with HDMI

[Adafruit Feather RP2040 with DVI Output Port - Works with HDMI](https://www.adafruit.com/product/5710)
Wouldn't it be cool if you could display images and graphics from a microcontroller directly to an HDMI monitor or television? We think so! So we designed this RP2040 Feather that has a digital video output (a.k.a DVI) that will work with any HDMI monitor or display. Note it doesn't do...

Out of Stock
[Buy Now](https://www.adafruit.com/product/5710)
[Related Guides to the Product](https://learn.adafruit.com/products/5710/guides)
### Adafruit Feather RP2040 with USB Type A Host

[Adafruit Feather RP2040 with USB Type A Host](https://www.adafruit.com/product/5723)
You're probably really used to microcontroller boards with USB, but what about a dev board with two? Two is more than one, so that makes it twice as good! And the&nbsp; **Adafruit Feather RP2040 with USB Host** is **&nbsp;** definitely double-the-fun of our other Feather...

Out of Stock
[Buy Now](https://www.adafruit.com/product/5723)
[Related Guides to the Product](https://learn.adafruit.com/products/5723/guides)
### Adalogger FeatherWing - RTC + SD Add-on For All Feather Boards

[Adalogger FeatherWing - RTC + SD Add-on For All Feather Boards](https://www.adafruit.com/product/2922)
A Feather board without ambition is a Feather board without FeatherWings! This is the **Adalogger FeatherWing** : it adds both a battery-backed Real Time Clock and micro SD card storage to any Feather main board. Using our [Feather...](https://www.adafruit.com/products/2830)

In Stock
[Buy Now](https://www.adafruit.com/product/2922)
[Related Guides to the Product](https://learn.adafruit.com/products/2922/guides)
### HDMI 5" Display Backpack - Without Touch

[HDMI 5" Display Backpack - Without Touch](https://www.adafruit.com/product/2232)
It's a mini panel-mountable HDMI monitor! So small and simple, you can use this display with any computer that has HDMI output, and the shape makes it easy to attach to a case or rail. This backpack features the TFP401 for decoding video and includes the attached display, so it's...

Out of Stock
[Buy Now](https://www.adafruit.com/product/2232)
[Related Guides to the Product](https://learn.adafruit.com/products/2232/guides)
### FeatherWing Tripler Mini Kit - Prototyping Add-on For Feathers

[FeatherWing Tripler Mini Kit - Prototyping Add-on For Feathers](https://www.adafruit.com/product/3417)
This is the **FeatherWing Tripler** - a prototyping add-on and more for all Feather boards. This is similar to our [FeatherWing Proto](https://www.adafruit.com/products/2884) except there are three! The magic of the Tripler comes when you want to connect your Feather to...

In Stock
[Buy Now](https://www.adafruit.com/product/3417)
[Related Guides to the Product](https://learn.adafruit.com/products/3417/guides)
### SD/MicroSD Memory Card (8 GB SDHC)

[SD/MicroSD Memory Card (8 GB SDHC)](https://www.adafruit.com/product/1294)
Add mega-storage in a jiffy using this 8 GB class 4 micro-SD card. It comes with a SD adapter so you can use it with any of our shields or adapters. Preformatted to FAT so it works out of the box with our projects. Tested and works great with our <a...></a...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/1294)
[Related Guides to the Product](https://learn.adafruit.com/products/1294/guides)
### 512MB micro SD Memory Card

[512MB micro SD Memory Card](https://www.adafruit.com/product/5252)
Add storage in a jiffy using this **512MB** microSD card. Preformatted to FAT32, so it works out of the packaging with our projects. Works great with any device in the Adafruit shop that uses microSD cards. Ideal for use with Feathers, data loggers, or small Linux SBCs (not good...

In Stock
[Buy Now](https://www.adafruit.com/product/5252)
[Related Guides to the Product](https://learn.adafruit.com/products/5252/guides)
### USB MicroSD Card Reader/Writer - microSD / microSDHC / microSDXC

[USB MicroSD Card Reader/Writer - microSD / microSDHC / microSDXC](https://www.adafruit.com/product/939)
This is the cutest little microSD card reader/writer - but don't be fooled by its adorableness! It's wicked fast and supports up to 64 GB SDXC cards! Simply slide the card into the edge and plug it into your computer. No drivers are required, it shows up as a standard 'Mass...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/939)
[Related Guides to the Product](https://learn.adafruit.com/products/939/guides)

## Related Guides

- [Adafruit Feather RP2040 with DVI Output Port](https://learn.adafruit.com/adafruit-feather-rp2040-dvi.md)
- [Adafruit Feather RP2040 with USB Type A Host](https://learn.adafruit.com/adafruit-feather-rp2040-with-usb-type-a-host.md)
- [Adafruit Fruit Jam](https://learn.adafruit.com/adafruit-fruit-jam.md)
- [Fruit Jam, Zork and the Z Machine](https://learn.adafruit.com/zork-and-the-z-machine.md)
- [MagTag IoT Menorah](https://learn.adafruit.com/magtag-iot-menorah.md)
- [Arcade Synth Controller](https://learn.adafruit.com/arcade-synth-controller.md)
- [NeoTrellis MIDI Feedback Controller](https://learn.adafruit.com/neotrellis-midi-feedback-controller.md)
- [Arcade Fightstick](https://learn.adafruit.com/arcade-fightstick.md)
- [Wireless Control Button for WLED Projects](https://learn.adafruit.com/wireless-control-button-for-wled-projects.md)
- [Egg Hunt Maze Game on Fruit Jam](https://learn.adafruit.com/egg-hunt-maze-game-on-fruit-jam.md)
- [CircuitPython Trombone Champ Controller](https://learn.adafruit.com/circuitpython-trombone-champ-controller.md)
- [Split Ortho Keyboard with TCA8418 Matrix Expanders](https://learn.adafruit.com/split-ortho-keyboard.md)
- [BLE HID Keyboard Buttons with CircuitPython](https://learn.adafruit.com/ble-hid-keyboard-buttons-with-circuitpython.md)
- [Pi Hole Ad Detection Display with PiTFT](https://learn.adafruit.com/pi-hole-ad-pitft-tft-detection-display.md)
- [Logic Gates Simulator on Fruit Jam](https://learn.adafruit.com/logic-gates-simulator-on-fruit-jam.md)
- [Fruit Jam Nintendo Entertainment System and Retro Jam](https://learn.adafruit.com/fruit-jam-nintendo-entertainment-system.md)
- [Qualia S3 Compass](https://learn.adafruit.com/qualia-s3-compass.md)
- [Adding a Bubble Level to the MEMENTO](https://learn.adafruit.com/adding-a-bubble-level-to-the-memento.md)
