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.Buf256 .EQ $0E00 Main
*-------------------------------------- *--------------------------------------
K.STACK .EQ $0F00 from up to $0fff K.STACK .EQ $0F20 down to $0f00
*-------------------------------------- *--------------------------------------
*** Z80 Reserved $0F00-10FF*** *** 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 Z80JMP .EQ $1000 (00000h) Up To $10FF
*-------------------------------------- *--------------------------------------
FltMgr.Table .EQ $1100 K.FLT.MAX*S.FLT.SIZE=8*32=128b FltMgr.Table .EQ $1100 K.FLT.MAX*S.FLT.SIZE=8*32=128b

View File

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

View File

@ -69,16 +69,12 @@ Cmd.Exec stz bStartProc
>LDYA ZPCMDBuf >LDYA ZPCMDBuf
>SYSCALL ExpandStr.YA >SYSCALL ExpandStr.YA
>STYA ZPPtr1 Ptr to CMD >STYA ZPPtr1 Ptr to CMD ARGS
txa txa
>STA.G CMD.hCmdLine >STA.G CMD.hCmdLine
Cmd.Exec.2 >LDYA ZPPtr1 Cmd.Exec.2 ldy #$ff CMD Len
>SYSCALL PrintF.YA
jsr Cmd.Exec.ECHO.CR
ldy #$ff CMD Len
.1 iny .1 iny
lda (ZPPtr1),y Get CMD char... lda (ZPPtr1),y Get CMD char...
@ -87,6 +83,9 @@ Cmd.Exec.2 >LDYA ZPPtr1
cmp #' ' we reached blank between CMD ARGS cmp #' ' we reached blank between CMD ARGS
bne .1 bne .1
lda #0
sta (ZPPtr1),y Cut CMD with the ending 0
.2 phy Y=CMD len .2 phy Y=CMD len
>LDYA L.INTCMDS >LDYA L.INTCMDS
@ -135,8 +134,9 @@ Cmd.Exec.2 >LDYA ZPPtr1
lda (ZPPtr1),y lda (ZPPtr1),y
beq .7 ARGS = "" beq .7 ARGS = ""
iny skip " "
iny skip " "
.7 tya .7 tya
clc clc
adc ZPPtr1 adc ZPPtr1
@ -158,51 +158,35 @@ 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
bne .10 bne .1
jmp .3
.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 >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 >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 >SYSCALL STAT
bcs .99 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 ? cmp #$04 TXT File ?
beq Cmd.Exec.EXT.TXT beq Cmd.Exec.EXT.TXT
cmp #$06 BIN File ? cmp #$06 BIN File ?
@ -216,6 +200,13 @@ Cmd.Exec.EXT pla Discard CMD len
sec sec
.99 jmp Cmd.Exec.Done .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" * TXT : Launch "/PATH/SHELL /PATH/CMD ARGS"
*-------------------------------------- *--------------------------------------
Cmd.Exec.EXT.TXT Cmd.Exec.EXT.TXT
@ -460,7 +451,6 @@ 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 '='

View File

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

View File

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

View File

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

@ -270,8 +270,6 @@ GO.A2osX php
.1 stx GO.EXIT.JMP+1 .1 stx GO.EXIT.JMP+1
sty GO.EXIT.JMP+2 sty GO.EXIT.JMP+2
ldy pStack
bcs GO.A2osX.BNK if CS, go AUXLC bcs GO.A2osX.BNK if CS, go AUXLC
bit RRAMWRAMBNK1 Go MAINLC (ProDOS), always BNK1 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 ldx A2osX.SaveSX
txs txs
*-------------------------------------- *--------------------------------------
GO.EXIT sty pStack GO.EXIT pha push P on stack
pha push P on stack
GO.EXIT.SaveY ldy #$ff GO.EXIT.SaveY ldy #$ff
GO.EXIT.SaveX ldx #$ff GO.EXIT.SaveX ldx #$ff
GO.EXIT.SaveA lda #$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 ldy #S.PS.hDS
sta (ZPPtr3),y save DS hMem in TSKSLOT sta (ZPPtr3),y save DS hMem in TSKSLOT
.2 ldy #H.BIN.EXE.SS.SIZE+1 .2 ldy #H.BIN.EXE.SS.SIZE
lda (ZPPtr4),y Load SS.SIZE.HI lda (ZPPtr4),y Load SS.SIZE.LO
tax
dey ldy #S.PS.SP
ora (ZPPtr4),y sta (ZPPtr3),y Init SP to top of hSS
bne .3 SS.SIZE=0, set as default $100 lda #0
inx SS.SIZE.HI
.3 lda (ZPPtr4),y
tay tay
txa bne .3 SS.SIZE.LO=0, set as default $100
>PUSHYA inc SS.SIZE.HI
.3 >PUSHYA
>PUSHBI S.MEM.F.ALIGN >PUSHBI S.MEM.F.ALIGN
jsr K.GetMem jsr K.GetMem
bcs .9 bcs .9