News:

The Savage///Circuits website has been upgraded to a more efficient theme.

Main Menu

Z80 Emulation Using the RP2040

Started by Chris Savage, Dec 31, 2025, 09:05 AM

Previous topic - Next topic

granz

Got ya, sorry about taking so long. I'll get the board set up tomorrow.

granz


Chris Savage

Quote from: granz on Jun 03, 2026, 03:50 PMNext post - steps to assemble the system.

Will this work with the original parts I bought for both of us?

                     Bringing concepts to life through engineering.

granz

Quote from: Chris Savage on Jun 03, 2026, 10:07 PMWill this work with the original parts I bought for both of us?
Yes.

Although, I did get the RP2040-GEEK to work, and it is less than half the price (only $16.31 from Amazon - https://www.amazon.com/RP2040-GEEK-Development-Raspberry-Microcontroller-Downloader/dp/B0CG82MKWC.) The only thing that would need to be added would be the micro SD Card.

This would also eliminate the need to wire the thing up (and also eliminate the possibility of mistakes in wiring.)

The only thing remaining for this is for me to figure out how to work with .DSK files so that I can remove the extraneous stuff, and add the editor and assembler/linker.

So, I am also continuing work on the RP2040-GEEK version, in addition to the original.

granz

#109
Setting up the hardware

This is the pinout of the Raspberry Pi Pico:


Step 1:

Start by inserting the Raspberry Pi Pico into the breadboard. You will need to press pretty firmly to get the Pico to seat all the way to the breadboard. Be careful to avoid pressing on the Pico's pins - the can hurt your fingers.

Step 2:

Next insert the SD card breakout into the breadboard, as shown. Don't insert the SD card into the socket before you put the breakout into the breadboard as you will need to add the CP/M files in the Software step.

Step 3:

Take a close look at the pin labels on the breakout. You should notice that they are, from left to right:
  • GND - Ground
  • VCC - +Voltage
  • MISO - Master In Slave Out
  • MOSI - Master Out Slave In
  • SCK - System Clock
  • CS - Card Select
If you are using a different SD card breakout, you will need to verify the pinout of the breakout and adjust these directions per your card.

Step 4:

In wiring up the SD card breakout, start off with the power connections. Connect a black jumper to pin 38 of the Pico module. Then connect the other end of that jumper to the left-most pin of the breakout. Use a red jumper to connect pin 36 of the Pico to the next breakout pin to the right. These will provide the power required for your SD card. Only four more to go.

Step 5:

Use different colored jumpers to connect up the rest of the SD card breakout.

Going from the red VCC pin on the breakout board, going right:
  • MISO - Pico pin 21 (white)
  • MOSI - Pico pin 25 (yellow)
  • CS - Pico pin 22 (blue)
  • SCK - Pico pin 24 (orange)
The colors listed are the colors that I used, you may use whatever colors are convenient to your board. Try to avoid black, and red, as those are the standard colors for power connections.

Next, we install the RunCPM firmware, and then set up the CP/M files in the Software step.

Edited to add Pico pinout at top of post.

granz

Next installment:
(The below is actually in a Word document, and the above assembly instructions will be incorporated before I release it. This is for you to check over for accuracy, and to make sure that this is along the lines of what you want.)

QuoteWelcome to the Savage Circuits Z80 Assembly introduction course. One of the down sides of having the latest, and greatest, IT systems is that the foundations of computers is hidden by the complexities of modern systems. The older systems, such as the early microprocessors, are simpler and thus easier to understand.

In 1974, the Zilog company came out with their first 8-bit processor chip. The Z80 chip was very popular, and was used in many home, and office, computers during the 1970s, and early 1980s. Even today, there are many Z80 computer systems being used in different products such as calculators, industrial control systems, cars and other devices. Recently, Zilog ceased production of the Z80 chips themselves, however they still produce descendants of the Z-80 in their eZ80 micro-controllers, and other chips. In addition to that, there are several companies which have licensed the Z80 design from Zilog, and produce many Z80 chips still for sale. The Open Source community also has at least a few Open Source Z80 designs that can run all Z80 software.

Because of the simplicity of the Z80 (compared to modern CPUs) we have decided to use the Z80 as the basis for learning about the basics of computers.

All computers operate on electronics, and perform their commands based on voltage levels. A typical command to the computer to load the accumulator (a small memory located inside the CPU) with a number would look like: 0V, 0V, +5V, +5V, +5V, +5V, +5V, 0V on the eight data lines going to the CPU. This would be followed by different voltage levels on the data lines to represent the number to be stored in the accumulator.

To make things a bit easier for humans to understand, those voltage have been associated with numbers.  The above example would be represented as: 0 0 1 1 1 1 1 0

In its most fundamental level, computer programs are made up of nothing more than numbers. These numbers, referring to programming steps, are called the computer's machine language. This is the foundation of all computer programming.

While numbers are natural for computers, pure numbers are more difficult for humans. Thus very quickly computer programmers substituted abbreviations, or mnemonics (memory aids,) for those numbers. In the Z80 example above that command to load a number into the accumulator would be LD A (for load to the accumulator.) These abbreviations are called Assembler Language. Since this is the lowest level language that is convenient for humans, we will introduce you to programming in Assembly Language to teach the fundamentals of computers.
In order to write programs for an early computer, like one based on the Z80, you would need to get some kind of Z80 computer system. First, you could get an old computer based on the Z80, such as an old Radio Shack TRS-80, or a ZX81 from Sinclair Research. This would be the most historically accurate way to learn about computing basics. These old computers are available from eBay, and other places, or you could get one from a thrift/second-hand store. Since these computers are older, they often need to be repaired after you obtain them. They also often need to be repaired while using them, making use of these old computers more complex – especially if you want to learn about the basics of computer programming, and not concern yourself with the upkeep of your computer.

Second, you can get an emulator, or a program that makes your modern home computer pretend to be one of the older Z80 computers. There are many of these available throughout the Internet. These emulators can give a feeling of the old computer, and are available for low cost, and often for free. While this works, emulator programs tend to feel a bit artificial. You lose a bit of the feel of the old computers.

The third option is to use a mixture of the first, and second, options. There have been huge increases in the hardware capabilities of computers. There are modern micro-controllers (devices which have all, or most of the components of a full computer on a single integrated circuit – IC,) which are far more powerful than the older computers from the 1970s. Emulator programs have been written that let micro-controllers run software written for the older computers. These emulators take the machine language programs, and convert them to the micro-controllers language.

The Raspberry Pi Foundation, famous for their Raspberry Pi computers, has come out with a micro-controller called the RP2040. They then designed, and sell, a tiny printed circuit board called the Raspberry Pi Pico. This is one of the easiest micro-controller systems for beginners to learn, and use. The RP2040 controller is far faster, and much more powerful than any of the Z80 systems from the 1970s. In fact people have actually produced programs for this chip to emulate many different older computers.

A person, whose handle is MockbaTheBorg, created an emulator program for the Z80 (called RunCPM - https://github.com/MockbaTheBorg/RunCPM) when he was doing some restoration work on an old Z80 programming language. CP/M (Control Program for Microcomputers) is an operating system often used in Z80-based systems. This emulator ran on his main computer, and allowed him to quickly test his programming work. Another person, called GuidoL70, rewrote that RunCPM emulator (https://github.com/guidol70/RunCPM_RPi_Pico) to run on the Raspberry Pi Pico. This system allows you to have the experience of running a full Z80 system. Your computer acts as an old computer terminal, and you can cheaply, and easily, learn Z80 programming on this simple system.
In this course you will set up a low-cost system to emulate a full Z80 computer with the RunCPM System. If you have purchased the kit from Savage Circuits you have everything that you need. If you are purchasing your own kit, you will need the following items (which may be purchased from Amazon):

·    SD Card Breakout (2 ea) - $5.49 - https://www.amazon.com/DIYables-Adapter-Arduino-ESP8266-Raspberry/dp/B0BXKLNN2L
·    Raspberry Pi Pico H w/ USB Cable - $11.42 - https://www.amazon.com/Microcontroller-Development-Pre-Soldered-Dual-Core-Multi-Function/dp/B0DSBQS5ZF/ *
·    830 Point Breadboard - $4.59 - https://www.amazon.com/California-JOS-Breadboard-Solderless-Distribution/dp/B0BRQX6G3T/ *
·    1 GB Micro SD Card - $8.99 - https://www.amazon.com/Lerdisk-Wholesale-1GB-Produced-Authorized/dp/B0D3KWY34B ***
·    Hookup Wire - $6.19 - https://www.amazon.com/MECCANIXITY-Breadboard-Electronics-Electronic-Projects/dp/B0F1YDQ53Q
* Note: the Raspberry Pi Pico comes with an additional 3-pin male header. This is not used in this tutorial, and may be ignored.
** Note: this breadboard comes with jumper wires. Unfortunately, there is no telling which kind of jumper that you will get. It is better to use the known male-to-male jumpers that are listed above, for this project, and ignore the ones included with the breadboard.
Total - $36.68 plus sales tax and shipping (shipping is free with Amazon Prime membership) If you are an electronics hobbyist, you may have some, or all, of these in your parts bin, but these items are easy to order for a beginner.
To this computer, we will add an editor to write the program, and an Assembler program to convert the assembly mnemonics into the ones, and zeros, making up the machine language program. There is also a program called a Linker to convert the machine language to run on the specific system as we mentioned above. This linker is included in the assembler program that we will use.
This will all be a single file to download from Savage Circuits web site.

granz

Okay, here is the document, as it stands:

https://files.granzeier.com/Downloads/SavageCircuits/RunCPM/Manual%20-%202026-06-12.doc

The next section is the installation of the firmware, and the CP/M O/S software and then the editor and assembler.

After that we will present an introduction to writing code to run Z80 assembly language under CP/M. Included will be a quick intro to the editor followed by an introduction to the assembler.

We will then close with directions for further work on the subject: books/manuals on the editor, assembler and CP/M and some web sites for followup work.

SMF spam blocked by CleanTalk