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, 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

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
;;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

View File

@ -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:

View File

@ -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