Compare commits
3 Commits
TerminalWi
...
monitor-in
Author | SHA1 | Date | |
---|---|---|---|
08b32b2064 | |||
b98ad3e136 | |||
3ebf35fa77 |
@ -1,6 +1,6 @@
|
|||||||
Sys_ABI: equ $0003
|
Sys_ABI: equ $0081
|
||||||
Sys_Beep: equ $0013
|
Sys_Beep: equ $0091
|
||||||
Sys_Print: equ $0007
|
Sys_Print: equ $0085
|
||||||
Sys_Printc: equ $000a
|
Sys_Printc: equ $0088
|
||||||
Sys_Readc: equ $000d
|
Sys_Readc: equ $008b
|
||||||
Sys_Readline: equ $0010
|
Sys_Readline: equ $008e
|
||||||
|
@ -19,9 +19,21 @@ jp Sysinit ; Startup vector: DO NOT MOVE! Must be the first instruction
|
|||||||
; I/O 6 (0xC0 - 0xDF)
|
; I/O 6 (0xC0 - 0xDF)
|
||||||
; I/O 7 (0xE0 - 0xFF)
|
; I/O 7 (0xE0 - 0xFF)
|
||||||
|
|
||||||
|
; **** RESET/INTERRUPT VECTOR ****
|
||||||
|
|
||||||
|
; Maskable interrupt mode 1: when the BREAK key is pressed,
|
||||||
|
; a maskable interrupt is generated and the CPU jumps to this address.
|
||||||
|
; In this way, BREAK key brings up memory monitor at any time.
|
||||||
|
ds 0x38
|
||||||
|
di ; Disable maskable interrupts.
|
||||||
|
exx ; exchange registers
|
||||||
|
ex af, af'
|
||||||
|
jp Monitor_main
|
||||||
|
|
||||||
; **** SYSTEM CALLS ****
|
; **** SYSTEM CALLS ****
|
||||||
; System calls provide access to low level functions (input from keyboard, output to screen etc).
|
; System calls provide access to low level functions (input from keyboard, output to screen etc).
|
||||||
; The name starts always with Sys_
|
; The name starts always with Sys_
|
||||||
|
ds 0x40 ; Place system calls after Z80 reset/interrupt subroutines space
|
||||||
|
|
||||||
; Returns ABI version.
|
; Returns ABI version.
|
||||||
; (ABI -> https://en.wikipedia.org/wiki/Application_binary_interface)
|
; (ABI -> https://en.wikipedia.org/wiki/Application_binary_interface)
|
||||||
@ -102,12 +114,17 @@ Sysinit:
|
|||||||
call Sys_Beep
|
call Sys_Beep
|
||||||
|
|
||||||
; Run memory monitor
|
; Run memory monitor
|
||||||
call Monitor_main
|
ei ; enable maskabpe interrupts
|
||||||
|
im 1 ; set interrupt mode 1 (on interrupt jumps to 0x38)
|
||||||
|
rst 0x38 ; throw fake interrupt: jump to interrupt routine to start monitor
|
||||||
|
|
||||||
|
; User exited from memory monitor without loading a program. Do nothing.
|
||||||
|
mloop:
|
||||||
|
; Main loop: do nothing.
|
||||||
|
jp mloop
|
||||||
|
|
||||||
; DEBUG: Echo chars
|
; DEBUG: Echo chars
|
||||||
; loop:
|
; loop:
|
||||||
; call Term_readc
|
; call Term_readc
|
||||||
; call Term_printc
|
; call Term_printc
|
||||||
; jp loop
|
; jp loop
|
||||||
|
|
||||||
halt
|
|
||||||
|
@ -21,8 +21,9 @@ MON_COMMAND_ZERO: DB "ZERO",0
|
|||||||
MON_COMMAND_LOAD: DB "LOAD",0
|
MON_COMMAND_LOAD: DB "LOAD",0
|
||||||
MON_COMMAND_RUN: DB "RUN",0
|
MON_COMMAND_RUN: DB "RUN",0
|
||||||
MON_COMMAND_ADB: DB "ADB",0
|
MON_COMMAND_ADB: DB "ADB",0
|
||||||
|
MON_COMMAND_QUIT: DB "QUIT",0
|
||||||
MON_ARG_HEX: DB " 0x",0
|
MON_ARG_HEX: DB " 0x",0
|
||||||
MON_HELP: DB 10,"Available commands:\nHELP prints this message\nDUMP [ADDR] shows memory content\nSET [ADDR] sets memory content\nZERO [ADDR] [ADDR] sets all bytes to 0 in the specified range\nLOAD\nRUN [ADDR] executes code starting from ADDR\nADB starts Assembly Deploy Bridge",0
|
MON_HELP: DB 10,"Available commands:\nHELP prints this message\nDUMP [ADDR] shows memory content\nSET [ADDR] sets memory content\nZERO [ADDR] [ADDR] sets all bytes to 0 in the specified range\nLOAD\nRUN [ADDR] executes code starting from ADDR\nADB starts Assembly Deploy Bridge\nQUIT exits",0
|
||||||
MON_MSG_ADB: DB 10,"Waiting for data.",0
|
MON_MSG_ADB: DB 10,"Waiting for data.",0
|
||||||
MON_ERR_SYNTAX: DB " Syntax error",0
|
MON_ERR_SYNTAX: DB " Syntax error",0
|
||||||
;MON_ADB_TIMEOUT: EQU 0xFF // Number of cycles after an ADB binary transfer is considered completed
|
;MON_ADB_TIMEOUT: EQU 0xFF // Number of cycles after an ADB binary transfer is considered completed
|
||||||
@ -66,6 +67,9 @@ Monitor_main:
|
|||||||
ld hl, MON_COMMAND_ADB
|
ld hl, MON_COMMAND_ADB
|
||||||
cp (hl)
|
cp (hl)
|
||||||
jp z, monitor_adb
|
jp z, monitor_adb
|
||||||
|
ld hl, MON_COMMAND_QUIT
|
||||||
|
cp (hl)
|
||||||
|
jp z, monitor_quit
|
||||||
; Unrecognized command: print error and beep
|
; Unrecognized command: print error and beep
|
||||||
ld bc, MON_ERR_SYNTAX
|
ld bc, MON_ERR_SYNTAX
|
||||||
call Sys_Print
|
call Sys_Print
|
||||||
@ -80,6 +84,23 @@ monitor_help:
|
|||||||
call Sys_Print
|
call Sys_Print
|
||||||
jp monitor_main_loop
|
jp monitor_main_loop
|
||||||
|
|
||||||
|
monitor_quit:
|
||||||
|
ld bc, MON_COMMAND_QUIT + 1 ; autocomplete command
|
||||||
|
call Sys_Print
|
||||||
|
; newline
|
||||||
|
ld a, 10
|
||||||
|
call Sys_Printc
|
||||||
|
; Restores registers and re-enable interrupts: when the BREAK key is pressed,
|
||||||
|
; a maskable interrupt is generated and the CPU jumps to 0x38 reset vector,
|
||||||
|
; where if finds a call to Memory monitor (see main.asm).
|
||||||
|
exx ; exchange registers
|
||||||
|
ex af, af'
|
||||||
|
; enable interrupts
|
||||||
|
ei
|
||||||
|
im 1 ; set interrupt mode 1 (on interrupt jumps to 0x38)
|
||||||
|
reti ; return from interrupt
|
||||||
|
|
||||||
|
|
||||||
; Asks the user for a memory position and shows the following 64 bytes of memory
|
; Asks the user for a memory position and shows the following 64 bytes of memory
|
||||||
; @uses a, b, c, d, e, h, l
|
; @uses a, b, c, d, e, h, l
|
||||||
monitor_dump:
|
monitor_dump:
|
||||||
@ -257,23 +278,34 @@ monitor_zero: ; TODO: bugged, doesn't exit cycle
|
|||||||
monitor_load:
|
monitor_load:
|
||||||
ld bc, MON_COMMAND_LOAD + 1 ; autocomplete command
|
ld bc, MON_COMMAND_LOAD + 1 ; autocomplete command
|
||||||
call Sys_Print
|
call Sys_Print
|
||||||
|
; TODO: When implemented, re-enable interrupts before run application
|
||||||
jp monitor_main_loop
|
jp monitor_main_loop
|
||||||
|
|
||||||
monitor_run:
|
monitor_run:
|
||||||
ld bc, MON_COMMAND_RUN + 1 ; autocomplete command
|
ld bc, MON_COMMAND_RUN + 1 ; autocomplete command
|
||||||
call Sys_Print
|
call Sys_Print
|
||||||
; Now read the memory address to be changed from the user
|
; Now read the memory address to be executed from the user
|
||||||
call monitor_arg_2byte ; returns the read bytes in hl
|
call monitor_arg_2byte ; returns the read bytes in hl
|
||||||
ld a, 10 ; newline
|
ld a, 10 ; newline
|
||||||
call Sys_Printc
|
call Sys_Printc
|
||||||
jp (hl) ; Start executing code
|
; enable interrupts
|
||||||
|
ei
|
||||||
|
im 1 ; set interrupt mode 1 (on interrupt jumps to 0x38)
|
||||||
|
; pop the last entry on the stack: this is needed (as the monitor
|
||||||
|
; runs in an interrupt) to counter-balance the missing reti statement
|
||||||
|
pop bc
|
||||||
|
; execute code
|
||||||
|
jp (hl)
|
||||||
|
|
||||||
monitor_adb:
|
monitor_adb:
|
||||||
ld bc, MON_COMMAND_ADB + 1 ; autocomplete command
|
ld bc, MON_COMMAND_ADB + 1 ; autocomplete command
|
||||||
call Sys_Print
|
call Sys_Print
|
||||||
; start copying incoming data to application space
|
; start copying incoming data to application space
|
||||||
call monitor_copyTermToAppMem
|
call monitor_copyTermToAppMem
|
||||||
|
; call monitor_enable_int ; re-enable interrupts
|
||||||
;jp APP_SPACE ; Start executing code
|
;jp APP_SPACE ; Start executing code
|
||||||
|
|
||||||
|
|
||||||
; ld bc, APP_SPACE
|
; ld bc, APP_SPACE
|
||||||
; call Sys_Print
|
; call Sys_Print
|
||||||
jp monitor_main_loop
|
jp monitor_main_loop
|
||||||
@ -517,3 +549,5 @@ monitor_copyTermToAppMem:
|
|||||||
jp monitor_copyTermToAppMem_loop ; continue loop
|
jp monitor_copyTermToAppMem_loop ; continue loop
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user