Seemingly working immediate load in monitor
This commit is contained in:
parent
72e4bee080
commit
76f8910773
@ -26,7 +26,7 @@ Term_printc:
|
|||||||
out (TERM_DATA_REG),a
|
out (TERM_DATA_REG),a
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; Reads a single character
|
; Reads a single character. 0s are ignored (can be used with keyboard)
|
||||||
; @return A The read character
|
; @return A The read character
|
||||||
Term_readc:
|
Term_readc:
|
||||||
in a, (TERM_DATA_REG) ; reads a character
|
in a, (TERM_DATA_REG) ; reads a character
|
||||||
@ -34,7 +34,7 @@ Term_readc:
|
|||||||
jp z, Term_readc ; if char is 0 (NULL), ignores it and waits for another character
|
jp z, Term_readc ; if char is 0 (NULL), ignores it and waits for another character
|
||||||
ret ; if not NULL, returns it in the a register
|
ret ; if not NULL, returns it in the a register
|
||||||
|
|
||||||
; Reads a line
|
; Reads a line. 0s are ignored (can be used with keyboard)
|
||||||
; @return BC The pointer to a null-terminated read string
|
; @return BC The pointer to a null-terminated read string
|
||||||
Term_readline:
|
Term_readline:
|
||||||
ld bc, incoming_string ; this array will contain read string
|
ld bc, incoming_string ; this array will contain read string
|
||||||
@ -55,3 +55,10 @@ Term_readline:
|
|||||||
;ld (bc), 0 ; Null-terminate string
|
;ld (bc), 0 ; Null-terminate string
|
||||||
ld bc, incoming_string ; Returns read string pointer
|
ld bc, incoming_string ; Returns read string pointer
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
; Reads the byte currently on the I/O bus at the provided address.
|
||||||
|
; 0s are not ignored (cannot be used with keyboard)
|
||||||
|
; Affects NO condition bits!
|
||||||
|
Term_readb:
|
||||||
|
in a, (TERM_DATA_REG) ; reads a byte
|
||||||
|
ret
|
@ -100,16 +100,11 @@ monitor_immediate:
|
|||||||
ld bc, MON_COMMAND_IMMEDIATE + 1 ; autocomplete command
|
ld bc, MON_COMMAND_IMMEDIATE + 1 ; autocomplete command
|
||||||
call Print
|
call Print
|
||||||
; start copying incoming data to application space
|
; start copying incoming data to application space
|
||||||
monitor_immediate_copyToAppSpace:
|
call monitor_copyTermToAppMem
|
||||||
ld bc, APP_SPACE
|
|
||||||
call Readc
|
|
||||||
ld (bc), a
|
|
||||||
cp a, 0
|
|
||||||
;jmp z monitor_immediate_copyToAppSpace ; così esce al primo 0 che trova, ovviamente invece vogliamo aspettare 8 zeri
|
|
||||||
|
|
||||||
jp APP_SPACE ; Start executing code
|
jp APP_SPACE ; Start executing code
|
||||||
jp monitor_main_loop
|
;jp monitor_main_loop
|
||||||
|
|
||||||
|
; Read 1 hex byte (e.g. 0x8C)
|
||||||
monitor_arg_byte:
|
monitor_arg_byte:
|
||||||
; Print 0x... prompt
|
; Print 0x... prompt
|
||||||
ld bc, MON_ARG_HEX
|
ld bc, MON_ARG_HEX
|
||||||
@ -119,6 +114,7 @@ monitor_arg_byte:
|
|||||||
call monitor_readHexDigit
|
call monitor_readHexDigit
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
; Reads 2 hex bytes (e.g. 0x3F09)
|
||||||
monitor_arg_2byte:
|
monitor_arg_2byte:
|
||||||
; Print 0x... prompt
|
; Print 0x... prompt
|
||||||
ld bc, MON_ARG_HEX
|
ld bc, MON_ARG_HEX
|
||||||
@ -130,6 +126,7 @@ monitor_arg_2byte:
|
|||||||
call monitor_readHexDigit
|
call monitor_readHexDigit
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
; Reads an hex digit (0 to 9, A to F)
|
||||||
monitor_readHexDigit:
|
monitor_readHexDigit:
|
||||||
call Readc
|
call Readc
|
||||||
; check if is a valid hex digit (0-9 -> ascii codes 48 to 57; A-F -> ascii codes 65 to 70)
|
; check if is a valid hex digit (0-9 -> ascii codes 48 to 57; A-F -> ascii codes 65 to 70)
|
||||||
@ -162,4 +159,23 @@ monitor_readHexDigit:
|
|||||||
sub a, 55
|
sub a, 55
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
; Copy data from STDIN to application memory. This is tought to be used with parallel terminal, not keyboard:
|
||||||
|
; 0s are not ignored and the sequence is complete when found 8 zeros.
|
||||||
|
monitor_copyTermToAppMem:
|
||||||
|
call Term_readb
|
||||||
|
cp 0
|
||||||
|
jp z, monitor_copyTermToAppMem ; wait for data stream to begin: ignore leading zeros
|
||||||
|
ld hl, APP_SPACE ; we will write in APP_SPACE
|
||||||
|
ld b, 8 ; the number of zeros that represent the end of stream
|
||||||
|
monitor_copyTermToAppMem_loop:
|
||||||
|
ld (hl), a ; copy byte to memory
|
||||||
|
inc hl ; move to next memory position
|
||||||
|
cp 0 ; compare A to 0
|
||||||
|
; load next byte to A (this doesn't affect condition bits, so flag Z from previous cp is still valid)
|
||||||
|
call Term_readb
|
||||||
|
jp nz, monitor_copyTermToAppMem_loop ; if during previous cp A was not 0, execute next cycle
|
||||||
|
dec b ; if A is 0, decrement "end of stream" counter
|
||||||
|
ret z ; if B is 0, we found 8 zeros, so the stream is finished: return.
|
||||||
|
jp monitor_copyTermToAppMem_loop ; otherwise, continue loop
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user