Kernel 0.9.1 : Code reorganization & move to CSTR : SHELL

This commit is contained in:
Rémy GIBERT 2017-09-13 08:17:46 +02:00
parent 46918f88f0
commit 83b1abc4df
5 changed files with 123 additions and 131 deletions

Binary file not shown.

Binary file not shown.

View File

@ -166,11 +166,8 @@ Cmd.Exec.EXT pla Discard CMD len
>PUSHW L.STAT
>PUSHW ZPPtr1
>SYSCALL STAT
bcs .99
>LDYAI UsrBuf256
>STYA ZPPtr1
bra .3
bcc .3
bra Cmd.Exec.Done
.1 >LDYA L.ENV.PATH push ENVNAME=PATH for search
>SYSCALL GetEnv.YA get value for ENV=PATH
@ -183,7 +180,6 @@ Cmd.Exec.EXT pla Discard CMD len
lda (pPs),y
>SYSCALL GetMemPtr.A
jsr Cmd.Exec.Search
bcs .99
.3 lda STAT+S.STAT.P.TYPE
@ -382,9 +378,9 @@ Cmd.Exec.STARTPROC
*--------------------------------------
Cmd.Exec.SET lda (ZPPTR2)
bne Cmd.Exec.SETVAR
* No arg, print all ENV
ldy #S.PS.hENV
lda (pPs),y
>SYSCALL GetMemPtr.A
@ -394,11 +390,11 @@ Cmd.Exec.SET lda (ZPPTR2)
beq .8 Ending 0 ?
ldy #$ff
.2 iny
lda (ZPPTR1),y
bne .2
tya
sec
adc ZPPTR1
@ -430,7 +426,7 @@ Cmd.Exec.SET lda (ZPPTR2)
bra .1
.8 clc
.9 rts
.9 rts
Cmd.Exec.SETVAR ldy #0

View File

@ -64,7 +64,6 @@ L.MSG.CSHERR .DA MSG.CSHERR
L.ENV.PATH .DA ENV.PATH
L.ENV.PWD .DA ENV.PWD
L.ENV.PS1 .DA ENV.PS1
L.CMD .DA CMD
L.TIME .DA TIME
L.STAT .DA STAT
L.FMT.DATE .DA FMT.DATE
@ -101,25 +100,25 @@ CS.INIT jsr SetPWD
jsr CMD.Init
bcs .9
lda (pPs)
ora #S.PS.F.EVENT Now accept events
sta (pPs)
ldy #S.PS.ARGC
lda (pPs),y
beq .1 no arg, continue starting interactive
jmp CSH.Init
.1 jsr HIS.Init
bcs .9
>LDYA L.MSG.GREETINGS
>SYSCALL PrintF.YA
.9 rts
.9 rts
*--------------------------------------
CS.RUN >LDA.G bReadMode READ Command ?
bne CS.RUN.READ
@ -135,53 +134,51 @@ CS.RUN >LDA.G bReadMode READ Command ?
>SYSCALL GetChar
bcs .8
.13 jsr CheckSleep
bne .8
>LDA.G CSH.hBuf batch mode ?
beq .10
jmp CS.RUN.BATCH
* Interactive Mode
jmp CS.RUN.BATCH
* Interactive Mode
.10 >LDA.G hCmdBuf Get the buffer
>SYSCALL GetMemPtr.A
>STYA ZPCMDBuf
lda #0 reset it
sta (ZPCMDBuf)
>STA.G bSecureRead Clear password mode
.12 jsr PrintPrompt
bcs CS.RUN.EXIT.RTS
.1 >SYSCALL Sleep
>SYSCALL GetChar
bcs .1 no char
jsr CS.CHARIN
>LDA.G bCmdBufexec Something to execute ?
bpl .1
jsr Cmd.Parse
>LDA.G CmdBuflen
beq .12 Empty line
jsr HIS.Add
jsr Cmd.Exec
ldy #S.PS.RC
sta (pPs),y
>LDA.G bExit
bne CS.RUN.EXIT
.8 clc
rts
@ -192,21 +189,21 @@ CS.RUN.EXIT.RTS rts
CS.RUN.READ >LDA.G hCmdBuf Get the buffer
>SYSCALL GetMemPtr.A
>STYA ZPCMDBuf
lda #0 reset it
sta (ZPCMDBuf)
.1 >SYSCALL Sleep
>SYSCALL GetChar
bcs .1 no char
jsr CS.CHARIN
>LDA.G bCmdBufexec
bpl .1
>PUSHW ZPCMDBuf
lda #CMD.VarName
clc
adc pData
@ -219,17 +216,17 @@ CS.RUN.READ >LDA.G hCmdBuf Get the buffer
*--------------------------------------
CS.RUN.BATCH jsr CSH.Run
bcs .9
>LDA.G bCmdBufexec
bpl .8 Empty line....nothing to do....
jsr Cmd.Parse
lda (ZPCMDBuf)
beq .8
jsr Cmd.Exec
.8 ldy #S.PS.RC
sta (pPs),y
clc
@ -240,43 +237,43 @@ CS.RUN.BATCH jsr CSH.Run
lda #0
sec
rts
.7 pha
ldy #CSH.BufPtr+1
>PUSHB (pData),y
dey
>PUSHB (pData),y
>LDYA L.MSG.CSHERR
>SYSCALL PrintF.YA
jsr CSH.RestorePtr
.90 jsr CSH.GetChar
bcs .92
>SYSCALL PutChar.A
.91 jsr CSH.GetNextChar
bcs .92
cmp #13
beq .92
>SYSCALL PutChar.A
bra .91
.92 pla
bra .99
.98 lda #0
.99 ldy #S.PS.RC
sta (pPs),y
pha
ldy #bExitOnEOF
lda (pData),y
asl CS if bExitOnEOF
pla
rts
*--------------------------------------
@ -301,12 +298,12 @@ CS.DOEVENT lda (pEvent)
rts
*--------------------------------------
CS.CHARIN tax Save Char
>LDA.G CSH.hBuf Batch mode ?
>LDA.G CSH.hBuf Batch mode ?
beq .10
* Batch Mode
* Batch Mode
cpx #3 test Ctrl-c
bne .12
>LDA.G bExitOnEOF
>STA.G bExit
clc
@ -314,26 +311,26 @@ CS.CHARIN tax Save Char
.12 cpx #19 test Ctrl-s
bne .8
lda #$80
>STA.G bPause
clc
rts
* interactive mode
* interactive mode
.10 >LDA.G hCmdBuf
>SYSCALL GetMemPtr.A
>STYA ZPCMDBuf
>LDA.G bEscMode
beq .13
cpx #'['
beq .8
lda #0
sta (pData),y Y=bEscMode
txa
ldx EscChars
@ -342,10 +339,10 @@ CS.CHARIN tax Save Char
dex
bne .17
bra .8
.18 lda EscAscii,x
.18 lda EscAscii,x
tax
.13 cpx #$20
bcs .1
jsr CS.CHARIN.CTRL
@ -358,12 +355,12 @@ CS.CHARIN tax Save Char
rts
.2 >LDA.G CmdBuflen
cmp #CmdLine.MAX
beq .8
pha
inc
sta (pData),y
txa
@ -372,10 +369,10 @@ CS.CHARIN tax Save Char
>LDA.G bSecureRead
bne .8
txa
>SYSCALL PutChar.A
.8 clc
rts
*--------------------------------------
@ -385,12 +382,12 @@ CS.CHARIN.CTRL cpx #13 CR
>SYSCALL PutChar.A
lda #10
>SYSCALL PutChar.A
lda #$ff
>STA.G bCmdBufexec
clc
rts
.10 cpx #$1B esc
bne .11
@ -405,33 +402,33 @@ CS.CHARIN.CTRL cpx #13 CR
jsr CmdLine.CLR
clc
rts
.1 cpx #8 BS (left arrow)
bne .2
jsr CmdLine.DEL
clc
rts
.2 cpx #10 LF (down arrow)
bne .3
jsr HIS.GetNext
clc
rts
.3 cpx #11 VT (up arrow)
bne .4
jsr HIS.GetPrev
clc
rts
.4 cpx #21 NAK (right arrow)
bne .8
clc
rts
.8 clc
rts
*--------------------------------------
@ -479,30 +476,30 @@ PrintPrompt >LDYA L.ENV.PS1
CmdLine.CLR ldy #0
.1 lda (ZPCMDBuf),y
beq .9
beq .9
lda #8
sta (pData),y
iny
bne .1
jsr CmdLine.SET
lda #0
sta (ZPCMDBuf)
.9 rts
*--------------------------------------
CmdLine.DEL >LDA.G CmdBuflen
beq .9
dec
sta (pData),y
tay
lda #0
sta (pData),y
lda #8
>SYSCALL PutChar.A
.9 rts
@ -557,7 +554,6 @@ FMT.TIME >CSTR "%H:%M:%S (%I:%M:%S%p)"
*--------------------------------------
EscChars >PSTR "DBAC"
EscAscii .HS 04080A0B15
CMD .BS 256
TIME .BS S.TIME
STAT .BS S.STAT
bStartProc .BS 1

View File

@ -37,7 +37,7 @@ A2osX.PrtDrv.Go ldy #S.DEV.ROM.JMP
iny
lda (pDev),y
sta .8+2
.8 jsr $ffff
A2osX.PrtDrv.Go.Cmd
.BS 1
@ -68,18 +68,18 @@ A2osX.PrtDrv.GetDev
sta K.SP.PARAMS+1
rts
A2osX.PrtDrv.Cnt
.HS 03030301030101010404
.HS 03030301030101010404
*--------------------------------------
DevMgr.NUL.Code .DA .1 STATUS
.DA A2osX.BADCALL READBLOCK
.DA A2osX.BADCALL WRITEBLOCK
.DA A2osX.BADCALL FORMAT
.DA A2osX.BADCALL CONTROL
.DA A2osX.BADCALL INIT
.DA A2osX.BADCALL OPEN
.DA A2osX.BADCALL CLOSE
.DA A2osX.BADCALL READ
.DA .8 WRITE
DevMgr.NUL.Code .DA .1 STATUS
.DA A2osX.BADCALL READBLOCK
.DA A2osX.BADCALL WRITEBLOCK
.DA A2osX.BADCALL FORMAT
.DA A2osX.BADCALL CONTROL
.DA A2osX.BADCALL INIT
.DA A2osX.BADCALL OPEN
.DA A2osX.BADCALL CLOSE
.DA A2osX.BADCALL READ
.DA .8 WRITE
.8 clc
rts
*--------------------------------------
@ -94,14 +94,14 @@ DevMgr.NUL.Code .DA .1 STATUS
.DA #0
.DA $0900
*--------------------------------------
DevMgr.SYS.Code .DA .1 STATUS
.DA A2osX.BADCALL READBLOCK
.DA A2osX.BADCALL WRITEBLOCK
.DA A2osX.BADCALL FORMAT
DevMgr.SYS.Code .DA .1 STATUS
.DA A2osX.BADCALL READBLOCK
.DA A2osX.BADCALL WRITEBLOCK
.DA A2osX.BADCALL FORMAT
.DA DevMgr.SYS.Control
.DA A2osX.BADCALL INIT
.DA A2osX.BADCALL INIT
.DA DevMgr.SYS.Open
.DA A2osX.BADCALL CLOSE
.DA A2osX.BADCALL CLOSE
.DA DevMgr.SYS.Read
.DA DevMgr.SYS.Write
*--------------------------------------
@ -118,25 +118,25 @@ DevMgr.SYS.Code .DA .1 STATUS
*--------------------------------------
DevMgr.SYS.Open stz DevMgr.SYS.CH
stz DevMgr.SYS.CV
ldx #0
ldy #0
.1 lda DevMgr.SYS.TITLE,y
beq .2
jsr DevMgr.SYS.SetCharAtYX
iny
bne .1
.2 lda #$20
jsr DevMgr.SYS.SetCharAtYX
iny
cpy #80
bne .2
jsr DevMgr.SYS.Home
lda #1
sta A2osX.SCRNDEVS+1 fall in Control
*--------------------------------------
@ -154,18 +154,18 @@ DevMgr.SYS.Control
DevMgr.SYS.Read lda A2osX.ASCREEN
cmp #2 is SYS active?
bne .9
lda OPENAPPLE
bmi .9 Open apple key, not for us...
lda KBD
bpl .9
sta KBDSTROBE
and #$7F
clc
rts
.9 lda #0 Error = no event
sec
rts
@ -181,21 +181,21 @@ DevMgr.SYS.Write
jsr DevMgr.SYS.SetCharAtYX
jsr DevMgr.SYS.FSOut
bra .8
.1 cmp #10
bne .2
jsr DevMgr.SYS.LF
bra .8
.2 cmp #13
bne .3
jsr DevMgr.SYS.CR
bra .8
.3 ora #$20
jsr DevMgr.SYS.SetCharAtYX
jsr DevMgr.SYS.FSOut
.8 ply
plx
clc
@ -205,10 +205,10 @@ DevMgr.SYS.FSOut
lda DevMgr.SYS.CH
cmp #79
bne .1
stz DevMgr.SYS.CH
bra DevMgr.SYS.LF
.1 inc DevMgr.SYS.CH
rts
*--------------------------------------
@ -219,7 +219,7 @@ DevMgr.SYS.CR jsr DevMgr.SYS.ClrEOL
DevMgr.SYS.LF ldx DevMgr.SYS.CV
cpx #23
beq DevMgr.SYS.Scroll
inc DevMgr.SYS.CV
inc DevMgr.SYS.CV
rts
*--------------------------------------
DevMgr.SYS.ClrEOL
@ -259,7 +259,7 @@ DevMgr.SYS.Scroll
sta CLRWRITEAUX
sta CLRREADAUX
plp
ldy #39
.3 lda (ZPDRV+2),y
sta (ZPDRV),y
@ -280,7 +280,7 @@ DevMgr.SYS.ClrLineAtX
lda #$A0
ldy #39
.1 sta SETWRITEAUX
sta (ZPDRV),y
sta CLRWRITEAUX
@ -293,15 +293,15 @@ DevMgr.SYS.ClrLineAtX
rts
*--------------------------------------
DevMgr.SYS.Home ldx #23
.1 jsr DevMgr.SYS.ClrLineAtX
dex
bne .1
stz DevMgr.SYS.CH
lda #1
sta DevMgr.SYS.CV
rts
*--------------------------------------
DevMgr.SYS.SetCharAtYX
@ -310,9 +310,9 @@ DevMgr.SYS.SetCharAtYX
cmp #$5F
bcs .1
and #$3F
.1 php
phy
pha
lda DevMgr.SYS.BASEL,x
@ -324,14 +324,14 @@ DevMgr.SYS.SetCharAtYX
tay
bcs .2
sta SETWRITEAUX
.2 pla
sta (ZPDRV),y
sta CLRWRITEAUX
ply
plp
rts
*--------------------------------------
DevMgr.SYS.CH .BS 1