1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-27 09:48:05 +11:00

shell: cleanup

This commit is contained in:
Virgil Dupras 2019-04-14 11:22:45 -04:00
parent 21168f6c4e
commit e4e7db8e23

View File

@ -11,6 +11,9 @@
; Commands, for now, are dummy. ; Commands, for now, are dummy.
; ;
; See constants below for error codes. ; See constants below for error codes.
;
; All numerical values in the Collapse OS shell are represented and parsed in
; hexadecimal form, without prefix or suffix.
; *** CONSTS *** ; *** CONSTS ***
@ -46,23 +49,11 @@ shellInit:
.db "Collapse OS", 0 .db "Collapse OS", 0
shellLoop: shellLoop:
call chkbuf ; check if the input buffer is full or ends in CR or LF. If it does,
jr shellLoop ; prints it back and empty it.
printcrlf:
ld a, ASCII_CR
call aciaPutC
ld a, ASCII_LF
call aciaPutC
ret
; check if the input buffer is full or ends in CR or LF. If it does, prints it
; back and empty it.
chkbuf:
call aciaBufPtr call aciaBufPtr
cp 0 cp 0
ret z ; BUFIDX is zero? nothing to check. jr z, shellLoop ; BUFIDX is zero? nothing to check.
cp ACIA_BUFSIZE cp ACIA_BUFSIZE
jr z, .do ; if BUFIDX == BUFSIZE? do! jr z, .do ; if BUFIDX == BUFSIZE? do!
@ -78,8 +69,7 @@ chkbuf:
jr z, .do ; char is LF? do! jr z, .do ; char is LF? do!
; nothing matched? don't do anything ; nothing matched? don't do anything
ret jr shellLoop
.do: .do:
; terminate our string with 0 ; terminate our string with 0
xor a xor a
@ -90,6 +80,13 @@ chkbuf:
; alright, let's go! ; alright, let's go!
ld hl, ACIA_BUF ld hl, ACIA_BUF
call shellParse call shellParse
jr shellLoop
printcrlf:
ld a, ASCII_CR
call aciaPutC
ld a, ASCII_LF
call aciaPutC
ret ret
; Parse command (null terminated) at HL and calls it ; Parse command (null terminated) at HL and calls it