diff --git a/FSHa.asm b/FSHa.asm index 5e23f86..1f0d98c 100644 --- a/FSHa.asm +++ b/FSHa.asm @@ -26,7 +26,7 @@ Input: LD DE, 0 LD DE, FshCmdInptSize CALL inputstr - + CALL _NewLine Decode: @@ -55,17 +55,19 @@ Exit: PS1: .DB "FSH> ",0 FshFlags: .DB %00000000 ; 0: Debug Flag -; 1: Error Flag (Unused) +; 1: Error Flag ; 2: Program Flag - -#include "includes/String.asm" -#include "includes/Byte.asm" #include "includes/Math.asm" -#include "includes/FshVar.asm" -#include "includes/FshCmd.asm" +#include "includes/Byte.asm" #include "includes/Char.asm" #include "includes/Cursor.asm" -#include "includes/Input.asm" + +#include "includes/FshCmd.asm" #include "includes/Err.asm" +#include "includes/String.asm" + +#include "includes/FshVar.asm" + +#include "includes/Input.asm" .end diff --git a/bin/FSHa.8xp b/bin/FSHa.8xp index 5f4b27c..c1b2cb5 100644 Binary files a/bin/FSHa.8xp and b/bin/FSHa.8xp differ diff --git a/includes/Err.asm b/includes/Err.asm index fa3fe2f..8d1b47c 100644 --- a/includes/Err.asm +++ b/includes/Err.asm @@ -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 ;;Routes err codes. -;;Outputs: -;; Jp to loc for err func 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 @@ -20,10 +49,18 @@ ErrCmdNotFoundf: call _PutS call _NewLine 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: ld hl, ErrDefaultt call _PutS jp Exit -ErrDefaultt: .db "ERR: Default; Exit", 0 +ErrDefaultt: .db "error: Default; Exit", 0 diff --git a/includes/FshVar.asm b/includes/FshVar.asm index 11d3c8c..c6b2941 100644 --- a/includes/FshVar.asm +++ b/includes/FshVar.asm @@ -4,12 +4,15 @@ ;; HL: 16b ;; DE: Destination Word Relitive to FshVars fshvarset: + push bc + ld bc, FshVarsSize / 2 - 1 + call cpBCDE + pop bc + jr c, fshvarsetOOBException + push bc push de push hl - ld bc, FshVarsSize / 2 - call cpBCDE - jr c, fshvarsetOOBException ld bc, FshVars ex de, hl add hl, hl @@ -17,12 +20,18 @@ fshvarset: ld (hl), e inc hl ld (hl), d -fshvarsetOOBException: pop hl pop de pop bc ret +fshvarsetOOBException: + push hl + ld hl, ErrOutOfBoundso + call ErrSet + pop hl + ret + ;;; fshvarget [Words] ;; Gets a Word in FshVars. ;; Inputs: @@ -30,12 +39,15 @@ fshvarsetOOBException: ;; Outputs: ;; HL: Word in (DE) fshvarget: + push bc + ld bc, FshVarsSize / 2 - 1 + call cpBCDE + pop bc + jr c, fshvargetOOBException + push bc push de ld hl, 0 - ld bc, FshVarsSize / 2 - call cpBCDE - jr c, fshvargetOOBException ld bc, FshVars ex de, hl add hl, hl @@ -44,17 +56,29 @@ fshvarget: inc hl ld d, (hl) ex de, hl -fshvargetOOBException: pop de pop bc ret +fshvargetOOBException: + push hl + ld hl, ErrOutOfBoundso + call ErrSet + pop hl + ret + ; fshvarcpy [Bytes] ;; Copies a word. ;; Inputs: ;; HL: Byte pointer ;; DE: Destination fshvarcpy: + push bc + ld bc, FshVarsSize / 2 - 1 + call cpBCDE + pop bc + jr c, fshvarcpyOOBException + push bc push de push hl @@ -73,12 +97,18 @@ fshvarcpy: inc hl ld a, (de) ld (hl), a -fshvarcpyOOBException: pop hl pop de pop bc ret +fshvarcpyOOBException: + push hl + ld hl, ErrOutOfBoundso + call ErrSet + pop hl + ret + ; fshvarfill ;; fills fshvars with word ;; Inputs: diff --git a/includes/commands/SET.asm b/includes/commands/SET.asm index 25b646e..159eaa8 100644 --- a/includes/commands/SET.asm +++ b/includes/commands/SET.asm @@ -57,7 +57,7 @@ fshcmdSETfExe: ld l, b call fshvarset call _NewLine - jp Fin + jp ErrCatch fshcmdSETfInputBuffer: .db $00,$00,$00,$00 fshcmdSETfDIndex: .db "Index= ", 0