;*************************************************************************** ; PROGRAM: Z80 Monitor ; PURPOSE: ROM Monitor Program ; ASSEMBLER: TASM 3.2 ; LICENCE: The MIT Licence ; CREATED: 05 May 2015 by MCook ; UPDATED: 12 Dec 2018 by Peter Murray, Don Prefontaine ;*************************************************************************** ROM_BOTTOM: .EQU $0000 ; Bottom address of ROM. ROM_TOP: .EQU $7FFF ; Top address of ROM. RAM_BOTTOM: .EQU $8000 ; Bottom address of RAM. RAM_TOP: .EQU $FFFF ; Top address of RAM. UART_BASE: .EQU $08 ; Base address for the UART. EOS: .EQU $00 ; End of string delimiter. ;PPI_BASE: .EQU $00 ; Base address for 8255 PPI. DELAY_LCD: .EQU $0220 ; 1.6ms. LCD initialization time. ;************ .ORG $0000 START: DI ; Disable interrupts. JP MAIN ; Jump to the MAIN routine. ;************ .ORG $0038 INT_CATCH: JP INT_CATCH ; Infinite loop to catch interrupts (not enabled). ;************ .ORG $0066 NMI_CATCH: JP START ;JP NMI_CATCH ; Infinite loop to catch interrupts (not enabled). ;************ .ORG $0100 ;*************************************************************************** ;MAIN ;Function: Entrance to user program ;*************************************************************************** MAIN: LD SP, RAM_TOP ; Initialize the stack pointer. CALL UART_INIT ; Initialize UART. CALL PRINT_MON_HDR ; Display the ROM Monitor header info. JP MON_PROMPT_LOOP ;*************************************************************************** ;CLEAR_SCREEN ;Function: Clears terminal screen ;Three methods: ; MON_CLS: .BYTE "\f",EOS ; Escape character (aka form feed) for CLS. ; or ; ESC: .EQU $1B ; MON_CLS: .BYTE ESC,"[2J",ESC,"[f",EOS ; ANSI/VT100 escape codes sequence ; or ; 24 NEWLINES. ;*************************************************************************** CLEAR_SCREEN: LD BC, 24 ; 24 Newlines to clear the screen. CLS: PUSH BC CALL PRINT_NEW_LINE POP BC DJNZ CLS RET ;*************************************************************************** ;RESET_COMMAND ;Function: Software Reset to $0000 ;*************************************************************************** RESET_COMMAND: JP START ; Jumps to $0000 (reset). ;*************************************************************************** ;PRINT_MON_HDR ;Function: Display program header info ;*************************************************************************** MON_MSG: .BYTE "\r\n\t *** ZMC80 Computer ***\r\n\r\n 2015 MCook. Expanded 2018 PMurray, DPrefontaine\r\n\r\n",EOS MON_VER: .BYTE "\t ROM Monitor v1.2 2018-12-12\r\n\r\n\r\n",EOS MON_HLP: .BYTE "\t Input ? for command list\r\n\r\n",EOS PRINT_MON_HDR: CALL CLEAR_SCREEN ; Clear the display screen. LD HL,MON_MSG ; Display first of three messages. CALL PRINT_STRING LD HL,MON_VER ; Display second of three messages. CALL PRINT_STRING LD HL,MON_HLP ; Display third of three messages. CALL PRINT_STRING RET ;*************************************************************************** ;MON_PROMPT ;Function: Prompt user for input ;*************************************************************************** MON_PROMPT: .BYTE "MON>",EOS MON_PROMPT_LOOP: LD HL,MON_PROMPT ; Display monitor prompt. CALL PRINT_STRING CALL UART_RX ; Get a character from user into Acc... CALL PRINT_CHAR ; ...and print it. CALL PRINT_NEW_LINE ; Display a new line. CALL MON_COMMAND ; Respond to user input. CALL PRINT_NEW_LINE ; Display a new line. JP MON_PROMPT_LOOP ; Repeat indefinitely. ;*************************************************************************** ;MON_COMMAND ;Function: User input in accumulator to respond to ;*************************************************************************** MON_COMMAND: CP '?' CALL Z,HELP_COMMAND CP 'D' CALL Z,MEMORY_DUMP_COMMAND CP 'd' CALL Z,MEMORY_DUMP_COMMAND CP 'C' ; CALL Z,CLEAR_SCREEN ; CP 'c' ; CALL Z,CLEAR_SCREEN ; CP 'W' CALL Z,MEMORY_WRITE_COMMAND CP 'w' CALL Z,MEMORY_WRITE_COMMAND CP 'R' CALL Z,MEMORY_READ_COMMAND CP 'r' CALL Z,MEMORY_READ_COMMAND CP 'O' CALL Z,IO_WRITE_COMMAND CP 'o' CALL Z,IO_WRITE_COMMAND CP 'I' CALL Z,IO_READ_COMMAND CP 'i' CALL Z,IO_READ_COMMAND CP 'G' CALL Z,GO_COMMAND CP 'g' CALL Z,GO_COMMAND CP 'X' CALL Z,RECEIVE_COMMAND CP 'x' CALL Z,RECEIVE_COMMAND CP 'M' CALL Z,MemoryFillCommmand CP 'm' CALL Z,MemoryFillCommmand CP 'T' CALL Z,MEMTestCmd CP 't' CALL Z,MEMTestCmd CP 'B' ; CALL Z,MemoryBlockCommmand ; CP 'b' ; CALL Z,MemoryBlockCommmand ; RET DELAY: ; Unused delay routine. LD HL, DELAY_LCD ; loopDELAY: ; NOP ; NOP ; DEC L ; JP NZ, loopDELAY ; DEC H ; JP NZ, loopDELAY ; RET ; #INCLUDE "Monitor-Commands_DON.asm" ; Eleven monitor commands for execution. #INCLUDE "Binary-File-RX.asm" ; Transfer PC file to Z80 RAM using TeraTerm SendFile function. #INCLUDE "UART-Driver_DON.asm" ; UART initialization, ASCII sending/receiving. #INCLUDE "Console-IO_DON.asm" ; Send/receive valid characters and hex bytes. .END