Z80 Software Source Code
Project Description
This page has download links to sources for various pieces of software that I have
worked on and customized, produced from scratch, or great packages I have
built from sources.. You may find some of the bits and pieces useful. These
packages are all configured for the FPGA_Z80 board running my custom FPGA image based
on Grant Searles work.
Download links are at the bottom of this page.
- DS1305.C - This is a bit of C code that talks to a DS1305 Real Time Clock chip.
It can be run in an interactive mode which lets one explore all the functionality
of the chip like reading the time, setting the time, setting alarms, reading and writing
individual registers, setting CPM3 system time from the RTC, and reading and writing to
the nonvolatile ram area. It can also be called from the startup file PROFILE.SUB
to set the CPM3 clock from the RTC chip (Use "ds1305 S" as the command line). The code
directly interfaces to 3 output bits and 3 input bits of a port to implement a bit banged SPI
protocol to talk with the chip. I use this code with my FPGA_Z80 board. This code is written
to be compiled by BDS C version 1.6.
The above image shows the logic analyzer results when bit banging a byte write command
to location 37 (25H) with a data word of 15 (0FH). Note the 16 bit command/data on the SDI line
being clocked by the falling edge of the SCLK line. The first bit is a one, indicating a write command,
the next 7 bits are the address of 25H. The following 8 bits are 0FH. The whole command
takes about 2.1ms to send to the RTC.
The above image shows bit banging a read command of address 25H. The first 8 bits
on the SDI line is the read command and address. The next 8 bits on the SDO line (0FH) is
the data being sent back from the RTC chip. Again, the sequence takes right around 2ms to complete.
The SCLK signal is a little different shape between the write and read portions of the cycle due to an extra
instruction in the write loop. This is insignificant as the SPI data all depends on the falling edge
of the SCLK.
- CWTUTOR2.ASM - This 8080 assembler code uses the buzzer output on the FPGA_Z80 board to
send code practice in various forms at 25WPM. It can run character by character practice,
random 5 letter groups in 2 formats, 500 common english words, or continuous
"PARIS " strings to calibrate the WPM speed.
- SCBTIME.ASM - This assembly language program displays the raw time variables
used internally by CPM3. It was very helpful in debugging various CPM time related routines.
The CPM command "DATE" can be used to set the SCB variables to various dates and these
can then be dumped using this utility and compared with data generated by user programs that
manipulate the system time. The big challenge in setting the CPM time from
a real time clock chip is that the clock chips use a variety of representations
for the time in their internal registers. This RTC internal format must be converted
to the 5 byte long CPM3 time structure format. You can look at the source for the
DS1305 project above to see how this can be accomplished.
- FIND.ASM - This assembly language program searches a range of files for a specified character string.
It is like a simple version of the unix grep utility. The specified range of files are searched for the
given string and when found, the line number and the contents of the line are displayed.
- U2CPM.C - This C program scans through text file and converts all the line endings to the CPM standard
of CRLF. This works for files edited on Mac, Linux, or Windows. It also adds a ^Z to the end of the file to
conform with the CPM text file standard. This utility really helps clean up imported files that have
been edited on foreign systems. Most of the CPM compilers and assemblers are quite picky on the line endings
used in their input source files. This file compiles using BDS C 1.6.
- KERMIT - This is one of the classic programs used to communicate between assorted computers.
I use this program daily to pass files between my linux box running ckermit in server mode and my FPGA_Z80
board. The program uses the CPM console (typically a USB serial port on P12) for
user interaction and a second serial port (CPM AUX:) that is running on my
repurposed printer port connector for streaming the kermit data to the host. This is a big
complicated program, but I pretty much just use the "SEND" and "GET" commands. I did not do
any significant modifications to the code but wanted it archived here as a working example.
see the file KERMIT.TXT for instructions on configuring and building from source. You will need
lasm and mload to assemble and generate the .com file for this package.
- XMODEM 2.7 - This is another of the classic programs used to communicate between assorted computers.
The program uses the CPM console (typically a USB serial port on P12) for
user interaction and a second serial port that is running on my
repurposed printer port connector for streaming the xmodem data to the host.
I did not do any modifications to the code as I was able to setup the wanted
serial configuration in the XMODEM.CFG file.
- LS - An alternate disk file listing utility. It is similar to the CPM command "DIR",
but I have it configured to list 3 columns of sorted file names with the details on each file
including filename, size in bytes, user area on disk and the file attributes (like [sys]).
I typically use it if I am trying to find a file on the disk and I dont know
the user area. The stock "dir" command just lists non system files in
the current user area, while this "ls" command lists all the files on the
current disk.
- LIFE.C - A simple version of John Conways game of life converted to
compile using BDS C 1.6 and run on a VT100 compatible terminal. This version
just creates random initial cells and runs them through multiple mutations.
Serial terminals kind of suck for graphics displays, but in its time
this was mesmerizing to watch. A good screen saver display to use in
the background while you are on a zoom call.
Source Code
Source Code - DS1305.C (21K) - utility to test operation of DS1305 RTC via bit banged SPI
Source Code - CWTUTOR2.ASM (43K) - morse code receive training
Source Code - SCBTIME.ASM (5K) - display CPM3 time variables from system control block (SCB)
Source Code - FIND.ASM (8K) - A utility like grep. Finds a specified string in a range of files
Source Code - U2CPM.C (3K) - A utility that converts line endings to match the CPM standard (CRLF)
Source Code - KERMIT.ZIP (200K) - Classic computer to computer file transfer program
Source Code - XMODEM.ZIP (31K) - Another classic computer to computer file transfer program
Source Code - LS.ASM (60K) - A very nice disk file listing command (similar to CPM3 DIR)
Source Code - LIFE.C (4K) - A fun block graphics version of John Conways game.