Kernel 0.92 : SHELL, fixed the instability problem

This commit is contained in:
Rémy GIBERT 2018-11-14 15:34:13 +01:00
parent be851c6636
commit 996a7b3a9e
7 changed files with 115 additions and 113 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -71,7 +71,7 @@ CL.CHARIN.CTRL cpx #C.CR
>LDA.G CL.Ptr
tay
lda #0
sta (ZPCMDBuf),y
sta (ZPCLBuf),y
tya
>STA.G CL.Len
@ -102,7 +102,7 @@ CL.CHARIN.CTRL cpx #C.CR
rts
*--------------------------------------
CL.Insert >LDA.G CL.Len
cmp #CmdLine.MAX
cmp #CL.MAX
beq .9 Buffer full, discard...
inc
@ -112,9 +112,9 @@ CL.Insert >LDA.G CL.Len
.1 ply
dey
lda (ZPCMDBuf),y Move from Ptr To end of buffer forward...
lda (ZPCLBuf),y Move from Ptr To end of buffer forward...
iny
sta (ZPCMDBuf),y
sta (ZPCLBuf),y
dey
phy
tya
@ -126,7 +126,7 @@ CL.Insert >LDA.G CL.Len
* >LDA.G CL.Ptr
txa
sta (ZPCMDBuf),y
sta (ZPCLBuf),y
>LDA.G bREAD.S
bpl .2
@ -142,23 +142,23 @@ CL.Insert >LDA.G CL.Len
.9 clc
rts
*--------------------------------------
CL.CLR ldy #0
CL.CLR lda (ZPCLBuf)
beq CL.RESET.1
.1 lda (ZPCMDBuf),y
beq CL.RESET
ldy #0
.2 lda #$7F
.1 lda #$7F
sta (ZPCLBuf),y
sta (ZPCMDBuf),y
iny
lda (ZPCMDBuf),y
bne .2
lda (ZPCLBuf),y
bne .1
jsr CL.PrintCmdBuf
*--------------------------------------
CL.RESET lda #0
sta (ZPCMDBuf)
>STA.G CL.bExec
sta (ZPCLBuf)
CL.RESET.1 >STA.G CL.bExec
>STA.G CL.Ptr
>STA.G CL.Len
rts
@ -209,9 +209,9 @@ CL.DEL.1 pha
.1 ply
iny
lda (ZPCMDBuf),y
lda (ZPCLBuf),y
dey
sta (ZPCMDBuf),y
sta (ZPCLBuf),y
iny
phy
tya
@ -230,7 +230,7 @@ CL.PrintEOL >LDA.G CL.Ptr
pha
tay
lda (ZPCMDBuf),y
lda (ZPCLBuf),y
>SYSCALL PutChar
pla
inc
@ -258,7 +258,7 @@ CL.PrintEOL >LDA.G CL.Ptr
CL.PrintEOL.8 clc
rts
*--------------------------------------
CL.PrintCmdBuf >LDYA ZPCMDBuf
CL.PrintCmdBuf >LDYA ZPCLBuf
>PUSHYA
ldy #S.PS.hStdOut
lda (pPs),y
@ -279,9 +279,9 @@ CL.GetLine lda (ZPFileBufPtr)
* cmp #';'
* beq .6
sta (ZPCMDBuf),y
sta (ZPCLBuf),y
iny
cpy #CmdLine.MAX
cpy #CL.MAX
bne .1
lda #E.SYN Line Too long !!!
@ -300,7 +300,7 @@ CL.GetLine lda (ZPFileBufPtr)
inc ZPFileBufPtr+1
.8 lda #0
sta (ZPCMDBuf),y
sta (ZPCLBuf),y
tya
>STA.G CL.Len
@ -314,18 +314,8 @@ CL.GetLine lda (ZPFileBufPtr)
sec
rts
*--------------------------------------
CL.Trace >LDA.G bSET.X
beq .8
>PUSHW ZPCMDBuf
>PUSHBI 2
>LDYA L.MSG.TRACE
>SYSCALL printf
.8 clc
rts
*--------------------------------------
* in:
* ZPCMDBuf : CString command line
* ZPCLBuf : CString command line
* out:
* ZPArgVBuf :
* /path/excmd\0 arg1\0 arg2\0 ... \0
@ -337,15 +327,16 @@ CL.Parse >STZ.G CMD.IntCmd
lda #S.PS.F.HOLD+S.PS.F.DUPENV
>STA.G CMD.PSFlags
>PUSHW ZPCMDBuf
>LDYA ZPCMDBuf
>PUSHW ZPCLBuf
>LDYA ZPCLBuf
>STYA ZPCLBufPtr
>SYSCALL Args2ArgV
lda #0
sta (ZPArgVBuf)
lda (ZPCMDBuf)
lda (ZPCLBufPtr)
beq .8
.1 cmp #'#' comment ?
@ -355,10 +346,10 @@ CL.Parse >STZ.G CMD.IntCmd
bne .3 we already have Cmd, go check args
ldy #1
lda (ZPCMDBuf),y only one char ?
lda (ZPCLBufPtr),y only one char ?
bne .2
lda (ZPCMDBuf)
lda (ZPCLBufPtr)
cmp #'.' leading dot ?
bne .2
@ -377,28 +368,28 @@ CL.Parse >STZ.G CMD.IntCmd
tay an error ?
bne .9 yes...I/O error...
jsr CL.AddCmdBufTokenToArgV no...add as an arg
jsr CL.AddCLBufPtrToArgV no...add as an arg
bcs .9
.6 jsr CL.NextCmdBufToken
.7 lda (ZPCMDBuf)
.6 jsr CL.NextCLToken
.7 lda (ZPCLBufPtr)
bne .1
.8 clc
.9 rts
*--------------------------------------
* ZPCMDBuf-> argv[] (formatted & not empty)
* ZPCLBuf-> argv[] (formatted & not empty)
*--------------------------------------
CL.CheckCmd ldy #$ff
.1 iny
lda (ZPCMDBuf),y
lda (ZPCLBufPtr),y
beq .2
cmp #'/'
bne .1
>LDYA ZPCMDBuf found /, some path specified, External, no search
>LDYA ZPCLBufPtr found /, some path specified, External, no search
>SYSCALL realpath
bcs .9
@ -406,7 +397,7 @@ CL.CheckCmd ldy #$ff
>STA.G CMD.hCmdLine
bra .6 go check type...
.2 >PUSHW ZPCMDBuf
.2 >PUSHW ZPCLBufPtr
>LDYA L.CMD.INT
jsr Lookup no / found, search internal...
bcs .4 not internal, search PATH
@ -508,17 +499,17 @@ CL.SearchExt pha
ply
pla
>PUSHYA push search list
>LDYA ZPCMDBuf push CMD
>LDYA ZPCLBufPtr push CMD
>SYSCALL FileSearch
rts
*--------------------------------------
CL.CheckIO >PUSHW ZPCMDBuf
CL.CheckIO >PUSHW ZPCLBufPtr
>LDYA L.CL.IO
jsr Lookup
bcs .9 not a IO token...should be an arg....
phx
jsr CL.NextCmdBufToken skip this IO token
jsr CL.NextCLToken skip this IO token
plx
jmp (J.CL.IO,x)
@ -541,7 +532,7 @@ CL.IO.IN lda #O.RDONLY+O.TEXT
bcs .9
jsr IO.Set.In
jsr CL.NextCmdBufToken skip arg
jsr CL.NextCLToken skip arg
clc
.9 rts
@ -555,7 +546,7 @@ CL.IO.OUT.1 jsr CL.IO.Open
bcs .9
jsr IO.Set.Out
jsr CL.NextCmdBufToken skip arg
jsr CL.NextCLToken skip arg
clc
.9 rts
@ -567,19 +558,19 @@ CL.IO.2OUT.1 jsr CL.IO.Open
bcs .9
jsr IO.Set.Err
jsr CL.NextCmdBufToken skip arg
jsr CL.NextCLToken skip arg
clc
.9 rts
*--------------------------------------
CL.IO.Open pha
lda (ZPCMDBuf)
lda (ZPCLBufPtr)
beq .9 no arg left....
>PUSHWI 0 Aux type
>PUSHBI S.FI.T.TXT ftype
pla
>PUSHA flags
>LDYA ZPCMDBuf
>LDYA ZPCLBufPtr
>SYSCALL fopen
rts
@ -588,17 +579,17 @@ CL.IO.Open pha
sec
rts
*--------------------------------------
CL.NextCmdBufToken
lda (ZPCMDBuf)
inc ZPCMDBuf
CL.NextCLToken
lda (ZPCLBufPtr)
inc ZPCLBufPtr
bne .1
inc ZPCMDBuf+1
inc ZPCLBufPtr+1
.1 tax
bne CL.NextCmdBufToken
bne CL.NextCLToken
rts
*--------------------------------------
CL.AddCmdBufTokenToArgV
>LDYA ZPCmdBuf
CL.AddCLBufPtrToArgV
>LDYA ZPCLBufPtr
CL.AddYAToArgV >STYA ZPPtr1
>LDYA ZPArgVBuf

View File

@ -6,9 +6,10 @@ AUTO 4,1
CMD.Init >LDYAI 256
>SYSCALL GetMem
bcs .9
>STYA ZPCMDBuf
>STYA ZPCLBuf
txa
>STA.G CMD.hCmdBuf
>STA.G CMD.hCLBuf
>LDYAI 256
>SYSCALL GetMem
@ -17,7 +18,7 @@ CMD.Init >LDYAI 256
txa
>STA.G CMD.hArgVBuf
lda #CMD.IF.PTR
lda #CMD.STACK.PTR
tay
sta (pData),y
@ -27,7 +28,7 @@ CMD.Quit >LDA.G CMD.hArgVBuf
beq .1
>SYSCALL FreeMem
.1 >LDA.G CMD.hCmdBuf
.1 >LDA.G CMD.hCLBuf
beq .9
>SYSCALL FreeMem
.9 rts
@ -41,9 +42,9 @@ Cmd.Exec >LDA.G CMD.IntCmd
cpx #C.ELSE
bcs .1
>LDA.G CMD.IF.PTR
>LDA.G CMD.STACK.PTR
cmp #CMD.IF.PTR
cmp #CMD.STACK.PTR
beq .1 no IF pending...
tay
@ -72,6 +73,9 @@ Cmd.Exec >LDA.G CMD.IntCmd
.3 >SLEEP Suspend this PID
ldy #S.PS.RC
lda (pPs),y
bne .9
.8 clc
.9 rts
*--------------------------------------
@ -221,15 +225,13 @@ Cmd.INT.SETVAR jsr CMD.IsSwitch
cmp #'X'
bne .99
>LDA.G bSET.X
eor #$ff
lda #$ff
>EOR.G bSET.X
sta (pData),y
clc
.8 clc
rts
.10 >STYA ZPPTR1
lda (ZPPTR1)
.10 lda (ZPPTR1) set by CMD.IsSwitch
cmp #'=' string is '=value' ?
beq .99 syntax error
@ -258,10 +260,6 @@ Cmd.INT.SETVAR jsr CMD.IsSwitch
>SYSCALL UnsetEnv
rts
.8 clc
rts
.99 lda #E.SYN
sec
rts
@ -295,10 +293,10 @@ Cmd.INT.TIME clc
bra .2
.1 >PUSHW L.FMT.TIME
.2 >LDYA ZPCMDBuf
.2 >LDYA ZPCLBuf
>SYSCALL StrFTime
>LDYA ZPCMDBuf
>LDYA ZPCLBuf
>SYSCALL puts
rts
*--------------------------------------
@ -454,8 +452,8 @@ Cmd.INT.RD ldx #1
.9 jmp Cmd.Exec.ERRSYN
*--------------------------------------
Cmd.INT.IF >LDA.G CMD.IF.PTR
cmp #CMD.IF.PTR+CMD.IF.STACK.MAX
Cmd.INT.IF >LDA.G CMD.STACK.PTR
cmp #CMD.STACK.PTR+CMD.STACK.MAX
beq .9
inc
sta (pData),y
@ -475,7 +473,7 @@ Cmd.INT.IF >LDA.G CMD.IF.PTR
dex
dex 1 or $ff
>LDA.G CMD.IF.PTR
>LDA.G CMD.STACK.PTR
tay
txa
sta (pData),y true or false
@ -496,7 +494,7 @@ Cmd.INT.IF >LDA.G CMD.IF.PTR
jsr CMD.IF.UNARY
bcs .9
>LDA.G CMD.IF.PTR
>LDA.G CMD.STACK.PTR
tay
txa
eor (pData),y
@ -523,7 +521,7 @@ Cmd.INT.IF >LDA.G CMD.IF.PTR
jsr CMD.IF.BINARY
bcs .9
>LDA.G CMD.IF.PTR
>LDA.G CMD.STACK.PTR
tay
txa
eor (pData),y
@ -616,6 +614,7 @@ CMD.IF.BINARY ldx #2
>SYSCALL strcmp
lsr CS if !=
>EOR.G CMD.Operator
sta (pData),y
tax
clc
rts
@ -705,9 +704,9 @@ CMD.IF.BINARY.NUM
sec
rts
*--------------------------------------
Cmd.INT.ELSE >LDA.G CMD.IF.PTR
Cmd.INT.ELSE >LDA.G CMD.STACK.PTR
cmp #CMD.IF.PTR
cmp #CMD.STACK.PTR
beq .9
tay
@ -722,12 +721,12 @@ Cmd.INT.ELSE >LDA.G CMD.IF.PTR
sec
rts
*--------------------------------------
Cmd.INT.FI >LDA.G CMD.IF.PTR
cmp #CMD.IF.PTR
Cmd.INT.FI >LDA.G CMD.STACK.PTR
cmp #CMD.STACK.PTR
beq .9
dec
>STA.G CMD.IF.PTR
>STA.G CMD.STACK.PTR
clc
rts

View File

@ -70,7 +70,7 @@ HIS.Add >LDA.G HIS.hBuf
.3 ldy #$ff
.4 iny
lda (ZPCMDBuf),y
lda (ZPCLBuf),y
sta (ZPPTR1),y
bne .4
@ -138,7 +138,7 @@ HIS.SetA jsr HIS.GetA
.2 iny
lda (ZPPTR1),y
sta (ZPCMDBuf),y
sta (ZPCLBuf),y
bne .2
tya

View File

@ -8,6 +8,10 @@ AUTO 4,1
*--------------------------------------
CSH .EQ 0
*--------------------------------------
CL.MAX .EQ 127
History.MAX .EQ 256
CMD.STACK.MAX .EQ 8
*--------------------------------------
C.STARTPROC .EQ 0
C.CD .EQ 2
C.DATE .EQ 4
@ -34,20 +38,17 @@ C.FI .EQ 30
ZPPtr1 .EQ ZPBIN
ZPPtr2 .EQ ZPBIN+2
ZPPtr3 .EQ ZPBIN+4
ZPCMDBuf .EQ ZPBIN+6
ZPCLBuf .EQ ZPBIN+6
ZPArgVBuf .EQ ZPBIN+8
ZPFileBufPtr .EQ ZPBIN+10
ZPCLBufPtr .EQ ZPBIN+12
.DO CSH=1
ZPCSHSymbols .EQ ZPBIN+12
ZPCSHData .EQ ZPBIN+14
ZPCSHValue .EQ ZPBIN+16
ZPCSHStack .EQ ZPBIN+18
ZPCSHSymbols .EQ ZPBIN+14
ZPCSHData .EQ ZPBIN+16
ZPCSHValue .EQ ZPBIN+18
ZPCSHStack .EQ ZPBIN+20
.FIN
*--------------------------------------
CmdLine.MAX .EQ 127
History.MAX .EQ 256
CMD.IF.STACK.MAX .EQ 8
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
@ -60,9 +61,10 @@ CS.START cld
.DA DS.END-DS.START DS
.DA #64 SS
.DO CSH=1
.DA #20 ZP
.DA #22 ZP
.ELSE
.DA #12 ZP
.DA #14 ZP
.FIN
.DA 0
*--------------------------------------
* Relocation Table
@ -199,16 +201,18 @@ CS.RUN.LOOP jsr CL.Reset
>LDA.G hFileBuf batch mode ?
bne .8
bra .61
.60 cmp #C.CR
bne .4
>STZ.G bPause
.61 >STZ.G bPause
bra .62
.6 >LDA.G hVarName read mode ?
bne .7
>LDA.G hFileBuf batch mode ?
.62 >LDA.G hFileBuf batch mode ?
beq CS.RUN.INTERCATIVE
jmp CS.RUN.BATCH
.7 jmp CS.RUN.READ
@ -238,7 +242,7 @@ CS.RUN.INTERCATIVE
>LDA.G CL.bExec Something to execute ?
bpl .1
lda (ZPCMDBuf)
lda (ZPCLBuf)
beq .8 Empty line
jsr HIS.Add
@ -256,7 +260,7 @@ CS.RUN.READ
>LDA.G CL.bExec
bpl .1
lda (ZPCMDBuf)
lda (ZPCLBuf)
bne .2
>LDA.G hVarName
@ -264,7 +268,7 @@ CS.RUN.READ
>SYSCALL UnSetEnv
bra .7
.2 >PUSHW ZPCMDBuf
.2 >PUSHW ZPCLBuf
>LDA.G hVarName
>SYSCALL GetMemPtr
@ -290,7 +294,7 @@ CS.RUN.BATCH >SYSCALL GetChar
bne .1
* sec
rts
.9 rts
.1 cmp #19 test Ctrl-s
bne .2
@ -321,10 +325,17 @@ CS.RUN.BATCH >SYSCALL GetChar
.7 >LDA.G CL.bExec
bpl CS.RUN.LOOP.80
lda (ZPCMDBuf)
lda (ZPCLBuf)
beq CS.RUN.LOOP.80
jsr CL.Trace
>LDA.G bSET.X
beq CS.RUN.Exec
>PUSHW ZPCLBuf
>PUSHBI 2
>LDYA L.MSG.TRACE
>SYSCALL printf
bcs .9
*--------------------------------------
CS.RUN.Exec jsr CL.Parse
bcs CS.RUN.LOOP.END
@ -555,9 +566,10 @@ CL.Ptr .BS 1
CL.Len .BS 1
CL.bExec .BS 1
CMD.hCLBuf .BS 1
CMD.IntCmd .BS 1
CMD.hCmdLine .BS 1
CMD.hCmdBuf .BS 1
CMD.hArgVBuf .BS 1
CMD.ArgIndex .BS 1
@ -569,8 +581,8 @@ CMD.PSFlags .BS 1
CMD.Stat .BS S.STAT
CMD.Time .BS S.TIME
CMD.IF.PTR .BS 1
CMD.IF.STACK .BS CMD.IF.STACK.MAX
CMD.STACK.PTR .BS 1
CMD.STACK .BS CMD.STACK.MAX
HIS.hBuf .BS 1
HIS.Count .BS 1