Kernel 0.9.2

This commit is contained in:
Rémy GIBERT 2018-09-17 08:16:45 +02:00
parent 5ce201567b
commit 5916df2322
6 changed files with 195 additions and 85 deletions

Binary file not shown.

Binary file not shown.

View File

@ -300,6 +300,7 @@ C.FF .EQ 12
C.CR .EQ 13
C.FS .EQ 21
C.ESC .EQ 27
C.SPACE .EQ 32
C.DEL .EQ 127
*--------------------------------------
DEVID.NULL .EQ 0

View File

@ -128,6 +128,11 @@ CL.Insert >LDA.G CmdBuflen
txa
sta (ZPCMDBuf),y
>LDA.G bSecureRead
bpl .2
ldx #'*'
.2 txa
>SYSCALL PutChar
>INC.G CmdBufPtr
@ -156,7 +161,6 @@ CL.RESET lda #0
>STA.G bCmdBufexec
>STA.G CmdBufPtr
>STA.G CmdBuflen
>STA.G bSecureRead Clear password mode
rts
*--------------------------------------
CL.BS >LDA.G CmdBufPtr

View File

@ -71,7 +71,7 @@ Cmd.Parse.NextC lda (ZPPtr1)
*--------------------------------------
* ZPCMDBuf-> Command line (formatted & not empty)
*--------------------------------------
Cmd.Exec lda #0
CMD.Exec lda #0
>STA.G CMD.bStartProc
>STA.G CMD.hFullpath
@ -88,7 +88,7 @@ Cmd.Exec lda #0
txa
>STA.G CMD.hCmdLine
>LDYA L.INTCMDS
>LDYA L.CMD.INT
>STYA ZPPtr2
ldx #0
@ -136,8 +136,8 @@ Cmd.Exec lda #0
inc ZPPtr2+1
bra .3
.8 jsr Cmd.Exec.Split X unmodified
jmp (J.INTCMDS,x) Found an internal Cmd...
.8 jsr Cmd.Exec.GetArgs X unmodified
jmp (J.CMD.INT,x) Found an internal Cmd...
*--------------------------------------
Cmd.Exec.Done php
pha
@ -152,7 +152,7 @@ Cmd.Exec.Done php
plp
rts
*--------------------------------------
Cmd.Exec.EXT jsr Cmd.Exec.Split
Cmd.Exec.EXT jsr Cmd.Exec.GetArgs
lda (ZPPtr1)
cmp #'/' Command line is already full path, no search
@ -490,7 +490,8 @@ Cmd.Exec.READ lda (ZPPtr2)
lda #0
>STA.G bSecureRead
>STA.G CMD.VarName.LEN
lda pData
clc
adc #CMD.VarName
@ -499,85 +500,100 @@ Cmd.Exec.READ lda (ZPPtr2)
adc #0
sta ZPPTR1+1
ldy #0
.1 lda (ZPPtr2),y
.1 lda (ZPPtr2)
beq .8
iny
cmp #' '
beq .1
cmp #'-'
bne .11
jsr Cmd.Exec.GetNextP2
bra .1
.11 cmp #'-'
bne .7
lda (ZPPtr2),y
jsr Cmd.Exec.GetNextP2
beq .9
iny
cmp #'S'
bne .2
lda #$80
>STA.G bSecureRead
jsr Cmd.Exec.GetNextP2
beq .8
cmp #' '
bne .9
bra .1
.2 cmp #'P'
bne .9
lda (ZPPtr2),y
jsr Cmd.Exec.GetNextP2
beq .9
iny
cmp #' '
bne .9
lda (ZPPtr2),y
jsr Cmd.Exec.GetNextP2
beq .9
iny
cmp #'"'
bne .9
.3 lda (ZPPtr2),y
.3 jsr Cmd.Exec.GetNextP2
beq .9
iny
cmp #'"'
beq .1
phy
>SYSCALL PutChar
ply
bcs .99
bra .3
.9 jmp Cmd.Exec.ERRSYN
.70 lda (ZPPtr2),y
.7 >LDA.G CMD.VarName.LEN
cmp #VarLen.MAX
beq .9
pha
inc
sta (pData),y
ply
lda (ZPPtr2)
sta (ZPPTR1),y
iny
lda #0
sta (ZPPTR1),y
jsr Cmd.Exec.GetNextP2
beq .1
cmp #' '
beq .1
.7 lda (ZPPTR1)
cmp #VarLen.MAX
beq .9
inc
sta (ZPPTR1)
tay
lda (ZPPtr2),y
sta (ZPPTR1),y
bne .70
bra .7
.8 lda (ZPPTR1) No var name ? SYNERR
.8 >LDA.G CMD.VarName.LEN No var name ? SYNERR
beq .9
lda #$ff
>STA.G bReadMode
clc
.99 jmp Cmd.Exec.Done
*--------------------------------------
Cmd.Exec.SLEEP lda (ZPPtr2)
beq .9
>PUSHW ZPPtr2
>PUSHEA.G Sleep
>LDYA ZPPtr2
>SYSCALL AToL
bcs .9
>PULLL.G Sleep
jmp Cmd.Exec.Done
.9 jmp Cmd.Exec.ERRSYN
*--------------------------------------
@ -591,7 +607,48 @@ Cmd.Exec.EXIT lda #$FF
clc
jmp Cmd.Exec.Done
*--------------------------------------
Cmd.Exec.Split ldy #$ff CMD Len
Cmd.Exec.IF >STZ.G CMD.IFNOT
lda (ZPPtr2)
beq .9
cmp #'!'
bne .1
lda #$ff
sta (pData),y Y = #CMD.IFNOT
jsr Cmd.Exec.GetNextP2NB
beq .9
cmp #'('
bne .9
jsr Cmd.Exec.GetNextP2NB
beq .9
cmp #'-' -d -e -f
bne .1
jsr Cmd.Exec.GetNextP2NB
beq .9
.1 >DEBUG
>LDYA ZPPtr2
>SYSCALL puts
jmp Cmd.Exec.Done
.9 jmp Cmd.Exec.ERRSYN
*--------------------------------------
Cmd.Exec.GetArgs
ldy #$ff CMD Len
.1 iny
lda (ZPPtr1),y Get CMD char...
@ -611,8 +668,36 @@ Cmd.Exec.Split ldy #$ff CMD Len
lda ZPPtr1+1
adc #0
sta ZPPtr2+1 ZPPtr2->ARGS or CMD ending 0 if empty
* >LDYA L.CMD.IOR
* >STYA ZPPtr2
* ldx #0
*.3 lda (ZPPtr2)
rts
*--------------------------------------
Cmd.Exec.GetArg1
*--------------------------------------
Cmd.Exec.GetNextP2NB
.1 jsr Cmd.Exec.GetNextP2
beq .9
cmp #C.SPACE
beq .1
.9 rts
*--------------------------------------
Cmd.Exec.GetNextP2
inc ZPPtr2
bne .1
inc ZPPtr2+1
.1 lda (ZPPtr2)
rts
*--------------------------------------
MAN
SAVE /A2OSX.SRC/SBIN/SHELL.S.CMD
LOAD /A2OSX.SRC/SBIN/SHELL.S

View File

@ -13,11 +13,13 @@ AUTO 4,1
ZPPtr1 .EQ ZPBIN
ZPPtr2 .EQ ZPBIN+2
ZPCMDBuf .EQ ZPBIN+4
ZPCSHBufPtr .EQ ZPBIN+6
ZPCSHSymbols .EQ ZPBIN+8
ZPCSHData .EQ ZPBIN+10
ZPCSHValue .EQ ZPBIN+12
ZPCSHStack .EQ ZPBIN+14
ZPArg1Buf .EQ ZPBIN+6
ZPArg2Buf .EQ ZPBIN+8
ZPCSHBufPtr .EQ ZPBIN+10
ZPCSHSymbols .EQ ZPBIN+12
ZPCSHData .EQ ZPBIN+14
ZPCSHValue .EQ ZPBIN+16
ZPCSHStack .EQ ZPBIN+18
*--------------------------------------
CmdLine.MAX .EQ 255
VarLen.MAX .EQ 15
@ -29,11 +31,12 @@ CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA 0
.DA #S.PS.F.EVENT S.PS.F
.DA #0
.DA CS.END-CS.START CS
.DA DS.END-DS.START DS
.DA #64 SS
.DA #16 ZP
.DA #20 ZP
.DA 0
*--------------------------------------
* Relocation Table
@ -60,11 +63,13 @@ J.ESC .DA CL.BS left arrow
.DA HIS.GetNext
.DA HIS.GetPrev
.DA CL.NAK right arow
L.INTCMDS .DA INTCMDS
J.INTCMDS .DA Cmd.Exec.CD
L.CMD.INT .DA CMD.INT
L.CMD.IOR .DA CMD.IOR
J.CMD.INT .DA Cmd.Exec.CD
.DA Cmd.Exec.DATE
.DA Cmd.Exec.ECHO
.DA Cmd.Exec.EXIT
.DA Cmd.Exec.IF
.DA Cmd.Exec.PAUSE
.DA Cmd.Exec.PWD
.DA Cmd.Exec.READ
@ -172,7 +177,8 @@ CS.RUN >LDA.G bReadMode READ Command ?
jmp CS.RUN.BATCH
*--------------------------------------
.10 jsr CL.RESET reset CmdBuf
>STA.G bSecureRead Clear password mode
.12 jsr CL.PrintPrompt
bcs .9
@ -213,9 +219,8 @@ CS.RUN >LDA.G bReadMode READ Command ?
sec
.9 rts
*--------------------------------------
CS.RUN.READ lda #0 reset Buffer
sta (ZPCMDBuf)
CS.RUN.READ jsr CL.RESET reset CmdBuf
.1 >SLEEP
>SYSCALL GetChar
bcs .1 no char
@ -225,11 +230,19 @@ CS.RUN.READ lda #0 reset Buffer
>LDA.G bCmdBufExec
bpl .1
>STZ.G bReadMode
lda (ZPCMDBuf)
beq .8
>PUSHW ZPCMDBuf
>LEA.G CMD.VarName
>SYSCALL SetEnv
rts
.8 clc
rts
*--------------------------------------
CS.RUN.BATCH >SYSCALL GetChar
bcs .2
@ -268,12 +281,12 @@ CS.RUN.BATCH >SYSCALL GetChar
.7 >LDA.G bCmdBufExec
bpl .8 Empty line....nothing to do....
jsr Cmd.Parse
jsr CMD.Parse
lda (ZPCMDBuf)
beq .8
jsr Cmd.Exec
jsr CMD.Exec
bcs .8
lda #0
@ -339,36 +352,6 @@ SetPWD ldy #S.PS.hPREFIX
*--------------------------------------
CS.END
*--------------------------------------
ENV.PATH .AZ "PATH"
ENV.PWD .AZ "PWD"
ENV.PS1 .AZ "PS1"
ENV.HOME .AZ "HOME"
*--------------------------------------
* https://www.tldp.org/LDP/abs/html/io-redirection.html
*--------------------------------------
CMD. .AZ "&"
.AZ "|"
.AZ "<"
.AZ ">"
.AZ ">>"
.AZ "1>"
.AZ "1>>"
.AZ "2>"
.AZ "2>>"
*--------------------------------------
INTCMDS .AZ "CD"
.AZ "DATE"
.AZ "ECHO"
.AZ "EXIT"
.AZ "PAUSE"
.AZ "PWD"
.AZ "READ"
.AZ "SET"
.AZ "SLEEP"
.AZ "STARTPROC"
.AZ "TIME"
.HS 00
*--------------------------------------
MSG.GREETINGS .AZ "\r\nA2osX-Shell %d.%d\r\n\r\n"
MSG.PROMPT .AZ "\e[7h$ "
MSG.ECHO .AS ">%s"
@ -378,6 +361,41 @@ MSG.PRINTENV .AZ "%s=%s\r\n"
MSG.CSHERR .AZ "^\r\nLine #%D:"
FMT.DATE .AZ "%A (%w), %B %d %Y"
FMT.TIME .AZ "%H:%M:%S (%I:%M:%S%p)"
*--------------------------------------
ENV.PATH .AZ "PATH"
ENV.PWD .AZ "PWD"
ENV.PS1 .AZ "PS1"
ENV.HOME .AZ "HOME"
*--------------------------------------
* https://www.tldp.org/LDP/abs/html/io-redirection.html
*--------------------------------------
CMD.IOR .AZ "&"
.AZ "|"
.AZ "<"
.AZ ">>"
.AZ ">"
.AZ "1>>"
.AZ "1>"
.AZ "2>>"
.AZ "2>"
.HS 00
*--------------------------------------
CMD.INT .AZ "CD"
.AZ "DATE"
.AZ "ECHO"
.AZ "EXIT"
.AZ "IF"
.AZ "PAUSE"
.AZ "PWD"
.AZ "READ"
.AZ "SET"
.AZ "SLEEP"
.AZ "STARTPROC"
.AZ "TIME"
.HS 00
*--------------------------------------
CMD.IF.Chars .AS "def"
CMD.IF.Chars.Cnt .EQ *-CMD.IF.Chars
*--------------------------------------
.INB /A2OSX.SRC/SBIN/SHELL.C.CSH
.INB /A2OSX.SRC/X.ERRORS.S
@ -406,9 +424,11 @@ Sleep .BS 4
CMD.hCmdLine .BS 1
CMD.hFullpath .BS 1
CMD.bStartProc .BS 1
CMD.VarName.LEN .BS 1
CMD.VarName .BS VarLen.MAX+1
CMD.Stat .BS S.STAT
CMD.Time .BS S.TIME
CMD.IFNOT .BS 1
HIS.hBuf .BS 1
HIS.Count .BS 1