Added Err Handler similar to cmd routing

FshCmd is now 24 bytes
err flag is unused
cleaned up code a bit
This commit is contained in:
Stephen Toth 2018-06-24 22:19:08 -04:00
parent 2546f299d3
commit 15452c4fce
5 changed files with 54 additions and 39 deletions

View File

@ -6,15 +6,15 @@
.DB tExtTok,tAsm84CeCmp .DB tExtTok,tAsm84CeCmp
Setup: Setup:
CALL _homeup ;Put up home CALL _homeup
CALL _ClrLCDFull ;Clear screen CALL _ClrLCDFull
LD HL, $00 LD HL, $00
CALL fshvarfill CALL fshvarfill
Input: Input:
LD HL, $00 ; fill fshcmd with $00 LD C, $00
CALL fshcmdfill CALL fshcmdfill
XOR A XOR A
@ -30,10 +30,6 @@ Input:
CALL _NewLine CALL _NewLine
Decode: Decode:
LD HL, FshCmdOP ; resets op to 0, TEMP
LD A, $00
LD (HL), A
LD HL, FshCmd LD HL, FshCmd
LD DE, FshCmdOP LD DE, FshCmdOP
CALL fshcmddecode CALL fshcmddecode
@ -46,8 +42,7 @@ Fin:
JP Input JP Input
Err: Err:
;TODO: Err Handler JP ErrRoute
JP ErrDefault
Cleanup: Cleanup:
SET graphdraw,(IY+graphflags) SET graphdraw,(IY+graphflags)
@ -60,7 +55,7 @@ Exit:
PS1: .DB "FSH> ",0 PS1: .DB "FSH> ",0
FshFlags: .DB %00000000 FshFlags: .DB %00000000
; 0: Debug Flag ; 0: Debug Flag
; 1: Error Flag ; 1: Error Flag (Unused)
; 2: Program Flag ; 2: Program Flag

Binary file not shown.

View File

@ -1,6 +1,29 @@
;;ErrRoute
;;Routes err codes.
;;Outputs:
;; Jp to loc for err func
ErrRoute:
ld hl, FshCmdErrCode
ld de, ErrCmdNotFoundo
call bytecmp
jp z, ErrCmdNotFoundf
jp ErrDefault
ErrCmdNotFoundo: .db $01
ErrCmdNotFoundf:
ld hl, ErrCmdNotFoundt
call _PutS
ld hl, FshCmd
call _PutS
call _NewLine
jp Fin
ErrCmdNotFoundt: .db "ERR: No Command: ", 0
ErrDefault: ErrDefault:
ld hl, ErrDefaultT ld hl, ErrDefaultt
call _PutS call _PutS
jp Exit jp Exit
ErrDefaultT: ErrDefaultt: .db "ERR: Default; Exit", 0
.db "ERR: Default; Exit",0

View File

@ -68,36 +68,32 @@ fshcmdroute:
call bytecmp call bytecmp
jp z, fshcmdCLSf jp z, fshcmdCLSf
jp Fin ld hl, FshCmdErrCode
ld (hl), $01
jp Err
; fshcmdfill ; fshvarfill
;; fills fshvars with word ;; fills fshcmd with byte
;; Inputs: ;; Inputs:
;; HL: 16b ;; C: byte
fshcmdfill: fshcmdfill:
push hl push hl
push de push bc
ld d, h push de
ld e, l ld b, 0
ld hl, FshCmdArg0 ld de, 0
ld (hl), e ld hl, FshCmd
inc hl fshcmdfillLoop:
ld (hl), d ld (hl), c
inc hl inc hl
ld (hl), e inc b
inc hl inc de
ld (hl), d ld a, b
inc hl cp FshCmdSize / 2
ld (hl), e jr c, fshcmdfillLoop
inc hl pop de
ld (hl), d pop bc
inc hl
ld (hl), e
inc hl
ld (hl), d
pop de
pop hl pop hl
ret ret
#include "includes/commands.inc" #include "includes/commands.inc"

View File

@ -8,7 +8,7 @@
#define END .end #define END .end
#define FshVarsSize 128 ;256 bytes | 64 words #define FshVarsSize 128 ;256 bytes | 64 words
#define FshCmdSize 17 ;17 bytes | 8 chars | 1 null, 4 words #define FshCmdSize 24 ;17 bytes | 8 chars | 1 null, 4 words (args) | 1 byte (err code) | 6 unused
#define FshCmdInptSize 8 ;8 bytes | 8 chars #define FshCmdInptSize 8 ;8 bytes | 8 chars
#define FshPrgmSize 1024 ;1024 bytes | max size #define FshPrgmSize 1024 ;1024 bytes | max size
@ -23,3 +23,4 @@ FshCmdArg0 equ FshCmdOP + 1
FshCmdArg1 equ FshCmdOP + 3 FshCmdArg1 equ FshCmdOP + 3
FshCmdArg2 equ FshCmdOP + 5 FshCmdArg2 equ FshCmdOP + 5
FshCmdArg3 equ FshCmdOP + 7 FshCmdArg3 equ FshCmdOP + 7
FshCmdErrCode equ FshCmdArg3 + 1