A computer won't do you much good without software. We need some way to start the system and get data in and out. In a microcomputer this is often referred to as
the monitor. It's a small piece of software, usually in ROM, that handles basic functions like putting characters on the screen, reading from the keyboard, loading data and executing code. My monitor is loosely based on Motorola's MIKBUG but with some changes and additions.
The main functions on the MC3 monitor
- Initializes the system after reset
- Sets up a vector jump table for various functions
- Handles the serial console
- Loads S19 files into memory
- Display contents of memory
- Modify contents of memory
- Examine stack contents and stack position
- Manual I/O page select
Reset sequence
1. Initialize stack pointer
2. Initialize vector table
3. Initialize serial interface
4. Select initial I/O page (page 7)
5. Disable CPU internal RAM
6. Goto prompt
Commands in the monitor
-
G Go (RTI)
-
J Jump to address
-
L Load S19 from console
-
MC Memory change
-
MD Memory dump
-
RR Print contents of stack
-
RS Reset stack pointer
-
RC Change stack CC
-
RA Change stack A
-
RB Change stack B
-
RX Change stack X
-
RP Change stack PC
-
P Select I/O page
Vector table
The monitor sets up a vector table in RAM for access to various routines. Each vector consists of three bytes. A jump ($7E) and then the address to the routine. This allows software to use different routines for these functions.
CONSVEC EQU $7FE5 CONSOLE STATUS VECTOR
CONOVEC EQU $7FE8 CONSOLE OUTPUT VECTOR
CONIVEC EQU $7FEB CONSOLE INPUT VECTOR
TMOFVEC EQU $7FEE TIMER OVER FLOW INTERUPT VECTOR
TMOCVEC EQU $7FF1 TIMER OUTPUT COMPARE INTERUPT VECTOR
TMICVEC EQU $7FF4 TIMER INPUT CAPTURE INTERUPT VECTOR
IRQVEC EQU $7FF7 IRQ INTERUPT VECTOR
SWIVEC EQU $7FFA SWI INTERUPT VECTOR
NMIVEC EQU $7FFD NMI INTERUPT VECTOR
The interrupt vectors are a mirror of the CPU vectors. After initialization these all points to an RTI that effectively disables the interrupt. One exception is the SWI vector that points to a stack printout and then back to the monitor prompt. Pressing 'G' will continue execution after an SWI. The three vectors for handling the console I/O are CONSVEC, CONOVEC and CONIVEC. Think of them as stdin and stdout in the Unix world. They point to the routines for the console interface and can be changed and redirected for other output or input.
CONSVEC - Status vector. Returns the number of characters in buffer in A-acc.
CONIVEC - Input vector. Returns a character in A-acc.
CONOVEC - Output vector. Sends a character in A-acc.
Jump table
The beginning of the monitor ROM consists of a jump table to common routines further into the ROM.
RETURN EQU $C000 RETURN TO PROMPT
OUTCHAR EQU $C003 OUTPUT CHAR ON CONSOLE
INCHAR EQU $C006 INPUT CHAR FROM CONSOLE AND ECHO
PDATA EQU $C009 PRINT TEXT STRING @ X ENDED BY $04
OUTHR EQU $C00C PRINT RIGHT HEX CHAR @ X
OUTHL EQU $C00F PRINT LEFT HEX CHAR @ X
OUT2HS EQU $C012 PRINT 2 HEX CHARS @ X
OUT4HS EQU $C015 PRINT 4 HEX CHARS @ X
INHEX EQU $C018 INPUT 1 HEX CHAR TO A. CARRY SET = OK
INBYTE EQU $C01B INPUT 1 BYTE TO A. CARRY SET = OK
BADDR EQU $C01E INPUT ADDRESS TO X. CARRY SET = OK
The reason for using a jump table is that the contents of the monitor ROM can be altered without affecting these addresses meaning that programs utilizing these routines will not have to be changed.
Example program
Hello world utilizing routines in the MC3 monitor
RETURN EQU $C000 RETURN TO PROMPT
PDATA EQU $C009 PRINT TEXT STRING @ X ENDED BY $04
ORG $0100
0100 CE 0109 LDX #HELLOTX
0103 BD C009 JSR PDATA
0106 7E C000 JMP RETURN
0109 0D 0A HELLOTX FCB $0D,$0A
010B 48 65 6C 6C FCC "Hello World"
010F 6F 20 57 6F
0113 72 6C 64
0116 04 FCB $04
Download MC3 monitor 1.1
-
source
-
listing
-
S19