Kernel 0.92

This commit is contained in:
Rémy GIBERT 2019-01-28 16:33:30 +00:00
parent 0f044f3187
commit f29d232415
6 changed files with 1418 additions and 1422 deletions

Binary file not shown.

View File

@ -288,310 +288,6 @@ CL.PrintCLBuf >LDYA ZPCLBuf
>SYSCALL fputs
rts
*--------------------------------------
* Read From CLBuf or FileBuf
*--------------------------------------
CL.GetLine >LDYA ZPFileBufPtr
>STYA ZPFileBufPtrBak
lda (ZPFileBufPtr)
beq .9
ldx #0 not in "
ldy #0
.1 lda (ZPFileBufPtr),y
beq .7
cmp #C.CR
beq .6
cmp #'"'
bne .2
txa
eor #$80 toggle " switch
tax
lda #'"'
bra .5
.2 cmp #';'
bne .5
txa
beq .6
lda #';'
.5 sta (ZPCLBuf),y
iny
cpy #CL.MAX
bne .1
lda #E.SYN Line Too long !!!
* sec
rts
.6 sec skip CR or ;
.HS 90 BCC
.7 clc
tya
adc ZPFileBufPtr
sta ZPFileBufPtr
bcc .8
inc ZPFileBufPtr+1
.8 lda #0
sta (ZPCLBuf),y
tya
>STA.G CL.Len
lda #$ff
>STA.G CL.bExec
clc
rts
.9 lda #C.EOF
sec
rts
*--------------------------------------
* in:
* ZPCLBuf : CString command line
* out:
* ZPArgVBuf :
* /path/excmd\0 arg1\0 arg2\0 ... \0
* - or -
* intcmd\0 arg1\0 arg2\0 ... \0
*--------------------------------------
CL.Parse >STZ.G CMD.IntCmd
lda #S.PS.F.HOLD+S.PS.F.DUPENV
>STA.G CMD.PSFlags
>PUSHW ZPCLBuf
>LDYA ZPCLBuf
>STYA ZPCLBufPtr
>SYSCALL Args2ArgV
lda #0
sta (ZPArgVBuf)
lda (ZPCLBufPtr)
beq .8
.1 cmp #'#' comment ?
beq .8 yes, ignore remaining
>LDA.G CMD.IntCmd
bne .3 we already have Cmd, go check args
ldy #1
lda (ZPCLBufPtr),y only one char ?
bne .2
lda (ZPCLBufPtr)
cmp #'.' leading dot ?
bne .2
>LDA.G CMD.PSFlags yes, child process will run in same ENV
and #$ff^S.PS.F.DUPENV
sta (pData),y
bra .6 and skip this token
.2 jsr CL.CheckCmd
bcc .6 success, skip token, already added by CheckCmd
rts
.3 jsr CL.CheckIO
bcc .7 IO token & related args processed
tay an error ?
bne .9 yes...I/O error...
jsr CL.AddCLBufPtrToArgV no...add as an arg
bcs .9
.6 jsr CL.NextCLToken
.7 lda (ZPCLBufPtr)
bne .1
.8 clc
.9 rts
*--------------------------------------
* ZPCLBuf-> argv[] (formatted & not empty)
*--------------------------------------
CL.CheckCmd ldy #$ff
.1 iny
lda (ZPCLBufPtr),y
beq .2
cmp #'/'
bne .1
bra .4
.2 >PUSHW ZPCLBufPtr
>LDYA L.CMD.INT
jsr Lookup no / found, search internal...
bcs .4 not internal, search PATH
phx
plx
bne .3
>LDA.G CMD.PSFlags if STARTPROC, skip keyword...
and #$ff^S.PS.F.HOLD
sta (pData),y ...and toggle S.PS.F.HOLD flag
clc
.9 rts
.3 jsr CL.AddYAToArgV X unmodified
bcs .9
txa
>STA.G CMD.IntCmd
clc
rts
.4 >LDYA ZPCLBufPtr
jsr CL.AddYAToArgV
lda #$ff
>STA.G CMD.IntCmd
clc
CL.CheckCmd.RTS
rts
*--------------------------------------
CL.CheckIO >PUSHW ZPCLBufPtr
>LDYA L.CL.IO
jsr Lookup
bcs .9 not a IO token...should be an arg....
phx
jsr CL.NextCLToken skip this IO token
plx
jmp (J.CL.IO,x)
.9 lda #0
rts
*--------------------------------------
CL.IO.AMP >LDA.G CMD.PSFlags
and #$ff^S.PS.F.HOLD
sta (pData),y
clc
rts
CL.IO.IN lda #O.RDONLY+O.TEXT
jsr CL.IO.Open
bcs .9
jsr IO.Set.In
jsr CL.NextCLToken skip arg
clc
.9 rts
CL.IO.OUTA
CL.IO.1OUTA lda #O.WRONLY+O.APPEND+O.CREATE+O.TEXT
bra CL.IO.OUT.1
CL.IO.OUT
CL.IO.1OUT lda #O.WRONLY+O.TRUNC+O.CREATE+O.TEXT
CL.IO.OUT.1 jsr CL.IO.Open
bcs .9
jsr IO.Set.Out
jsr CL.NextCLToken skip arg
clc
.9 rts
CL.IO.2OUTA lda #O.WRONLY+O.APPEND+O.CREATE+O.TEXT
bra CL.IO.2OUT.1
CL.IO.2OUT lda #O.WRONLY+O.TRUNC+O.CREATE+O.TEXT
CL.IO.2OUT.1 jsr CL.IO.Open
bcs .9
jsr IO.Set.Err
jsr CL.NextCLToken skip arg
clc
.9 rts
*--------------------------------------
CL.IO.Open pha
lda (ZPCLBufPtr)
beq .9 no arg left....
>PUSHWI 0 Aux type
>PUSHBI S.FI.T.TXT ftype
pla
>PUSHA flags
>LDYA ZPCLBufPtr
>SYSCALL fopen
rts
.9 pla
lda #E.CSYN
sec
rts
*--------------------------------------
CL.NextCLToken
lda (ZPCLBufPtr)
inc ZPCLBufPtr
bne .1
inc ZPCLBufPtr+1
.1 tax
bne CL.NextCLToken
rts
*--------------------------------------
CL.AddCLBufPtrToArgV
>LDYA ZPCLBufPtr
CL.AddYAToArgV >STYA ZPPtr1
>LDYA ZPArgVBuf
>STYA ZPPtr2
.1 lda (ZPPtr2) scan to end of argV
beq .6
.2 inc ZPPtr2
bne .3
inc ZPPtr2+1
.3 lda (ZPPtr2)
bne .2
inc ZPPtr2
bne .4
inc ZPPtr2+1
.4 lda (ZPPtr2)
bne .2
.6 ldy #$ff
.7 iny
* beq .9
lda (ZPPtr1),y
sta (ZPPtr2),y
bne .7 including str ending \0
iny
* beq .9
sta (ZPPtr2),y arg[] ending \0
clc
rts
.9 lda #E.BUF
sec
rts
*--------------------------------------
MAN
SAVE USR/SRC/BIN/SHELL.S.CL
LOAD USR/SRC/BIN/SHELL.S

File diff suppressed because it is too large Load Diff

1106
BIN/SHELL.S.CORE.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@ -111,9 +111,9 @@ IO.PrintBatchErrMsg
bne .2 Scan until EoL
ldx ZPPtr1
cpx ZPFileBufPtr
cpx ZPInputBufPtr
lda ZPPtr1+1
sbc ZPFileBufPtr+1
sbc ZPInputBufPtr+1
bcc .1 not this line....
.4 ldy #0
@ -137,7 +137,7 @@ IO.PrintBatchErrMsg
lda (pPS),y
>SYSCALL fprintf
lda ZPFileBufPtr
lda ZPInputBufPtr
sec
sbc ZPPtr2
beq .8

View File

@ -4,7 +4,7 @@ AUTO 4,1
.LIST OFF
.OP 65C02
.OR $2000
.TF BIN/SHELL
.TF BIN/SHELL2
*--------------------------------------
CL.MAX .EQ 159
History.MAX .EQ 256
@ -63,9 +63,8 @@ ZPPtr2 .BS 2
ZPPtr3 .BS 2
ZPCLBuf .BS 2
ZPCLBufPtr .BS 2
ZPFileBufPtr .BS 2
ZPFileBufPtrBak .BS 2
ZPCmdBuf .BS 2
ZPInputBufPtr .BS 2
ZPInputBufPtrBak .BS 2
ZPArgVBuf .BS 2
ZS.END .ED
*--------------------------------------
@ -119,42 +118,42 @@ J.CL.IO .DA CL.IO.AMP
.DA CL.IO.1OUT
.DA CL.IO.2OUTA
.DA CL.IO.2OUT
L.CMD.INT .DA CMD.INT
J.CMD.INT .DA Cmd.INT.STARTPROC
.DA Cmd.INT.CD
.DA Cmd.INT.DATE
.DA Cmd.INT.ECHO
.DA Cmd.INT.EXIT
.DA Cmd.INT.GETKEY
.DA Cmd.INT.MD
.DA Cmd.INT.PAUSE
.DA Cmd.INT.PWD
.DA Cmd.INT.RD
.DA Cmd.INT.READ
.DA Cmd.INT.REN
.DA Cmd.INT.SET
.DA Cmd.INT.SLEEP
.DA Cmd.INT.SHIFT
.DA Cmd.INT.TIME
.DA Cmd.INT.PUSHD
.DA Cmd.INT.POPD
.DA Cmd.INT.BREAK
.DA Cmd.INT.CONTINUE
.DA Cmd.INT.FOR
.DA Cmd.INT.NEXT
.DA Cmd.INT.WHILE
.DA Cmd.INT.LOOP
.DA Cmd.INT.IF
.DA Cmd.INT.ELSE
.DA Cmd.INT.FI
L.CMD.Eval.TOKEN1 .DA CMD.Eval.TOKEN1
L.CMD.Eval.TOKEN2 .DA CMD.Eval.TOKEN2
J.CMD.Eval.TOKEN2 .DA CMD.Eval.D
.DA CMD.Eval.E
.DA CMD.Eval.F
L.CMD.Eval.TOKEN3 .DA CMD.Eval.TOKEN3
L.CMD.Eval.TOKEN4 .DA CMD.Eval.TOKEN4
J.CMD.Eval.TOKEN4 .DA M32.Add
L.CORE.INT .DA CORE.INT
J.CORE.INT .DA CORE.INT.STARTPROC
.DA CORE.INT.CD
.DA CORE.INT.DATE
.DA CORE.INT.ECHO
.DA CORE.INT.EXIT
.DA CORE.INT.GETKEY
.DA CORE.INT.MD
.DA CORE.INT.PAUSE
.DA CORE.INT.PWD
.DA CORE.INT.RD
.DA CORE.INT.READ
.DA CORE.INT.REN
.DA CORE.INT.SET
.DA CORE.INT.SLEEP
.DA CORE.INT.SHIFT
.DA CORE.INT.TIME
.DA CORE.INT.PUSHD
.DA CORE.INT.POPD
.DA CORE.INT.BREAK
.DA CORE.INT.CONTINUE
.DA CORE.INT.FOR
.DA CORE.INT.NEXT
.DA CORE.INT.WHILE
.DA CORE.INT.LOOP
.DA CORE.INT.IF
.DA CORE.INT.ELSE
.DA CORE.INT.FI
L.CORE.Eval.TOKEN1 .DA CORE.Eval.TOKEN1
L.CORE.Eval.TOKEN2 .DA CORE.Eval.TOKEN2
J.CORE.Eval.TOKEN2 .DA CORE.Eval.D
.DA CORE.Eval.E
.DA CORE.Eval.F
L.CORE.Eval.TOKEN3 .DA CORE.Eval.TOKEN3
L.CORE.Eval.TOKEN4 .DA CORE.Eval.TOKEN4
J.CORE.Eval.TOKEN4 .DA M32.Add
.DA M32.Sub
.DA M32.Mul
.DA M32.Div
@ -186,7 +185,7 @@ CS.RUN jsr CMD.Init
txa
>STA.G hFileBuf
>SYSCALL GetMemPtr
>STYA ZPFileBufPtr
>STYA ZPInputBufPtr
lda #0
jsr ShiftA Remove $0=/bin/shell
@ -359,7 +358,7 @@ CS.RUN.BATCH >SYSCALL GetChar
clc
jmp CS.RUN.LOOP.END
.2 jsr CL.GetLine
.2 jsr CL.GetCmd
bcc .7
cmp #C.EOF
@ -674,7 +673,6 @@ CL.Len .BS 1
CL.bExec .BS 1
CMD.IntCmd .BS 1
CMD.hCmdBuf .BS 1
CMD.hArgVBuf .BS 1
CMD.ArgIndex .BS 1