|
|
@ -25,7 +25,6 @@
|
|
|
|
; S (SET) $pos $val Replaces byte at $pos with $val
|
|
|
|
; S (SET) $pos $val Replaces byte at $pos with $val
|
|
|
|
; L (LOAD) $pos $val
|
|
|
|
; L (LOAD) $pos $val
|
|
|
|
; R (RUN) $pos Starts executing code from $pos
|
|
|
|
; R (RUN) $pos Starts executing code from $pos
|
|
|
|
; A (ADB) Enters in Assembly Depoy Bridge mode: loads all the incoming bytes in application memory and starts executing.
|
|
|
|
|
|
|
|
; The commands are entered with a single letter and the program completes the command
|
|
|
|
; The commands are entered with a single letter and the program completes the command
|
|
|
|
|
|
|
|
|
|
|
|
include 'libs/strings.asm'
|
|
|
|
include 'libs/strings.asm'
|
|
|
@ -38,13 +37,13 @@ MON_COMMAND_SET: DB "SET",0
|
|
|
|
MON_COMMAND_ZERO: DB "ZERO",0
|
|
|
|
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_MEMTEST: DB "MEMTEST",0
|
|
|
|
MON_COMMAND_MEMTEST: DB "MEMTEST",0
|
|
|
|
MON_COMMAND_QUIT: DB "QUIT",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\nMEMTEST checks ram boundaries\nQUIT exits",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 [ADDR] loads a program or data from tape at ADDR\nRUN [ADDR] executes code starting from ADDR\nADB starts Assembly Deploy Bridge\nMEMTEST checks ram boundaries\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_COMMAND_LOAD_PRESSPLAY: DB "Press play on tape",0
|
|
|
|
; MON_RAMTEST_INTRO: DB " Checking memory... ",0
|
|
|
|
; MON_RAMTEST_INTRO: DB " Checking memory... ",0
|
|
|
|
; MON_RAMTEST_RAMSTART: DB " Ram starts at 0x",0
|
|
|
|
; MON_RAMTEST_RAMSTART: DB " Ram starts at 0x",0
|
|
|
|
MON_DUMP_BYTES_LINES: EQU 8
|
|
|
|
MON_DUMP_BYTES_LINES: EQU 8
|
|
|
@ -84,9 +83,6 @@ Monitor_main:
|
|
|
|
ld hl, MON_COMMAND_RUN
|
|
|
|
ld hl, MON_COMMAND_RUN
|
|
|
|
cp (hl)
|
|
|
|
cp (hl)
|
|
|
|
jp z, monitor_run
|
|
|
|
jp z, monitor_run
|
|
|
|
ld hl, MON_COMMAND_ADB
|
|
|
|
|
|
|
|
cp (hl)
|
|
|
|
|
|
|
|
jp z, monitor_adb
|
|
|
|
|
|
|
|
; ld hl, MON_COMMAND_MEMTEST
|
|
|
|
; ld hl, MON_COMMAND_MEMTEST
|
|
|
|
; cp (hl)
|
|
|
|
; cp (hl)
|
|
|
|
; jp z, monitor_memtest
|
|
|
|
; jp z, monitor_memtest
|
|
|
@ -298,10 +294,18 @@ monitor_zero: ; TODO: bugged, doesn't exit cycle
|
|
|
|
ld (hl), 0 ; set byte to 0 in memory
|
|
|
|
ld (hl), 0 ; set byte to 0 in memory
|
|
|
|
ret
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; Asks user for a memory position, then wait for data from tape and place it
|
|
|
|
|
|
|
|
; from the specified position on until it receives 4 consecutive 0x00 (EOF)
|
|
|
|
|
|
|
|
; @uses b, c, h, l
|
|
|
|
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
|
|
|
|
; Now read the memory address from the user
|
|
|
|
|
|
|
|
call monitor_arg_2byte ; returns the read bytes in hl
|
|
|
|
|
|
|
|
; Ask user to press play
|
|
|
|
|
|
|
|
ld bc, MON_COMMAND_LOAD_PRESSPLAY
|
|
|
|
|
|
|
|
; TODO: wait for data
|
|
|
|
jp monitor_main_loop
|
|
|
|
jp monitor_main_loop
|
|
|
|
|
|
|
|
|
|
|
|
monitor_run:
|
|
|
|
monitor_run:
|
|
|
@ -320,19 +324,6 @@ monitor_run:
|
|
|
|
; execute code
|
|
|
|
; execute code
|
|
|
|
jp (hl)
|
|
|
|
jp (hl)
|
|
|
|
|
|
|
|
|
|
|
|
monitor_adb:
|
|
|
|
|
|
|
|
ld bc, MON_COMMAND_ADB + 1 ; autocomplete command
|
|
|
|
|
|
|
|
call Sys_Print
|
|
|
|
|
|
|
|
; start copying incoming data to application space
|
|
|
|
|
|
|
|
call monitor_copyTermToAppMem
|
|
|
|
|
|
|
|
; call monitor_enable_int ; re-enable interrupts
|
|
|
|
|
|
|
|
;jp APP_SPACE ; Start executing code
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; ld bc, APP_SPACE
|
|
|
|
|
|
|
|
; call Sys_Print
|
|
|
|
|
|
|
|
jp monitor_main_loop
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; Prints "0x" and read 1 hex byte (2 hex digits, e.g. 0x8C)
|
|
|
|
; Prints "0x" and read 1 hex byte (2 hex digits, e.g. 0x8C)
|
|
|
|
; Can be cancelled with Q/ENTER
|
|
|
|
; Can be cancelled with Q/ENTER
|
|
|
|
; @return a the read byte, b the exit code (0=valid byte in a, 1=Q, 2=ENTER)
|
|
|
|
; @return a the read byte, b the exit code (0=valid byte in a, 1=Q, 2=ENTER)
|
|
|
@ -524,53 +515,6 @@ monitor_printAsciiByte:
|
|
|
|
call Sys_Printc
|
|
|
|
call Sys_Printc
|
|
|
|
ret
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
; Copy data from parallel terminal to application memory. This is tought to be used with the ADB function of the Pat80 Python Terminal.
|
|
|
|
|
|
|
|
; Uses TERM_DATA_AVAIL_REG to check if a byte is available before reading it.
|
|
|
|
|
|
|
|
; The first two received bytes (heading bytes) defines the stream length (MSB first), the rest of the bytes are copied to memory.
|
|
|
|
|
|
|
|
; The copy is completed when the number of bytes defined in the heading bytes are received.
|
|
|
|
|
|
|
|
; @uses a, b, c, d, h, l
|
|
|
|
|
|
|
|
monitor_copyTermToAppMem:
|
|
|
|
|
|
|
|
; d contains the current status.
|
|
|
|
|
|
|
|
; 2 = waiting for first heading byte
|
|
|
|
|
|
|
|
; 1 = waiting for second heading byte
|
|
|
|
|
|
|
|
; 0 = heading bytes received, now receiving binary stream
|
|
|
|
|
|
|
|
ld d, 2
|
|
|
|
|
|
|
|
ld hl, APP_SPACE ; we will write in APP_SPACE
|
|
|
|
|
|
|
|
monitor_copyTermToAppMem_loop:
|
|
|
|
|
|
|
|
ld a, d
|
|
|
|
|
|
|
|
cp 2 ; check if we are receiving first header byte
|
|
|
|
|
|
|
|
jp z, monitor_copyTermToAppMem_loop_rec_head_byte_1
|
|
|
|
|
|
|
|
ld a, d
|
|
|
|
|
|
|
|
cp 1 ; check if we are receiving second header byte
|
|
|
|
|
|
|
|
jp z, monitor_copyTermToAppMem_loop_rec_head_byte_2
|
|
|
|
|
|
|
|
; we are receiving binary stream: read byte and save to memory
|
|
|
|
|
|
|
|
call Term_readb ; reads a byte from terminal
|
|
|
|
|
|
|
|
ld (hl), a ; copy byte to memory
|
|
|
|
|
|
|
|
inc hl ; move to next memory position
|
|
|
|
|
|
|
|
dec bc ; decrement remaining bytes counter
|
|
|
|
|
|
|
|
; check if we reached the number of bytes to be transferred
|
|
|
|
|
|
|
|
ld a, b
|
|
|
|
|
|
|
|
cp 0
|
|
|
|
|
|
|
|
jp nz, monitor_copyTermToAppMem_loop ; continue loop
|
|
|
|
|
|
|
|
ld a, c
|
|
|
|
|
|
|
|
cp 0
|
|
|
|
|
|
|
|
jp nz, monitor_copyTermToAppMem_loop ; continue loop
|
|
|
|
|
|
|
|
; all bytes received, return
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
monitor_copyTermToAppMem_loop_rec_head_byte_1:
|
|
|
|
|
|
|
|
; we are receiving first header byte: read byte and save to b
|
|
|
|
|
|
|
|
call Term_readb ; reads a byte from terminal
|
|
|
|
|
|
|
|
ld b, a
|
|
|
|
|
|
|
|
dec d
|
|
|
|
|
|
|
|
jp monitor_copyTermToAppMem_loop ; continue loop
|
|
|
|
|
|
|
|
monitor_copyTermToAppMem_loop_rec_head_byte_2:
|
|
|
|
|
|
|
|
; we are receiving second header byte: read byte and save to c
|
|
|
|
|
|
|
|
call Term_readb ; reads a byte from terminal
|
|
|
|
|
|
|
|
ld c, a
|
|
|
|
|
|
|
|
dec d
|
|
|
|
|
|
|
|
jp monitor_copyTermToAppMem_loop ; continue loop
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; Runs a memory test to identify ram memory boundaries and check the ram is working.
|
|
|
|
; Runs a memory test to identify ram memory boundaries and check the ram is working.
|
|
|
|
; Starting from last memory position, writes 0xFF, reads it back, writes 0x00, reads it back.
|
|
|
|
; Starting from last memory position, writes 0xFF, reads it back, writes 0x00, reads it back.
|
|
|
|
; Exits when the first value differs from the written value (this may be caused by a bad ram
|
|
|
|
; Exits when the first value differs from the written value (this may be caused by a bad ram
|
|
|
|