Kernel 0.9.1 : Code reorganization & move to CSTR (ENV,FileSearch)

This commit is contained in:
Rémy GIBERT 2017-09-11 17:29:08 +02:00
parent 56cdcf925a
commit 8d4c55130b
13 changed files with 78 additions and 120 deletions

Binary file not shown.

Binary file not shown.

View File

@ -37,8 +37,10 @@ L.MSG.HELP .DA MSG.HELP
L.MSG.LOAD .DA MSG.LOAD L.MSG.LOAD .DA MSG.LOAD
.DA 0 .DA 0
*-------------------------------------- *--------------------------------------
CS.INIT >SYSCALL GetArgC CS.INIT >DEBUG
cmp #1 ldy #S.PS.ARGC
lda (pPs),y
bne .1 bne .1
>LDYA L.MSG.HELP >LDYA L.MSG.HELP

View File

@ -68,21 +68,15 @@ Cmd.Parse.NextC lda (ZPPtr1)
Cmd.Exec stz bStartProc Cmd.Exec stz bStartProc
>LDYA ZPCMDBuf >LDYA ZPCMDBuf
>SYSCALL PrintF.YA
jsr Cmd.Exec.ECHO.CR
>LDYA ZPCMDBuf
>SYSCALL ExpandStr.YA >SYSCALL ExpandStr.YA
>STYA ZPPtr1 Ptr to CMD >STYA ZPPtr1 Ptr to CMD
txa txa
>STA.G CMD.hCmdLine >STA.G CMD.hCmdLine
Cmd.ExecYA >LDYA ZPPtr1 Cmd.Exec.2 >LDYA ZPPtr1
>SYSCALL PrintF.YA >SYSCALL PrintF.YA
jsr Cmd.Exec.ECHO.CR jsr Cmd.Exec.ECHO.CR
>DEBUG
ldy #$ff CMD Len ldy #$ff CMD Len
@ -152,13 +146,6 @@ Cmd.ExecYA >LDYA ZPPtr1
sta ZPPtr2+1 ZPPtr2->ARGS sta ZPPtr2+1 ZPPtr2->ARGS
jsr Cmd.Exec.INT Found an internal Cmd... jsr Cmd.Exec.INT Found an internal Cmd...
bcs .9
lda #0
.9 ldy #S.PS.RC
sta (pPS),y
Cmd.Exec.Done php Cmd.Exec.Done php
pha pha
@ -171,6 +158,7 @@ Cmd.Exec.Done php
Cmd.Exec.INT jmp (J.INTCMDS,x) Cmd.Exec.INT jmp (J.INTCMDS,x)
*-------------------------------------- *--------------------------------------
Cmd.Exec.EXT pla Discard CMD len Cmd.Exec.EXT pla Discard CMD len
>DEBUG
lda (ZPPtr1) lda (ZPPtr1)
cmp #'/' Command line is already full path, no search cmp #'/' Command line is already full path, no search
@ -279,8 +267,6 @@ Cmd.Exec.CD lda (ZPPTR2)
Cmd.Exec.PWD ldy #S.PS.hPREFIX Cmd.Exec.PWD ldy #S.PS.hPREFIX
lda (pPs),y lda (pPs),y
>SYSCALL GetMemPtr.A >SYSCALL GetMemPtr.A
>PUSHYA
>LDYA L.MSG.PSTRCR
>SYSCALL PrintF.YA >SYSCALL PrintF.YA
rts rts
@ -401,7 +387,7 @@ Cmd.Exec.STARTPROC
>LDYA ZPPTR2 >LDYA ZPPTR2
>STYA ZPPTR1 >STYA ZPPTR1
jmp Cmd.ExecYA jmp Cmd.Exec.2
*-------------------------------------- *--------------------------------------
Cmd.Exec.SET lda (ZPPTR2) Cmd.Exec.SET lda (ZPPTR2)
bne Cmd.Exec.SETVAR bne Cmd.Exec.SETVAR
@ -435,7 +421,6 @@ Cmd.Exec.SET lda (ZPPTR2)
>LDYA L.MSG.PRINTENV >LDYA L.MSG.PRINTENV
>SYSCALL PrintF.YA >SYSCALL PrintF.YA
>DEBUG
bcs .9 bcs .9
ldy #$ff ldy #$ff
@ -475,6 +460,7 @@ Cmd.Exec.SETVAR ldy #0
>LDYA ZPPTR2 String is VAR=VALUE... >LDYA ZPPTR2 String is VAR=VALUE...
>SYSCALL PutEnv.YA >SYSCALL PutEnv.YA
>DEBUG
rts rts
.2 dey String is "VAR=", Remove endig '=' .2 dey String is "VAR=", Remove endig '='
@ -525,10 +511,8 @@ Cmd.Exec.TIME clc
Cmd.Exec.ECHO lda (ZPPtr2) Cmd.Exec.ECHO lda (ZPPtr2)
beq Cmd.Exec.ECHO.CR beq Cmd.Exec.ECHO.CR
>PUSHW ZPPtr2 >LDYA ZPPtr2
>LDYA L.MSG.PSTRCR
>SYSCALL PrintF.YA >SYSCALL PrintF.YA
rts
Cmd.Exec.ECHO.CR Cmd.Exec.ECHO.CR
lda #13 lda #13

View File

@ -163,7 +163,7 @@ CSH.Run jsr CSH.GetBuf
>STA.G bCmdBufexec >STA.G bCmdBufexec
>LDA.G bEcho >LDA.G bEcho
beq .80 * beq .80
>PUSHW ZPCMDBuf >PUSHW ZPCMDBuf
>LDYA L.MSG.ECHO >LDYA L.MSG.ECHO

View File

@ -5,7 +5,7 @@ INC 1
AUTO 6 AUTO 6
.LIST OFF .LIST OFF
*-------------------------------------- *--------------------------------------
IO.PrintErrMsg >PUSHA Save EC for PrintF IO.PrintErrMsg pha Save EC for PrintF
ldx L.ERR.Codes ldx L.ERR.Codes
stx ZPPTR1 stx ZPPTR1
@ -37,6 +37,8 @@ IO.PrintErrMsg >PUSHA Save EC for PrintF
bra .3 bra .3
.8 >PUSHW ZPPTR1 .8 >PUSHW ZPPTR1
pla
>PUSHA
>LDYA L.MSG.ERROR >LDYA L.MSG.ERROR
>SYSCALL PrintF.YA >SYSCALL PrintF.YA
rts rts

View File

@ -58,8 +58,6 @@ CS.START cld
L.MSG.GREETINGS .DA MSG.GREETINGS L.MSG.GREETINGS .DA MSG.GREETINGS
L.MSG.PROMPT .DA MSG.PROMPT L.MSG.PROMPT .DA MSG.PROMPT
L.MSG.ECHO .DA MSG.ECHO L.MSG.ECHO .DA MSG.ECHO
L.MSG.PSTRCR .DA MSG.PSTRCR
L.MSG.PSTR .DA MSG.PSTR
L.MSG.ERROR .DA MSG.ERROR L.MSG.ERROR .DA MSG.ERROR
L.MSG.PRINTENV .DA MSG.PRINTENV L.MSG.PRINTENV .DA MSG.PRINTENV
L.MSG.CSHERR .DA MSG.CSHERR L.MSG.CSHERR .DA MSG.CSHERR
@ -123,13 +121,13 @@ CS.INIT jsr SetPWD
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
CS.RUN >LDA.G bReadMode READ Command ? CS.RUN >DEBUG
>LDA.G bReadMode READ Command ?
bne CS.RUN.READ bne CS.RUN.READ
ldy #S.PS.RC ldy #S.PS.RC
lda (pPs),y lda (pPs),y
beq .11 beq .11
jsr IO.PrintErrMsg jsr IO.PrintErrMsg
bcs CS.RUN.EXIT.RTS bcs CS.RUN.EXIT.RTS
@ -142,7 +140,7 @@ CS.RUN >LDA.G bReadMode READ Command ?
.13 jsr CheckSleep .13 jsr CheckSleep
bne .8 bne .8
>LDA.G CSH.hBuf batch mode ? >LDA.G CSH.hBuf batch mode ?
beq .10 beq .10
jmp CS.RUN.BATCH jmp CS.RUN.BATCH
@ -510,8 +508,7 @@ CmdLine.DEL >LDA.G CmdBuflen
>SYSCALL PutChar.A >SYSCALL PutChar.A
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
CmdLine.SET >PUSHW ZPCMDBuf CmdLine.SET >LDYA ZPCMDBuf
>LDYA L.MSG.PSTR
>SYSCALL PrintF.YA >SYSCALL PrintF.YA
rts rts
*-------------------------------------- *--------------------------------------
@ -522,9 +519,10 @@ CmdLine.SET >PUSHW ZPCMDBuf
*-------------------------------------- *--------------------------------------
CS.END CS.END
*-------------------------------------- *--------------------------------------
ENV.PATH >PSTR "PATH" ENV.PATH >CSTR "PATH"
ENV.PWD >PSTR "PWD" ENV.PWD >CSTR "PWD"
ENV.PS1 >PSTR "PS1" ENV.PS1 >CSTR "PS1"
*--------------------------------------
INTCMDS >PSTR "CD" INTCMDS >PSTR "CD"
>PSTR "DATE" >PSTR "DATE"
>PSTR "ECHO" >PSTR "ECHO"
@ -548,13 +546,11 @@ CSHCMDS >PSTR "IF"
.HS 00 .HS 00
*-------------------------------------- *--------------------------------------
MSG.GREETINGS >CSTR "\r\nA2osX-Shell\r\n\r\n" MSG.GREETINGS >CSTR "\r\nA2osX-Shell\r\n\r\n"
MSG.PROMPT >CSTR "%S$ " MSG.PROMPT >CSTR "%s$ "
MSG.ECHO >CSTR ">%S\r\n" MSG.ECHO >CSTR ">%s\r\n"
MSG.PSTRCR >CSTR "%S\r\n" MSG.ERROR >CSTR "[$%h]:%S.\r\n"
MSG.PSTR >CSTR "%S"
MSG.ERROR >CSTR "Err:%S [%h]\r\n"
MSG.PRINTENV >CSTR "%s=%s\r\n" MSG.PRINTENV >CSTR "%s=%s\r\n"
MSG.CSHERR >PSTR "Pos %D:" MSG.CSHERR >CSTR "Pos %D:"
FMT.DATE >CSTR "%A, %B %d %Y" FMT.DATE >CSTR "%A, %B %d %Y"
FMT.TIME >CSTR "%H:%M:%S (%I:%M:%S%p)" FMT.TIME >CSTR "%H:%M:%S (%I:%M:%S%p)"
*-------------------------------------- *--------------------------------------

View File

@ -469,9 +469,6 @@ CORE.DispatchEvents
CORE.TskMgrQuit clc CORE.TskMgrQuit clc
rts rts
*-------------------------------------- *--------------------------------------
TskMgr.Idx .BS 1
TSKMGR.EVENTCNT .BS 1
*--------------------------------------
CORE.DestroyEvent CORE.DestroyEvent
lda (pEvent) lda (pEvent)
beq .9 beq .9
@ -497,6 +494,22 @@ CORE.DestroyEvent
dec EvtMgr.Count dec EvtMgr.Count
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
TskMgr.Idx .BS 1
TSKMGR.EVENTCNT .BS 1
*--------------------------------------
DevMgr.Stat .DA DevMgr.NUL.Code
DevMgr.Free .DA DevMgr.FreeMem
.DA DevMgr.HiMem
DevMgr.Count .DA #2 NUL,SYS
*--------------------------------------
EvtMgr.VBLState .BS 1
EvtMgr.10TH.CNT .BS 1
EvtMgr.HZ.CNT .BS 1
EvtMgr.Count .BS 1
*--------------------------------------
TskMgr.Count .DA #1 One Slot Busy (Kernel PS=0)
TskMgr.LastID .DA #0
*--------------------------------------
MAN MAN
SAVE /A2OSX.SRC/SYS/KERNEL.S.CORE SAVE /A2OSX.SRC/SYS/KERNEL.S.CORE
LOAD /A2OSX.SRC/SYS/KERNEL.S LOAD /A2OSX.SRC/SYS/KERNEL.S

View File

@ -1,25 +0,0 @@
PR#3
PREFIX /A2OSX.BUILD
LOMEM $A00
INC 1
AUTO 6
*--------------------------------------
DevMgr.Stat .DA DevMgr.NUL.Code
DevMgr.Free .DA DevMgr.FreeMem
.DA DevMgr.HiMem
DevMgr.Count .DA #2 NUL,SYS
*--------------------------------------
EvtMgr.VBLState .BS 1
EvtMgr.10TH.CNT .BS 1
EvtMgr.HZ.CNT .BS 1
EvtMgr.Count .BS 1
*--------------------------------------
TskMgr.Count .DA #1 One Slot Busy (Kernel PS=0)
TskMgr.LastID .DA #0
*--------------------------------------
EmptyPSTR .DA #0
*--------------------------------------
MAN
SAVE /A2OSX.SRC/SYS/KERNEL.S.DAT
LOAD /A2OSX.SRC/SYS/KERNEL.S
ASM

View File

@ -14,7 +14,7 @@ AUTO 6
K.ExpandStr.YA stz K.ExpandStr.hPStr Reset Intermediate string... K.ExpandStr.YA stz K.ExpandStr.hPStr Reset Intermediate string...
.1 >STYA ZPPtr2 .1 >STYA ZPPtr2
stz K.ExpandStr.Len init Expanded String len=0 stz K.ExpandStr.BufLen init Expanded String len=0
stz K.ExpandStr.bFound No var found yet stz K.ExpandStr.bFound No var found yet
stz K.ExpandStr.bNoExp Reset no expand flag stz K.ExpandStr.bNoExp Reset no expand flag
@ -40,10 +40,10 @@ K.ExpandStr.YA stz K.ExpandStr.hPStr Reset Intermediate string...
.21 bit K.ExpandStr.bNoExp .21 bit K.ExpandStr.bNoExp
bpl .23 bpl .23
.22 ldx K.ExpandStr.Len .22 ldx K.ExpandStr.BufLen
sta K.Buf256,x sta K.Buf256,x
inx inx
stx K.ExpandStr.Len stx K.ExpandStr.BufLen
bra .11 bra .11
.23 ldx K.ExpandStr.bInVar already in a var? .23 ldx K.ExpandStr.bInVar already in a var?
@ -108,7 +108,7 @@ K.ExpandStr.YA stz K.ExpandStr.hPStr Reset Intermediate string...
jsr K.FreeMem.A yes, discard.... jsr K.FreeMem.A yes, discard....
.81 ldx K.ExpandStr.Len .81 ldx K.ExpandStr.BufLen
stz K.Buf256,x stz K.Buf256,x
>LDYAI K.Buf256 >LDYAI K.Buf256
@ -146,7 +146,7 @@ K.ExpandStrValidChar
K.ExpandStrGetValue K.ExpandStrGetValue
jsr ENV.ExpandSysVar jsr ENV.ExpandSysVar
bcc .9 bcc .9
>LDYAI K.ExpandStr.VarName >LDYAI K.ExpandStr.VarName
jsr K.GetEnv.YA jsr K.GetEnv.YA
bcs .9 bcs .9
@ -157,7 +157,7 @@ K.ExpandStrGetValue
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
K.ExpandStr.Len .BS 1 K.ExpandStr.BufLen .BS 1
K.ExpandStr.bNoExp .BS 1 K.ExpandStr.bNoExp .BS 1
K.ExpandStr.bInVar .BS 1 K.ExpandStr.bInVar .BS 1
K.ExpandStr.bFound .BS 1 K.ExpandStr.bFound .BS 1
@ -296,7 +296,7 @@ K.SetEnvPtr1Ptr2
bne .24 bne .24
iny iny
.25 lda #0
sta (ZPPtr3),y don't forget array ending 0 sta (ZPPtr3),y don't forget array ending 0
clc clc
rts rts
@ -317,11 +317,9 @@ K.GetEnv.YA >STYA ZPPtr1
bcs .9 bcs .9
jsr ENV.NextEnvPtr3 Skip NAME jsr ENV.NextEnvPtr3 Skip NAME
>LDYA ZPPtr3
clc just in case ADC in NextEnvPtr1 disturb CC clc just in case ADC in NextEnvPtr1 disturb CC
.8 rts
.9 >LDYAI EmptyPSTR .9 >LDYA ZPPtr3
rts rts
*/-------------------------------------- */--------------------------------------
* # UnsetEnv.YA * # UnsetEnv.YA
@ -405,16 +403,29 @@ ENV.SysVarsArgs lda #1
lda (ZPPtr3) lda (ZPPtr3)
beq ENV.SysVarsExit2 beq ENV.SysVarsExit2
ldx K.Buf256
inx inx
beq ENV.SysVarsExit2 make sure not overlapping buf 256 beq ENV.SysVarsExit2 make sure not overlapping buf 256
stx K.Buf256
lda #' ' lda #' '
sta K.Buf256,x sta K.Buf256,x
stx K.ExpandStr.BufLen
jsr ENV.AppendPtr3ToBuf jsr ENV.AppendPtr3ToBuf
bra .2 bra .2
*-------------------------------------- *--------------------------------------
ENV.AppendPtr3ToBuf
ldx K.ExpandStr.BufLen
ldy #$ff
dex
.1 iny
inx
lda (ZPPtr3),y
sta K.Buf256,x
bne .1
stx K.ExpandStr.BufLen
rts
*--------------------------------------
ENV.SysVarsArgC jsr K.GetArgC Trash Ptr1 ENV.SysVarsArgC jsr K.GetArgC Trash Ptr1
bra ENV.SysVarsA bra ENV.SysVarsA
@ -555,24 +566,6 @@ ENV.NextEnvPtr3 ldy #0
inc ZPPtr3+1 inc ZPPtr3+1
.8 rts .8 rts
*-------------------------------------- *--------------------------------------
ENV.AppendPtr3ToBuf
ldx #$ff
.1 inx
lda K.Buf256,x
bne .1
ldy #$ff
dex
.2 iny
inx
lda (ZPPtr3),y
sta K.Buf256,x
bne .2
rts
*--------------------------------------
MAN MAN
SAVE /A2OSX.SRC/SYS/KERNEL.S.ENV SAVE /A2OSX.SRC/SYS/KERNEL.S.ENV
LOAD /A2OSX.SRC/SYS/KERNEL.S LOAD /A2OSX.SRC/SYS/KERNEL.S

View File

@ -19,17 +19,15 @@ AUTO 6
* CS : not found * CS : not found
*\-------------------------------------- *\--------------------------------------
K.FileSearch >PULLW ZPPtr2 DstBuf K.FileSearch >PULLW ZPPtr2 DstBuf
>DEBUG
jsr K.FileSearch.I jsr K.FileSearch.I
bcs .9 bcs .9
lda K.Buf256 ldy #$ff
sta (ZPPtr2)
tay .1 iny
lda K.Buf256,y
.1 lda K.Buf256,y
sta (ZPPtr2),y sta (ZPPtr2),y
dey
bne .1 bne .1
.9 rts .9 rts
@ -44,16 +42,13 @@ K.FileSearch.I >PULLW ZPPtr4 ZPPtr1 trashed by ExpandStr.YA
stz .11+1 stz .11+1
.1 stz K.Buf256 reset String .1 ldx #$ff
ldx #0
.11 ldy #$ff Self Modified .11 ldy #$ff Self Modified
.2 tya .2 lda (ZPPtr3),y end of src string ?
cmp (ZPPtr3) end of src string ?
beq .3 end of string, try it.... beq .3 end of string, try it....
iny iny
lda (ZPPtr3),y
cmp #';' cmp #';'
beq .3 beq .3
inx inx
@ -65,17 +60,15 @@ K.FileSearch.I >PULLW ZPPtr4 ZPPtr1 trashed by ExpandStr.YA
sty .11+1 save current index sty .11+1 save current index
ldy #0 ldy #$ff
.4 iny .4 iny
lda (ZPPtr4),y Append Fiename... lda (ZPPtr4),y Append Fiename...
inx inx
sta K.Buf256,x sta K.Buf256,x
tya
cmp (ZPPtr4)
bne .4 bne .4
stx K.Buf256 set string length stz K.Buf256+1,x set string ending 0
>PUSHWI K.S.STAT >PUSHWI K.S.STAT
>PUSHWI K.Buf256 >PUSHWI K.Buf256
@ -150,7 +143,8 @@ K.GetFullPath.YA
* Y,A = File Length * Y,A = File Length
* X = hMem of Loaded File * X = hMem of Loaded File
*\-------------------------------------- *\--------------------------------------
K.LoadFile lda (pStack) read PTR.LO on top of stack K.LoadFile >DEBUG
lda (pStack) read PTR.LO on top of stack
pha pha
ldy #1 ldy #1
lda (pStack),y read PTR.HI on top of stack lda (pStack),y read PTR.HI on top of stack

View File

@ -300,7 +300,7 @@ PS.Init jsr BIN.Load.YA Y,A=filename full path
.2 ldy #H.BIN.EXE.SS.SIZE .2 ldy #H.BIN.EXE.SS.SIZE
lda (ZPPtr4),y Load SS.SIZE.LO lda (ZPPtr4),y Load SS.SIZE.LO
pha Save it.... pha Save it....
>DEBUG
dec set SP to top dec set SP to top
ldy #S.PS.SP ldy #S.PS.SP
@ -312,12 +312,12 @@ PS.Init jsr BIN.Load.YA Y,A=filename full path
bne .3 SS.SIZE=0, set as default $100 bne .3 SS.SIZE=0, set as default $100
inc SS.SIZE.HI inc SS.SIZE.HI
.3 jsr K.GetMem0.YA .3 jsr K.GetMem.YA
bcs .9 bcs .9
txa txa
ldy #S.PS.hSS ldy #S.PS.hSS
sta (ZPPtr3),y save DS hMem in TSKSLOT sta (ZPPtr3),y save SS hMem in TSKSLOT
clc clc

View File

@ -47,7 +47,6 @@ A2osX.D2 .PH $D000
A2osX.E0 .PH $E000 A2osX.E0 .PH $E000
.INB /A2OSX.SRC/SYS/KERNEL.S.JMP .INB /A2OSX.SRC/SYS/KERNEL.S.JMP
.INB /A2OSX.SRC/SYS/KERNEL.S.CORE .INB /A2OSX.SRC/SYS/KERNEL.S.CORE
.INB /A2OSX.SRC/SYS/KERNEL.S.DAT
.INB /A2OSX.SRC/SYS/KERNEL.S.IRQ .INB /A2OSX.SRC/SYS/KERNEL.S.IRQ
.INB /A2OSX.SRC/SYS/KERNEL.S.MEM .INB /A2OSX.SRC/SYS/KERNEL.S.MEM
.INB /A2OSX.SRC/SYS/KERNEL.S.D01 .INB /A2OSX.SRC/SYS/KERNEL.S.D01