FshVar functions now set Err

SET calls ErrCatch
Out Of Bounds Err added
This commit is contained in:
Stephen Toth 2018-06-25 13:45:10 -04:00
parent f8d9b65977
commit cf9a22fb88
5 changed files with 91 additions and 22 deletions

View File

@ -26,7 +26,7 @@ Input:
LD DE, 0 LD DE, 0
LD DE, FshCmdInptSize LD DE, FshCmdInptSize
CALL inputstr CALL inputstr
CALL _NewLine CALL _NewLine
Decode: Decode:
@ -55,17 +55,19 @@ Exit:
PS1: .DB "FSH> ",0 PS1: .DB "FSH> ",0
FshFlags: .DB %00000000 FshFlags: .DB %00000000
; 0: Debug Flag ; 0: Debug Flag
; 1: Error Flag (Unused) ; 1: Error Flag
; 2: Program Flag ; 2: Program Flag
#include "includes/String.asm"
#include "includes/Byte.asm"
#include "includes/Math.asm" #include "includes/Math.asm"
#include "includes/FshVar.asm" #include "includes/Byte.asm"
#include "includes/FshCmd.asm"
#include "includes/Char.asm" #include "includes/Char.asm"
#include "includes/Cursor.asm" #include "includes/Cursor.asm"
#include "includes/Input.asm"
#include "includes/FshCmd.asm"
#include "includes/Err.asm" #include "includes/Err.asm"
#include "includes/String.asm"
#include "includes/FshVar.asm"
#include "includes/Input.asm"
.end .end

Binary file not shown.

View File

@ -1,17 +1,46 @@
;;ErrCatch
;;Checks err bit and jp to err route
ErrCatch:
ld hl, FshFlags
bit 1, (hl)
jp nz, ErrRoute
jp Fin
;;ErrRoute ;;ErrRoute
;;Routes err codes. ;;Routes err codes.
;;Outputs:
;; Jp to loc for err func
ErrRoute: ErrRoute:
ld hl, FshFlags
res 1, (hl)
ld hl, FshCmdErrCode ld hl, FshCmdErrCode
ld de, ErrCmdNotFoundo ld de, ErrCmdNotFoundo
call bytecmp call bytecmp
jp z, ErrCmdNotFoundf jp z, ErrCmdNotFoundf
ld de, ErrOutOfBoundso
call bytecmp
jp z, ErrOutOfBoundsf
jp ErrDefault 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 ErrCmdNotFoundo: .db $01
ErrCmdNotFoundf: ErrCmdNotFoundf:
ld hl, ErrCmdNotFoundt ld hl, ErrCmdNotFoundt
@ -20,10 +49,18 @@ ErrCmdNotFoundf:
call _PutS call _PutS
call _NewLine call _NewLine
jp Fin jp Fin
ErrCmdNotFoundt: .db "ERR: No Command: ", 0 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: ErrDefault:
ld hl, ErrDefaultt ld hl, ErrDefaultt
call _PutS call _PutS
jp Exit jp Exit
ErrDefaultt: .db "ERR: Default; Exit", 0 ErrDefaultt: .db "error: Default; Exit", 0

View File

@ -4,12 +4,15 @@
;; HL: 16b ;; HL: 16b
;; DE: Destination Word Relitive to FshVars ;; DE: Destination Word Relitive to FshVars
fshvarset: fshvarset:
push bc
ld bc, FshVarsSize / 2 - 1
call cpBCDE
pop bc
jr c, fshvarsetOOBException
push bc push bc
push de push de
push hl push hl
ld bc, FshVarsSize / 2
call cpBCDE
jr c, fshvarsetOOBException
ld bc, FshVars ld bc, FshVars
ex de, hl ex de, hl
add hl, hl add hl, hl
@ -17,12 +20,18 @@ fshvarset:
ld (hl), e ld (hl), e
inc hl inc hl
ld (hl), d ld (hl), d
fshvarsetOOBException:
pop hl pop hl
pop de pop de
pop bc pop bc
ret ret
fshvarsetOOBException:
push hl
ld hl, ErrOutOfBoundso
call ErrSet
pop hl
ret
;;; fshvarget [Words] ;;; fshvarget [Words]
;; Gets a Word in FshVars. ;; Gets a Word in FshVars.
;; Inputs: ;; Inputs:
@ -30,12 +39,15 @@ fshvarsetOOBException:
;; Outputs: ;; Outputs:
;; HL: Word in (DE) ;; HL: Word in (DE)
fshvarget: fshvarget:
push bc
ld bc, FshVarsSize / 2 - 1
call cpBCDE
pop bc
jr c, fshvargetOOBException
push bc push bc
push de push de
ld hl, 0 ld hl, 0
ld bc, FshVarsSize / 2
call cpBCDE
jr c, fshvargetOOBException
ld bc, FshVars ld bc, FshVars
ex de, hl ex de, hl
add hl, hl add hl, hl
@ -44,17 +56,29 @@ fshvarget:
inc hl inc hl
ld d, (hl) ld d, (hl)
ex de, hl ex de, hl
fshvargetOOBException:
pop de pop de
pop bc pop bc
ret ret
fshvargetOOBException:
push hl
ld hl, ErrOutOfBoundso
call ErrSet
pop hl
ret
; fshvarcpy [Bytes] ; fshvarcpy [Bytes]
;; Copies a word. ;; Copies a word.
;; Inputs: ;; Inputs:
;; HL: Byte pointer ;; HL: Byte pointer
;; DE: Destination ;; DE: Destination
fshvarcpy: fshvarcpy:
push bc
ld bc, FshVarsSize / 2 - 1
call cpBCDE
pop bc
jr c, fshvarcpyOOBException
push bc push bc
push de push de
push hl push hl
@ -73,12 +97,18 @@ fshvarcpy:
inc hl inc hl
ld a, (de) ld a, (de)
ld (hl), a ld (hl), a
fshvarcpyOOBException:
pop hl pop hl
pop de pop de
pop bc pop bc
ret ret
fshvarcpyOOBException:
push hl
ld hl, ErrOutOfBoundso
call ErrSet
pop hl
ret
; fshvarfill ; fshvarfill
;; fills fshvars with word ;; fills fshvars with word
;; Inputs: ;; Inputs:

View File

@ -57,7 +57,7 @@ fshcmdSETfExe:
ld l, b ld l, b
call fshvarset call fshvarset
call _NewLine call _NewLine
jp Fin jp ErrCatch
fshcmdSETfInputBuffer: .db $00,$00,$00,$00 fshcmdSETfInputBuffer: .db $00,$00,$00,$00
fshcmdSETfDIndex: .db "Index= ", 0 fshcmdSETfDIndex: .db "Index= ", 0