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

This commit is contained in:
Rémy GIBERT 2017-09-12 17:24:36 +02:00
parent 75c95bd1eb
commit 46918f88f0
10 changed files with 101 additions and 106 deletions

Binary file not shown.

Binary file not shown.

View File

@ -60,11 +60,11 @@ K.MLI.PATH .EQ $03B0 64+1 -> $03D0
*--------------------------------------
K.Buf256 .EQ $0E00 Main
*--------------------------------------
K.STACK .EQ $0F00 from up to $0fff
K.STACK .EQ $0F20 down to $0f00
*--------------------------------------
*** Z80 Reserved $0F00-10FF***
*--------------------------------------
Z80STACK .EQ $0FFF (0FFFFh) Down to $0F00
Z80STACK .EQ $0FFF (0FFFFh) Down to $0F20
Z80JMP .EQ $1000 (00000h) Up To $10FF
*--------------------------------------
FltMgr.Table .EQ $1100 K.FLT.MAX*S.FLT.SIZE=8*32=128b

View File

@ -166,92 +166,92 @@ AUTO 6
* STACK PUSH/PULL
*--------------------------------------
.MA PUSHA
dec pStack
sta (pStack)
inc pStack
.EM
*--------------------------------------
.MA PULLA
dec pStack
lda (pStack)
inc pStack
.EM
*--------------------------------------
.MA PUSHYA
dec pStack
sta (pStack)
inc pStack
tya
dec pStack
sta (pStack)
inc pStack
.EM
*--------------------------------------
.MA PULLYA
dec pStack
lda (pStack)
inc pStack
tay
dec pStack
lda (pStack)
inc pStack
.EM
*--------------------------------------
.MA PUSHBI
dec pStack
lda #]1
sta (pStack)
inc pStack
.EM
*--------------------------------------
.MA PUSHB
.DO ]#=2
dec pStack
lda ]1,]2
sta (pStack)
inc pStack
.ELSE
dec pStack
lda ]1
sta (pStack)
inc pStack
.FIN
.EM
*--------------------------------------
.MA PULLB
.DO ]#=2
dec pStack
lda (pStack)
sta ]1,]2
inc pStack
.ELSE
dec pStack
lda (pStack)
sta ]1
inc pStack
.FIN
.EM
*--------------------------------------
.MA PUSHWI
dec pStack
lda /]1
sta (pStack)
inc pStack
dec pStack
lda #]1
sta (pStack)
inc pStack
.EM
*--------------------------------------
.MA PUSHW
dec pStack
lda ]1+1
sta (pStack)
inc pStack
dec pStack
lda ]1
sta (pStack)
inc pStack
.EM
*--------------------------------------
.MA PULLW
dec pStack
lda (pStack)
sta ]1
dec pStack
inc pStack
lda (pStack)
sta ]1+1
inc pStack
.EM
*--------------------------------------
.MA POP
lda pStack
sec
sbc ]1
clc
adc ]1
sta pStack
.EM
*--------------------------------------

View File

@ -69,16 +69,12 @@ Cmd.Exec stz bStartProc
>LDYA ZPCMDBuf
>SYSCALL ExpandStr.YA
>STYA ZPPtr1 Ptr to CMD
>STYA ZPPtr1 Ptr to CMD ARGS
txa
>STA.G CMD.hCmdLine
Cmd.Exec.2 >LDYA ZPPtr1
>SYSCALL PrintF.YA
jsr Cmd.Exec.ECHO.CR
ldy #$ff CMD Len
Cmd.Exec.2 ldy #$ff CMD Len
.1 iny
lda (ZPPtr1),y Get CMD char...
@ -87,6 +83,9 @@ Cmd.Exec.2 >LDYA ZPPtr1
cmp #' ' we reached blank between CMD ARGS
bne .1
lda #0
sta (ZPPtr1),y Cut CMD with the ending 0
.2 phy Y=CMD len
>LDYA L.INTCMDS
@ -135,8 +134,9 @@ Cmd.Exec.2 >LDYA ZPPtr1
lda (ZPPtr1),y
beq .7 ARGS = ""
iny skip " "
iny skip " "
.7 tya
clc
adc ZPPtr1
@ -158,51 +158,35 @@ Cmd.Exec.Done php
Cmd.Exec.INT jmp (J.INTCMDS,x)
*--------------------------------------
Cmd.Exec.EXT pla Discard CMD len
>DEBUG
lda (ZPPtr1)
cmp #'/' Command line is already full path, no search
bne .10
jmp .3
bne .1
.10 >LDYA L.ENV.PATH push ENVNAME=PATH for search
>SYSCALL GetEnv.YA get value for ENV=PATH
bcs .1 No PATH, try in CD
>PUSHYA push search list
>PUSHW ZPPtr1 push filename
>PUSHWI UsrBuf256
>PUSHW L.STAT
>SYSCALL FileSearch
bcc .2
.1 ldy #S.PS.hPREFIX not found, try in CD
lda (pPs),y
>SYSCALL GetMemPtr.A
>PUSHYA push search list
>PUSHW ZPPtr1
>PUSHWI UsrBuf256
>PUSHW L.STAT
>SYSCALL FileSearch
bcs .99
.2 phx save X=hMem, Y,A = Filename
>PUSHYA
>PUSHW L.CMD replace CMD in TmpBuffer with full path
>SYSCALL StrCpy
pla
>SYSCALL FreeMem.A Discard this string...
.3 stz UsrBuf256 reset UsrBuf256 for final CMDLINE
>PUSHW L.STAT
>PUSHW L.CMD
>SYSCALL STAT
bcs .99
lda STAT+S.STAT.P.TYPE
>LDYAI UsrBuf256
>STYA ZPPtr1
bra .3
.1 >LDYA L.ENV.PATH push ENVNAME=PATH for search
>SYSCALL GetEnv.YA get value for ENV=PATH
bcs .2 No PATH, try in CD
jsr Cmd.Exec.Search
bcc .3
.2 ldy #S.PS.hPREFIX not found, try in CD
lda (pPs),y
>SYSCALL GetMemPtr.A
jsr Cmd.Exec.Search
bcs .99
.3 lda STAT+S.STAT.P.TYPE
cmp #$04 TXT File ?
beq Cmd.Exec.EXT.TXT
cmp #$06 BIN File ?
@ -216,6 +200,13 @@ Cmd.Exec.EXT pla Discard CMD len
sec
.99 jmp Cmd.Exec.Done
*--------------------------------------
Cmd.Exec.Search >PUSHYA push search list
>PUSHW ZPPtr1
>PUSHWI UsrBuf256
>PUSHW L.STAT
>SYSCALL FileSearch
rts
*--------------------------------------
* TXT : Launch "/PATH/SHELL /PATH/CMD ARGS"
*--------------------------------------
Cmd.Exec.EXT.TXT
@ -460,7 +451,6 @@ Cmd.Exec.SETVAR ldy #0
>LDYA ZPPTR2 String is VAR=VALUE...
>SYSCALL PutEnv.YA
>DEBUG
rts
.2 dey String is "VAR=", Remove endig '='

View File

@ -121,8 +121,7 @@ CS.INIT jsr SetPWD
.9 rts
*--------------------------------------
CS.RUN >DEBUG
>LDA.G bReadMode READ Command ?
CS.RUN >LDA.G bReadMode READ Command ?
bne CS.RUN.READ
ldy #S.PS.RC

View File

@ -254,8 +254,12 @@ CORE.PSSelect ldy #S.PS.hCS
.1 ldy #S.PS.hSS
lda (pPs),y
jsr K.GetMemPtr.A
>STYA pStack
sta pStack+1
ldy #S.PS.SP
lda (pPs),y
sta pStack
clc
rts
*--------------------------------------

View File

@ -18,57 +18,64 @@ AUTO 6
* DstStat = S.STAT
* CS : not found
*\--------------------------------------
K.FileSearch >PULLW ZPPtr2 DstBuf
>DEBUG
K.FileSearch >PULLW .4+1 DstStat
>PULLW .2+1 DstBuf
jsr K.FileSearch.I
bcs .9
ldy #$ff
ldx #$ff
.1 iny
lda K.Buf256,y
sta (ZPPtr2),y
.1 inx
lda K.Buf256,x
.2 sta $ffff,x Self Modified
bne .1
ldx #S.STAT-1
.3 lda K.S.STAT,x
.4 sta $ffff,x Self Modified
dex
bpl .3
.9 rts
K.FileSearch.I >PULLW ZPPtr4 ZPPtr1 trashed by ExpandStr.YA
K.FileSearch.I >PULLW .4+1
>PULLYA Get Search list
>SYSCALL ExpandStr.YA Expand it (SYSCALL to BNK1)
>SYSCALL ExpandStr.YA Expand it (SYSCALL to BNK2)
bcs .99
stx .98+1
>STYA ZPPtr3 expanded search list ;
>STYA .2+1 expanded search list ;
stz .11+1
stz .1+1
.1 ldx #$ff
.1 ldy #$ff Self Modified Index in Search list string
.11 ldy #$ff Self Modified
ldx #$0
.2 lda (ZPPtr3),y end of src string ?
.2 lda $ffff,y Self Modified, Search list string
beq .3 end of string, try it....
iny
cmp #';'
beq .3
inx
sta K.Buf256,x
inx
bra .2
.3 txa
beq .98 String is empty....nothing to try
sty .11+1 save current index
sty .1+1 save current index
ldy #$ff
ldy #$0
.4 iny
lda (ZPPtr4),y Append Fiename...
inx
.4 lda $ffff,y Self Modified, Append Fiename...
sta K.Buf256,x
bne .4
beq .5
iny
inx
bra .4
stz K.Buf256+1,x set string ending 0
.5 stz K.Buf256+1,x set string ending 0
>PUSHWI K.S.STAT
>PUSHWI K.Buf256
@ -143,8 +150,7 @@ K.GetFullPath.YA
* Y,A = File Length
* X = hMem of Loaded File
*\--------------------------------------
K.LoadFile >DEBUG
lda (pStack) read PTR.LO on top of stack
K.LoadFile lda (pStack) read PTR.LO on top of stack
pha
ldy #1
lda (pStack),y read PTR.HI on top of stack

View File

@ -270,8 +270,6 @@ GO.A2osX php
.1 stx GO.EXIT.JMP+1
sty GO.EXIT.JMP+2
ldy pStack
bcs GO.A2osX.BNK if CS, go AUXLC
bit RRAMWRAMBNK1 Go MAINLC (ProDOS), always BNK1
@ -295,8 +293,7 @@ GO.A2osX.BNK ldx #RRAMWRAMBNK1 Self Modified, initialized to BNK1 for INIT3
ldx A2osX.SaveSX
txs
*--------------------------------------
GO.EXIT sty pStack
pha push P on stack
GO.EXIT pha push P on stack
GO.EXIT.SaveY ldy #$ff
GO.EXIT.SaveX ldx #$ff
GO.EXIT.SaveA lda #$ff

View File

@ -297,19 +297,18 @@ PS.Init jsr BIN.Load.YA Y,A=filename full path
ldy #S.PS.hDS
sta (ZPPtr3),y save DS hMem in TSKSLOT
.2 ldy #H.BIN.EXE.SS.SIZE+1
lda (ZPPtr4),y Load SS.SIZE.HI
tax
dey
ora (ZPPtr4),y
.2 ldy #H.BIN.EXE.SS.SIZE
lda (ZPPtr4),y Load SS.SIZE.LO
ldy #S.PS.SP
sta (ZPPtr3),y Init SP to top of hSS
bne .3 SS.SIZE=0, set as default $100
inx SS.SIZE.HI
.3 lda (ZPPtr4),y
lda #0
tay
txa
>PUSHYA
bne .3 SS.SIZE.LO=0, set as default $100
inc SS.SIZE.HI
.3 >PUSHYA
>PUSHBI S.MEM.F.ALIGN
jsr K.GetMem
bcs .9