fsh-shell/includes/Err.asm

67 lines
969 B
NASM

;;ErrCatch
;;Checks err bit and jp to err route
ErrCatch:
ld hl, FshFlags
bit 1, (hl)
jp nz, ErrRoute
jp Fin
;;ErrRoute
;;Routes err codes.
ErrRoute:
ld hl, FshFlags
res 1, (hl)
ld hl, FshCmdErrCode
ld de, ErrCmdNotFoundo
call bytecmp
jp z, ErrCmdNotFoundf
ld de, ErrOutOfBoundso
call bytecmp
jp z, ErrOutOfBoundsf
jp ErrDefault
;;ErrSet
;;Sets all things relating to Err codes
;; Inputs:
;; HL: Err____o
ErrSet:
push hl
ld a, (hl)
ld hl, FshCmdErrCode
ld (hl), a
ld hl, FshFlags
set 1, (hl)
pop hl
ret
;;ERR FUNCS
ErrCmdNotFoundo: .db $01
ErrCmdNotFoundf:
ld hl, ErrCmdNotFoundt
call _PutS
ld hl, FshCmd
call _PutS
call _NewLine
jp Fin
ErrCmdNotFoundt: .db "error:No Command:", 0
ErrOutOfBoundso: .db $02
ErrOutOfBoundsf:
ld hl, ErrOutOfBoundst
call _PutS
call _NewLine
jp Fin
ErrOutOfBoundst: .db "error: Out Of Bounds", 0
ErrDefault:
ld hl, ErrDefaultt
call _PutS
jp Exit
ErrDefaultt: .db "error: Default; Exit", 0