Z80 Monitor

ROMMonitorPIC1

Our system is just a heap of silicon unless it has some code to run. I don’t think the hardware is quite at the point of running an operating system like CP/M yet, but that doesn’t mean we can’t do anything. We can hit the assembly and build up some code in our ROM chip. We can make a ROM monitor.

A ROM monitor is just the code in a ROM chip which runs as soon as the system is turned on. The monitor provides essential functions such as to load RAM or check the hardware before running the operating system. In our case I have not quite ironed out what those will be. For this very preliminary monitor code I wanted to have some basic functions that will be useful later (as I learn more assembly). They are as follows,

ZMC80 Monitor Command List
? - view command list
R - monitor reset
C - clear screen
D - print $50 bytes from specified location

The first three commands are rather simple just printing messages to the screen or going back to the beginning of the ROM with a “reset”. The memory dump command is a bit more complex however. This command prints $80 bytes from a user specified location. This in itself is a very complex operation since you have to convert characters to hex and back to characters. This was a bit of a challenge which started to produce a very cumbersome file.  So the monitor is broken up into four files,

Z80Monitor.asm
UARTDriver.asm
MONCommands.asm
CONIO.asm

The routines in these four files are specific to certain tasks. Such as ‘UARTDriver.asm’, which contains routines for the 16550 UART chip. These functions are abstracted later as in the PRINT_STRING routine which just calls the UART_PRNT_STR routine. This level of abstraction is meant for instances such as if I switch later from using the UART to print to the terminal and instead print to a another medium I can implement a driver file for that medium without having to overhaul a lot of other routines that reference PRINT_STRING and not UART_PRNT_STR. This technique is implemented in a few places in the code, but I am sure it could be a lot more efficient. As I develop the monitor I may shuffle some routines around.

I hope to optimize the code as I write the routines for the monitor. I am not great at assembly, but I am learning. I have a bit of style/structure to the code that makes it more readable than most of the Z80 assembly code I  have seen online. I will maintain this style for all of the code … hopefully.

None of the hardware has changed so only code this time around.

If you have any suggestions for routines or code that could be beneficial leave a comment below.

All Files from this project can be downloaded from my GitHub Repository,

Z80 Project Repository

This slideshow requires JavaScript.

About Matt Cook

Computer Engineer
This entry was posted in Uncategorized and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s