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
Setup:
CALL _homeup ;Put up home
CALL _ClrLCDFull ;Clear screen
CALL _homeup
CALL _ClrLCDFull
LD HL, $00
CALL fshvarfill
Input:
LD HL, $00 ; fill fshcmd with $00
LD C, $00
CALL fshcmdfill
XOR A
@ -30,10 +30,6 @@ Input:
CALL _NewLine
Decode:
LD HL, FshCmdOP ; resets op to 0, TEMP
LD A, $00
LD (HL), A
LD HL, FshCmd
LD DE, FshCmdOP
CALL fshcmddecode
@ -46,8 +42,7 @@ Fin:
JP Input
Err:
;TODO: Err Handler
JP ErrDefault
JP ErrRoute
Cleanup:
SET graphdraw,(IY+graphflags)
@ -60,7 +55,7 @@ Exit:
PS1: .DB "FSH> ",0
FshFlags: .DB %00000000
; 0: Debug Flag
; 1: Error Flag
; 1: Error Flag (Unused)
; 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:
ld hl, ErrDefaultT
ld hl, ErrDefaultt
call _PutS
jp Exit
ErrDefaultT:
.db "ERR: Default; Exit",0
ErrDefaultt: .db "ERR: Default; Exit", 0

View File

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

View File

@ -8,7 +8,7 @@
#define END .end
#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 FshPrgmSize 1024 ;1024 bytes | max size
@ -23,3 +23,4 @@ FshCmdArg0 equ FshCmdOP + 1
FshCmdArg1 equ FshCmdOP + 3
FshCmdArg2 equ FshCmdOP + 5
FshCmdArg3 equ FshCmdOP + 7
FshCmdErrCode equ FshCmdArg3 + 1