Home

Z80  Programming VII - Part 2

ROM Monitor: ROM-Monitor_DON.ASM

Back to Part 1             Forward to Part 3

Overview:

Several programs have been assembled to create the ROM Monitor. They are listed at the bottom of the main assembly file ROM-Monitor_DON.asm in the adjacent screenshot.

We're going to examine the content of all of the files and the functions they create or support, and we'll begin by examining this file which we're displaying in "chunks" on the right.

 

ROM-Monitor_DON.asm is our main file. It's the file we assemble with TASM v3.2. At the bottom of the file are all of the other files the assembler is expected to open and parse when it creates the ROM-Monitor_DON.lst listing file. If you recall, this file contains both assembly and machine code.

Let's have a look at it. Starting in line 10, we declare all necessary variables. You may need to change ROM_TOP to $3FFF for some hardware implementations. The delay routine in line 17 is not used in this monitor but it will be if we add a 4x20 LCD panel and code to this monitor. More on that later.

PPI Base has been commented out. As we add more devices to this configuration, the 8255 PPI will probably be moved to I/O address $38 to make room.

 

There are 4 .ORG statements near the beginning of our ROM-Monitor_DON.asm file. (Recall that .ORG tells the assembler to start assembling code "here". If your only .ORG statement in your code was $0100, then that is what you could expect to see your program start its addressing at in the .lst file.)

 

.ORG $0000    This is from where the Z80's Program Counter (PC) will boot. Line 23 forces the PC to jump to line 43 for the MAIN function where our ROM Monitor program really starts.

 

.ORG $0038    This is where Interrupts (when enabled) will normally jump to. As you can see, we have put the Z80 into an infinite loop because there are no interrupts in our hardware or software so the PC should not go here. In total, there are 8 software restart locations (page 61 of the Z80 CPU manual).

 

.ORG $0066    If a non-maskable interrupt occurs (maybe we pushed the NMI button), this is to where the PC will jump.  In this case, it will be forced back to label START which takes it to MAIN (line 43) where our program starts. You can read  more about location $0066 on page 13 of the Z80 CPU manual.

 

.ORG $0100    This is where we have chosen to start running our monitor program. We don't really need to use this statement because the PC would simply advance to the next available memory location after the instruction in line 33, but we'll use it anyway for the sake of consistency when we later build our routine_entry.asm file. File routine_entry.asm is used when building separate standalone apps so they can reference the calls made in the main program like our ROM monitor, ROM-Monitor_DON.asm.

 

Finally our program starts in line 44: we load the Stack Pointer with the top of RAM address which is most likely  $7FFF or $FFFF, depending on how you've configured your hardware jumpers and your "equates" like line 13.

Our program will perform the next 3 commands and then it's "finished":

CALL UART_INIT

CALL PRINT_MON_HDR

JP MON_PROMPT_LOOP

 

If you attempt to use <CTRL>F to "Find" the label "UART_INIT:" in the ROM-Monitor_DON.asm file , it will not succeed because that software routine is in a different file, specifically line 26 of file UART-Driver_DON.asm. Instead, search for it in ROM-Monitor_DON.lst that contains the assembled code for all of the files listed as "INCLUDES" at the bottom of ROM_Monitor_DON.asm.

 

If you have ROM-Monitor_DON.asm open, you can see various functions start in line 49 including CLEAR_SCREEN, RESET_COMMAND, PRINT_MON_HDR, MON_PROMPT, and MON_COMMAND. We'll talk about them on the next web page.

NEXT PAGE  =>

TOP

Home