mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-25 04:38:05 +11:00
shell: add error codes to cmds
This commit is contained in:
parent
12c23f52e0
commit
c996da8ac8
@ -31,6 +31,7 @@ table describes those codes:
|
||||
|------|---------------------------|
|
||||
| `01` | Unknown command |
|
||||
| `02` | Badly formatted arguments |
|
||||
| `03` | Out of bounds |
|
||||
|
||||
## seek
|
||||
|
||||
|
@ -13,6 +13,8 @@
|
||||
; BLOCKDEV_COUNT: The number of devices we manage.
|
||||
|
||||
; *** CONSTS ***
|
||||
BLOCKDEV_ERR_OUT_OF_BOUNDS .equ 0x03
|
||||
|
||||
; *** VARIABLES ***
|
||||
; A memory pointer to a device table. A device table is a list of addresses
|
||||
; pointing to GetC and PutC routines.
|
||||
@ -73,14 +75,14 @@ blkSel:
|
||||
blkBselCmd:
|
||||
.db "bsel", 0b001, 0, 0
|
||||
blkBsel:
|
||||
ret
|
||||
push af
|
||||
ld a, (hl) ; argument supplied
|
||||
cp BLOCKDEV_COUNT
|
||||
ret nz ; if selection >= device count, don't do anything
|
||||
; (will devise a unified cmd error system later)
|
||||
jr nc, .error ; if selection >= device count, error
|
||||
call blkSel
|
||||
pop af
|
||||
xor a
|
||||
ret
|
||||
.error:
|
||||
ld a, BLOCKDEV_ERR_OUT_OF_BOUNDS
|
||||
ret
|
||||
|
||||
; Reads one character from blockdev ID specified at A and returns its value
|
||||
|
@ -152,8 +152,7 @@ shellParse:
|
||||
|
||||
; exhausted loop? not found
|
||||
ld a, SHELL_ERR_UNKNOWN_CMD
|
||||
call shellPrintErr
|
||||
jr .end
|
||||
jr .error
|
||||
|
||||
.found:
|
||||
; we found our command. DE points to its table entry. Now, let's parse
|
||||
@ -182,10 +181,13 @@ shellParse:
|
||||
ld ixl, e
|
||||
; Ready to roll!
|
||||
call callIX
|
||||
cp 0
|
||||
jr nz, .error ; if A is non-zero, we have an error
|
||||
jr .end
|
||||
|
||||
.parseerror:
|
||||
ld a, SHELL_ERR_BAD_ARGS
|
||||
.error:
|
||||
call shellPrintErr
|
||||
.end:
|
||||
pop ix
|
||||
@ -318,6 +320,9 @@ shellParseArgs:
|
||||
; When these commands are called, HL points to the first byte of the
|
||||
; parsed command args.
|
||||
;
|
||||
; If the command is a success, it should set A to zero. If the command results
|
||||
; in an error, it should set an error code in A.
|
||||
;
|
||||
; Extra commands: Other parts might define new commands. You can add these
|
||||
; commands to your shell. First, set SHELL_EXTRA_CMD_COUNT to
|
||||
; the number of extra commands to add, then add a ".dw"
|
||||
@ -329,7 +334,6 @@ shellParseArgs:
|
||||
shellSeekCmd:
|
||||
.db "seek", 0b011, 0b001, 0
|
||||
shellSeek:
|
||||
push af
|
||||
push de
|
||||
push hl
|
||||
|
||||
@ -355,7 +359,7 @@ shellSeek:
|
||||
|
||||
pop hl
|
||||
pop de
|
||||
pop af
|
||||
xor a
|
||||
ret
|
||||
|
||||
|
||||
@ -366,7 +370,6 @@ shellSeek:
|
||||
shellPeekCmd:
|
||||
.db "peek", 0b101, 0, 0
|
||||
shellPeek:
|
||||
push af
|
||||
push bc
|
||||
push de
|
||||
push hl
|
||||
@ -393,7 +396,7 @@ shellPeek:
|
||||
pop hl
|
||||
pop de
|
||||
pop bc
|
||||
pop af
|
||||
xor a
|
||||
ret
|
||||
|
||||
; Load the specified number of bytes (max 0xff) from IO and write them in the
|
||||
@ -406,7 +409,6 @@ shellPeek:
|
||||
shellLoadCmd:
|
||||
.db "load", 0b001, 0, 0
|
||||
shellLoad:
|
||||
push af
|
||||
push bc
|
||||
push hl
|
||||
|
||||
@ -421,7 +423,7 @@ shellLoad:
|
||||
.end:
|
||||
pop hl
|
||||
pop bc
|
||||
pop af
|
||||
xor a
|
||||
ret
|
||||
|
||||
; Calls the routine where the memory pointer currently points. This can take two
|
||||
@ -431,7 +433,6 @@ shellLoad:
|
||||
shellCallCmd:
|
||||
.db "call", 0b101, 0b111, 0b001
|
||||
shellCall:
|
||||
push af
|
||||
push hl
|
||||
push ix
|
||||
|
||||
@ -461,7 +462,7 @@ shellCall:
|
||||
.end:
|
||||
pop ix
|
||||
pop hl
|
||||
pop af
|
||||
xor a
|
||||
ret
|
||||
|
||||
; This table is at the very end of the file on purpose. The idea is to be able
|
||||
|
Loading…
Reference in New Issue
Block a user