Kernel 0.9.1 : Code reorganization & move to CSTR (SHELL)

This commit is contained in:
Rémy GIBERT 2017-09-08 16:49:23 +02:00
parent 4d2aab3e63
commit ea86f48bc7
14 changed files with 309 additions and 357 deletions

Binary file not shown.

Binary file not shown.

View File

@ -254,7 +254,7 @@ SYS.ExecProcessNewEnvYA .EQ $A0
SYS.ExecProcessYA .EQ $A2
SYS.CreateProcessNewEnvYA .EQ $A4
SYS.CreateProcessYA .EQ $A6
SYS.GetPSByIDA .EQ $A8
* .EQ $A8
* .EQ $AA
SYS.Sleep .EQ $AC
* .EQ $AE

View File

@ -115,17 +115,37 @@ AUTO 6
*--------------------------------------
* Global DATA Segment Access
*--------------------------------------
.MA GETG.A
.MA LDA.G
ldy #]1
lda (pData),y
.EM
*--------------------------------------
.MA SETG.A
.MA STA.G
ldy #]1
sta (pData),y
.EM
*--------------------------------------
.MA GETG.YA
.MA CMP.G
ldy #]1
cmp (pData),y
.EM
*--------------------------------------
.MA INCW.G
ldy #]1
lda (pData),y
inc
sta (pData),y
bne :1
iny
lda (pData),y
inc
sta (pData),y
:1 .EQ *
.EM
*--------------------------------------
.MA LDYA.G
ldy #]1
lda (pData),y
pha
@ -134,7 +154,7 @@ AUTO 6
ply
.EM
*--------------------------------------
.MA SETG.YA
.MA STYA.G
phy
ldy #]1+1
sta (pData),y

View File

@ -9,7 +9,7 @@ CMD.Init >LDYAI CmdLine.MAX+1
>SYSCALL GetMem.YA
bcs .9
txa
>SETG.A hCmdBuf
>STA.G hCmdBuf
.9 rts
*--------------------------------------
* ZPCMDBuf : Remove extra SPACE & comment
@ -68,19 +68,29 @@ Cmd.Parse.NextC lda (ZPPtr1)
Cmd.Exec stz bStartProc
>LDYA ZPCMDBuf
>SYSCALL PrintF.YA
jsr Cmd.Exec.ECHO.CR
>LDYA ZPCMDBuf
Cmd.ExecYA >SYSCALL ExpandStr.YA
>STYA ZPPtr1 Ptr to CMD
txa
>SETG.A CMD.hCmdLine
>STA.G CMD.hCmdLine
>LDYA ZPPtr1
>SYSCALL PrintF.YA
jsr Cmd.Exec.ECHO.CR
>DEBUG
ldy #$ff CMD Len
.1 iny
lda (ZPPtr1),y Get CMD char...
beq .2
cmp #" " we reached blank between CMD ARGS
cmp #' ' we reached blank between CMD ARGS
bne .1
.2 phy Y=CMD len
@ -97,7 +107,7 @@ Cmd.ExecYA >SYSCALL ExpandStr.YA
pha
cmp (ZPPtr2) Same Len ?
beq .5
beq .51
.4 inx
inx
@ -110,8 +120,9 @@ Cmd.ExecYA >SYSCALL ExpandStr.YA
inc ZPPtr2+1
bra .3
.5 tay
dey
.51 tay
.5 dey
lda (ZPPtr1),y
cmp #'a' To Uppercase
@ -128,9 +139,11 @@ Cmd.ExecYA >SYSCALL ExpandStr.YA
bne .5
ply get back Cmd Len
lda (ZPPtr1),y
beq .7 ARGS = ""
iny skip " "
.7 tya
clc
adc ZPPtr1
@ -150,7 +163,7 @@ Cmd.ExecYA >SYSCALL ExpandStr.YA
Cmd.Exec.Done php
pha
>GETG.A CMD.hCmdLine
>LDA.G CMD.hCmdLine
>SYSCALL FreeMem.A
pla
plp
@ -237,7 +250,7 @@ Cmd.Exec.EXT.BIN
>PUSHWI UsrBuf256
>SYSCALL StrCat
lda ARGS
lda (ZPPTR2)
beq .1
inc UsrBuf256 Add a space....
@ -245,7 +258,7 @@ Cmd.Exec.EXT.BIN
lda #' '
sta UsrBuf256,y
>PUSHW L.ARGS
>PUSHW ZPPTR2
>PUSHWI UsrBuf256
>SYSCALL StrCat
@ -261,7 +274,7 @@ Cmd.Exec.EXT.BIN
*--------------------------------------
* Internal Commands
*--------------------------------------
Cmd.Exec.CD lda ARGS
Cmd.Exec.CD lda (ZPPTR2)
bne Cmd.Exec.CD1
Cmd.Exec.PWD ldy #S.PS.hPREFIX
@ -273,7 +286,7 @@ Cmd.Exec.PWD ldy #S.PS.hPREFIX
rts
Cmd.Exec.CD1 stz UsrBuf256
lda ARGS+1
cmp #'/' Full Path?
beq .1
@ -284,7 +297,7 @@ Cmd.Exec.CD1 stz UsrBuf256
>PUSHWI UsrBuf256
>SYSCALL StrCpy
.1 >PUSHW L.ARGS Append ARG to buffer
.1 >PUSHW ZPPTR2 Append ARG to buffer
>PUSHWI UsrBuf256
>SYSCALL StrCat
@ -381,15 +394,15 @@ Cmd.Exec.ERRSYN lda #SYSMGR.ERRSYN
rts
*--------------------------------------
Cmd.Exec.STARTPROC
lda ARGS
lda (ZPPTR2)
beq Cmd.Exec.ERRSYN
sec
ror bStartProc
>LDYA L.ARGS
>LDYA ZPPTR2
jmp Cmd.ExecYA
*--------------------------------------
Cmd.Exec.SET lda ARGS
Cmd.Exec.SET lda (ZPPTR2)
bne Cmd.Exec.SETVAR
ldy #S.PS.hENV
@ -432,38 +445,41 @@ Cmd.Exec.SET lda ARGS
.8 clc
.9 rts
Cmd.Exec.SETVAR tax
lda ARGS,x
cmp #'=' ARGS ends with =, UnsetEnv
beq .2
Cmd.Exec.SETVAR ldy #0
lda (ZPPTR2),y
iny
cmp #'=' string is '=value' ?
beq .99 syntax error
.1 dex
.1 lda (ZPPTR2),y
iny
beq .3 no =, GetEnv
lda ARGS,x
cmp #'=' ARGS contains =, PutEnv
bne .1
cpx #1 string is '=value' ?
beq .99 syntax error
lda (ZPPTR2),y
beq .2 "VAR=" go UnsetEnv
>LDYA L.ARGS String is VAR=VALUE...
>LDYA ZPPTR2 String is VAR=VALUE...
>SYSCALL PutEnv.YA
rts
.2 dec ARGS String is "VAR=", Remove endig '='
>LDYA L.ARGS String is "VAR"...
.2 dey String is "VAR=", Remove endig '='
sta (ZPPTR2),y
>LDYA ZPPTR2 String is "VAR"...
>SYSCALL UnsetEnv.YA
rts
* Print requested VAR
.3 >LDYA L.ARGS
.3 >LDYA ZPPTR2
>SYSCALL GetEnv.YA
bcs .8
>PUSHYA push value
>PUSHW L.ARGS push name
>PUSHW ZPPTR2 push name
>LDYA L.MSG.PRINTENV
>SYSCALL PrintF.YA
@ -495,10 +511,10 @@ Cmd.Exec.TIME clc
bcs Cmd.Exec.ECHO.RTS
bra Cmd.Exec.ECHO.CR
*--------------------------------------
Cmd.Exec.ECHO lda ARGS
Cmd.Exec.ECHO lda (ZPPtr2)
beq Cmd.Exec.ECHO.CR
>PUSHW L.ARGS
>PUSHW ZPPtr2
>LDYA L.MSG.PSTRCR
>SYSCALL PrintF.YA
rts
@ -514,11 +530,11 @@ Cmd.Exec.ECHO.CR
Cmd.Exec.ECHO.RTS
rts
*--------------------------------------
Cmd.Exec.READ lda ARGS
Cmd.Exec.READ lda (ZPPtr2)
beq .9
lda #0
>SETG.A bSecureRead
>STA.G bSecureRead
lda pData
clc
@ -528,63 +544,56 @@ Cmd.Exec.READ lda ARGS
adc #0
sta ZPPTR1+1
ldx #0
ldy #0
.1 cpx ARGS
.1 lda (ZPPtr2),y
beq .8
inx
lda ARGS,x
iny
cmp #' '
beq .1
cmp #'-'
bne .7
cpx ARGS
lda (ZPPtr2),y
beq .9
inx
lda ARGS,x
iny
cmp #'S'
bne .2
lda #$80
>SETG.A bSecureRead
>STA.G bSecureRead
bra .1
.2 cmp #'P'
bne .9
cpx ARGS
lda (ZPPtr2),y
beq .9
inx
lda ARGS,x
iny
cmp #' '
bne .9
cpx ARGS
lda (ZPPtr2),y
beq .9
inx
lda ARGS,x
iny
cmp #'"'
bne .9
.3 cpx ARGS
.3 lda (ZPPtr2),y
beq .9
inx
lda ARGS,x
iny
cmp #'"'
beq .1
phx
phy
>SYSCALL PutChar.A
plx
ply
bcs .99
bra .3
.9 jmp Cmd.Exec.ERRSYN
.70 inx
lda ARGS,x
.70 lda (ZPPtr2),y
cmp #' '
beq .1
@ -594,9 +603,9 @@ Cmd.Exec.READ lda ARGS
inc
sta (ZPPTR1)
tay
lda ARGS,x
lda (ZPPtr2),y
sta (ZPPTR1),y
cpx ARGS
bne .70
.8 lda (ZPPTR1) No var name ? SYNERR
@ -605,7 +614,7 @@ Cmd.Exec.READ lda ARGS
clc
.99 rts
*--------------------------------------
Cmd.Exec.SLEEP lda ARGS
Cmd.Exec.SLEEP lda (ZPPtr2)
beq .9
lda #Sleep
@ -615,7 +624,7 @@ Cmd.Exec.SLEEP lda ARGS
lda /Sleep
adc pData+1
>PUSHYA
>PUSHW L.ARGS
>PUSHW ZPPtr2
>SYSCALL AToI.YA
bcs .9
@ -624,12 +633,12 @@ Cmd.Exec.SLEEP lda ARGS
.9 jmp Cmd.Exec.ERRSYN
*--------------------------------------
Cmd.Exec.PAUSE lda #$FF
>SETG.A bPause
>STA.G bPause
clc
rts
*--------------------------------------
Cmd.Exec.EXIT lda #$FF
>SETG.A bExit
>STA.G bExit
clc
rts
*--------------------------------------

View File

@ -5,8 +5,6 @@ INC 1
AUTO 6
.LIST OFF
*--------------------------------------
*--------------------------------------
CSH.TYPE.CHAR .EQ 1
CSH.TYPE.INT .EQ 2
CSH.TYPE.LONG .EQ 3
@ -21,46 +19,40 @@ CSH.Init >PUSHWI 0 Aux type
>PUSHYA
>SYSCALL LoadFile
bcs .9
>SETG.YA CSH.BufLen
>STYA.G CSH.BufLen
txa
>SETG.A CSH.hBuf
>STA.G CSH.hBuf
lda #$FF
>SETG.A bExitOnEOF
>STA.G bExitOnEOF
>LDYAI 256
>SYSCALL GetMem0.YA
bcs .9
txa
ldy #CSH.hSymbols
sta (pData),y
>STA.G CSH.hSymbols
lda #0
ldy #CSH.SymbolsPtr
sta (pData),y
>STA.G CSH.SymbolsPtr
>LDYAI 256
>SYSCALL GetMem.YA
bcs .9
txa
ldy #CSH.hData
sta (pData),y
>STA.G CSH.hData
lda #0
ldy #CSH.DataPtr
sta (pData),y
>STA.G CSH.DataPtr
>LDYAI 256
>SYSCALL GetMem.YA
bcs .9
txa
ldy #CSH.hStack
sta (pData),y
>STA.G CSH.hStack
lda #0
ldy #CSH.StackPtr
sta (pData),y
>STA.G CSH.StackPtr
* clc
.9 rts
@ -70,7 +62,7 @@ CSH.Run jsr CSH.GetBuf
jsr CSH.GetPtrs
lda #0
>SETG.A CmdBuflen Reset Cmdline
>STA.G CmdBuflen Reset Cmdline
jsr CSH.GetCharNB
bcs .9
@ -142,7 +134,7 @@ CSH.Run jsr CSH.GetBuf
jsr CSH.RestorePtr Restore ptr to get full cmd line to execute
>GETG.A hCmdBuf Get the buffer
>LDA.G hCmdBuf Get the buffer
>SYSCALL GetMemPtr.A
>STYA ZPCMDBuf
@ -166,12 +158,11 @@ CSH.Run jsr CSH.GetBuf
.8 lda #0
sta (ZPCMDBuf),y
tya
>SETG.A CmdBuflen
>STA.G CmdBuflen
lda #$ff
>SETG.A bCmdBufexec
>STA.G bCmdBufexec
ldy #bEcho
lda (pData),y
>LDA.G bEcho
beq .80
>PUSHW ZPCMDBuf
@ -181,35 +172,29 @@ CSH.Run jsr CSH.GetBuf
.80 clc
rts
*--------------------------------------
CSH.Quit ldy #CSH.hBuf
lda (pData),y
CSH.Quit >LDA.G CSH.hBuf
beq .1
>SYSCALL FreeMem.A
.1 ldy #CSH.hStack
lda (pData),y
.1 >LDA.G CSH.hStack
beq .2
>SYSCALL FreeMem.A
.2 ldy #CSH.hData
lda (pData),y
.2 >LDA.G CSH.hData
beq .3
>SYSCALL FreeMem.A
.3 ldy #CSH.hSymbols
lda (pData),y
.3 >LDA.G CSH.hSymbols
beq .8
>SYSCALL FreeMem.A
.8 rts
*--------------------------------------
CSH.GetBuf ldy #CSH.hBuf
lda (pData),y
CSH.GetBuf >LDA.G CSH.hBuf
>SYSCALL GetMemPtr.A
>STYA ZPCSHBufBase
ldy #CSH.BufLen
lda (pData),y
>LDA.G CSH.BufLen
clc
adc ZPCSHBufBase
sta CSH.GetChar.LO+1
@ -219,8 +204,7 @@ CSH.GetBuf ldy #CSH.hBuf
adc ZPCSHBufBase+1
sta CSH.GetChar.HI+1
CSH.SetBufPtr ldy #CSH.BufPtr
lda (pData),y
CSH.SetBufPtr >LDA.G CSH.BufPtr
clc
adc ZPCSHBufBase
sta ZPCSHBufPtr
@ -231,25 +215,21 @@ CSH.SetBufPtr ldy #CSH.BufPtr
sta ZPCSHBufPtr+1
rts
*--------------------------------------
CSH.GetPtrs ldy #CSH.hSymbols
lda (pData),y
CSH.GetPtrs >LDA.G CSH.hSymbols
>SYSCALL GetMemPtr.A
>STYA ZPCSHSymbols
ldy #CSH.hData
lda (pData),y
>LDA.G CSH.hData
>SYSCALL GetMemPtr.A
>STYA ZPCSHData
ldy #CSH.hStack
lda (pData),y
>LDA.G CSH.hStack
>SYSCALL GetMemPtr.A
>STYA ZPCSHStack
rts
*--------------------------------------
CSH.SavePtr phy
ldy #CSH.BufPtr
lda (pData),y
>LDA.G CSH.BufPtr
sta CSH.BufPtrSave
iny
@ -259,9 +239,8 @@ CSH.SavePtr phy
rts
*--------------------------------------
CSH.RestorePtr phy
ldy #CSH.BufPtr
lda CSH.BufPtrSave
sta (pData),y
>STA.G CSH.BufPtr
clc
adc ZPCSHBufBase
sta ZPCSHBufPtr
@ -399,11 +378,9 @@ CSH.IF.END jsr CSH.GetNextChar just skip ending '}'
rts
*--------------------------------------
CSH.WHILE.END jsr CSH.Pop
ldy #CSH.BufPtr
sta (pData),y
>STA.G CSH.BufPtr
jsr CSH.Pop
ldy #CSH.BufPtr+1
sta (pData),y
>STA.G CSH.BufPtr+1
clc
rts
*--------------------------------------
@ -468,11 +445,6 @@ CSH.TYPE sta CSH.ACCT
.9 lda #CSH.E.SYNTAX
sec
.99 rts
*--------------------------------------
lda #CSH.E.SYNTAX
sec
rts
*--------------------------------------
CSH.ExpEval jsr CSH.ZeroACC
@ -528,25 +500,27 @@ CSH.GetName ldy #0
sec
rts
*--------------------------------------
CSH.GetNumInACC ldy #0
CSH.GetNumInACC
.1 iny
cpy #10
beq .9
* ldy #0
*
*.1 iny
* cpy #10
* beq .9
sta ARGS,y
jsr CSH.GetNextChar
bcs .8
jsr CSH.IsDigit10
bcc .1
* sta ARGS,y
* jsr CSH.GetNextChar
* bcs .8
* jsr CSH.IsDigit10
* bcc .1
.8 sty ARGS
*.8 sty ARGS
>PUSHW L.CSH.ACC
>PUSHW L.ARGS
>SYSCALL AToL
bcs .9
rts
* >PUSHW L.CSH.ACC
* >PUSHW L.ARGS
* >SYSCALL AToL
* bcs .9
* rts
.9 lda #CSH.E.SYNTAX
sec
@ -563,8 +537,7 @@ CSH.ZeroACC stz CSH.ACC
CSH.AddVar jsr CSH.FindVar
bcc .97
ldy #CSH.SymbolsPtr
lda (pData),y
>LDA.G CSH.SymbolsPtr
sec
adc CSH.Name
@ -573,8 +546,7 @@ CSH.AddVar jsr CSH.FindVar
adc #2 TYPE + OFS
bcs .99
ldy #CSH.DataPtr
lda (pData),y
>LDA.G CSH.DataPtr
pha
ldx CSH.ACCT
@ -584,8 +556,7 @@ CSH.AddVar jsr CSH.FindVar
ldx #$ff
ldy #CSH.SymbolsPtr
lda (pData),y
>LDA.G CSH.SymbolsPtr
tay
.10 inx
@ -605,8 +576,7 @@ CSH.AddVar jsr CSH.FindVar
iny
tya
ldy #CSH.SymbolsPtr
sta (pData),y
>STA.G CSH.SymbolsPtr
ply Get Back Data OFS again
@ -625,8 +595,7 @@ CSH.AddVar jsr CSH.FindVar
bne .1
tya
ldy #CSH.DataPtr
sta (pData),y
>STA.G CSH.DataPtr
clc
rts
@ -704,8 +673,7 @@ CSH.FindVar >LDYA ZPCSHSymbols
* Stack
*--------------------------------------
CSH.Push pha
ldy #CSH.StackPtr
lda (pData),y
>LDA.G CSH.StackPtr
tay
pla
@ -713,7 +681,7 @@ CSH.Push pha
iny
beq .9
tya
ldy #CSH.StackPtr
>STA.G CSH.StackPtr
sta (pData),y
clc
rts
@ -722,8 +690,7 @@ CSH.Push pha
sec
rts
*--------------------------------------
CSH.Pop ldy #CSH.StackPtr
lda (pData),y
CSH.Pop >LDA.G CSH.StackPtr
beq .9
dec
tay
@ -737,8 +704,7 @@ CSH.Pop ldy #CSH.StackPtr
rts
*--------------------------------------
CSH.CheckStack pha
ldy #CSH.StackPtr
lda (pData),y
>LDA.G CSH.StackPtr
beq .9
dec
tay
@ -747,8 +713,7 @@ CSH.CheckStack pha
bne .9
tya
ldy #CSH.StackPtr
sta (pData),y
>STA.G CSH.StackPtr
clc
rts
@ -784,18 +749,8 @@ CSH.CheckCharNB cmp #32 SPACE
.9 rts
*--------------------------------------
CSH.GetNextChar phy
ldy #CSH.BufPtr
lda (pData),y
inc
sta (pData),y
bne .1
iny
lda (pData),y
inc
sta (pData),y
.1 ply
>INCW.G CSH.BufPtr
ply
inc ZPCSHBufPtr
bne CSH.GetChar

View File

@ -10,28 +10,23 @@ HIS.Init >LDYAI 256 Get a buffer for History
bcs .9
txa
ldy #HIS.hBuf
sta (pData),y
>STA.G HIS.hBuf
lda #0
ldy #HIS.BufIndex
sta (pData),y
ldy #HIS.BufEnd
sta (pData),y
>STA.G HIS.BufIndex
>STA.G HIS.BufEnd
.9 rts
*--------------------------------------
HIS.Add ldy #HIS.hBuf
lda (pData),y
HIS.Add >LDA.G HIS.hBuf
beq .9
>SYSCALL GetMemPtr.A
>STYA ZPPTR1
.10 ldy #HIS.BufEnd
lda (pData),y
.10 >LDA.G HIS.BufEnd
.11 sec add len+1
adc (pData) CmdBuffer length
adc CmdBuflen CmdBuffer length
bcc .2 enough room
lda (ZPPTR1) get len of oldest string
@ -51,8 +46,7 @@ HIS.Add ldy #HIS.hBuf
tya
ldy #HIS.BufEnd mark new end of history
sta (pData),y
>STA.G HIS.BufEnd mark new end of history
bra .11 retry....
.2 tax keep new HIS.BufEnd
@ -61,17 +55,13 @@ HIS.Add ldy #HIS.hBuf
lda #0
sta (ZPPTR1),y set ending 0
ldy #HIS.BufEnd save old END
lda (pData),y
>LDA.G HIS.BufEnd save old END
pha
txa get back new END
ldy #HIS.BufIndex set it as new IDX
sta (pData),y
ldy #HIS.BufEnd
sta (pData),y set new HIS.BufEnd
>STA.G HIS.BufIndex set it as new IDX
>STA.G HIS.BufEnd set new HIS.BufEnd
pla get back old END
clc
@ -80,26 +70,28 @@ HIS.Add ldy #HIS.hBuf
bcc .3
inc ZPPTR1+1
.3 lda (pData)
tay
.3 ldy #0
.4 lda (pData),y
.4 lda (ZPCMDBuf),y
beq .5
iny
sta (ZPPTR1),y
dey
bpl .4
iny
bra .4
.5 tya
sta (ZPPTR1)
.9 rts
*--------------------------------------
HIS.GetPrev ldy #HIS.hBuf
lda (pData),y
HIS.GetPrev >LDA.G HIS.hBuf
beq HISTORY.RTS
tax
ldy #HIS.BufEnd
lda (pData),y
>LDA.G HIS.BufEnd
beq HISTORY.RTS empty history,nothing to do
ldy #HIS.BufIndex
lda (pData),y
>LDA.G HIS.BufIndex
beq HISTORY.RTS already oldest,nothing to do
txa
@ -120,22 +112,18 @@ HIS.GetPrev ldy #HIS.hBuf
bne .1 reached current index
.2 txa
ldy #HIS.BufIndex set new index
sta (pData),y
>STA.G HIS.BufIndex set new index
bra HIS.SetBuf
History.RTS rts
*--------------------------------------
HIS.GetNext ldy #HIS.hBuf
lda (pData),y
HIS.GetNext >LDA.G HIS.hBuf
beq HISTORY.RTS
tax
ldy #HIS.BufEnd
lda (pData),y
>LDA.G HIS.BufEnd
beq HISTORY.RTS empty history,nothing to do
ldy #HIS.BufIndex
cmp (pData),y
>CMP.G HIS.BufIndex
beq HISTORY.RTS already oldest,nothing to do
txa
@ -143,24 +131,19 @@ HIS.GetNext ldy #HIS.hBuf
>SYSCALL GetMemPtr.A
>STYA ZPPTR1
ldy #HIS.BufIndex
lda (pData),y
phy
>LDA.G HIS.BufIndex
tay
sec
adc (ZPPTR1),y add length+1 of current line in history
ply
sta (pData),y
>STA.G HIS.BufIndex
ldy #HIS.BufEnd
cmp (pData),y
>CMP.G HIS.BufEnd
bne HIS.SetBuf
jmp CmdLine.CLR end of history, just blank buffer
*--------------------------------------
HIS.SetBuf jsr CmdLine.CLR
ldy #HIS.BufIndex
lda (pData),y
>LDA.G HIS.BufIndex
tay keep length of string
clc
@ -170,13 +153,12 @@ HIS.SetBuf jsr CmdLine.CLR
inc ZPPTR1+1
.1 lda (ZPPTR1),y
sta (pData),y
sta (ZPCMDBuf),y
dey
bpl .1
jmp CmdLine.SET
*--------------------------------------
HIS.Quit ldy #HIS.hBuf
lda (pData),y
HIS.Quit >LDA.G HIS.hBuf
beq .9
>SYSCALL FreeMem.A
.9 rts

View File

@ -67,7 +67,6 @@ L.ENV.PATH .DA ENV.PATH
L.ENV.PWD .DA ENV.PWD
L.ENV.PS1 .DA ENV.PS1
L.CMD .DA CMD
L.ARGS .DA ARGS
L.TIME .DA TIME
L.STAT .DA STAT
L.FMT.DATE .DA FMT.DATE
@ -124,7 +123,7 @@ CS.INIT jsr SetPWD
.9 rts
*--------------------------------------
CS.RUN >GETG.A bReadMode READ Command ?
CS.RUN >LDA.G bReadMode READ Command ?
bne CS.RUN.READ
ldy #S.PS.RC
@ -134,32 +133,30 @@ CS.RUN >GETG.A bReadMode READ Command ?
jsr IO.PrintErrMsg
bcs CS.RUN.EXIT.RTS
.11 >GETG.A bPause
.11 >LDA.G bPause
bpl .13
>SYSCALL GetChar
bcs .8
.13 >DEBUG
jsr CheckSleep
.13 jsr CheckSleep
bne .8
>GETG.A CSH.hBuf batch mode ?
>LDA.G CSH.hBuf batch mode ?
beq .10
jmp CS.RUN.BATCH
* Interactive Mode
.10 >GETG.A hCmdBuf Get the buffer
.10 >LDA.G hCmdBuf Get the buffer
>SYSCALL GetMemPtr.A
>STYA ZPCMDBuf
lda #0 reset it
sta (ZPCMDBuf)
>SETG.A bSecureRead Clear password mode
>STA.G bSecureRead Clear password mode
.12 jsr PrintPrompt
bcs CS.RUN.EXIT.RTS
@ -170,12 +167,12 @@ CS.RUN >GETG.A bReadMode READ Command ?
jsr CS.CHARIN
>GETG.A bCmdBufexec Something to execute ?
>LDA.G bCmdBufexec Something to execute ?
bpl .1
jsr Cmd.Parse
>GETG.A CmdBuflen
>LDA.G CmdBuflen
beq .12 Empty line
jsr HIS.Add
@ -185,7 +182,7 @@ CS.RUN >GETG.A bReadMode READ Command ?
ldy #S.PS.RC
sta (pPs),y
>GETG.A bExit
>LDA.G bExit
bne CS.RUN.EXIT
.8 clc
@ -195,7 +192,7 @@ CS.RUN.EXIT lda #0
CS.RUN.EXIT.ERR sec
CS.RUN.EXIT.RTS rts
*--------------------------------------
CS.RUN.READ >GETG.A hCmdBuf Get the buffer
CS.RUN.READ >LDA.G hCmdBuf Get the buffer
>SYSCALL GetMemPtr.A
>STYA ZPCMDBuf
@ -208,7 +205,7 @@ CS.RUN.READ >GETG.A hCmdBuf Get the buffer
jsr CS.CHARIN
>GETG.A bCmdBufexec
>LDA.G bCmdBufexec
bpl .1
>PUSHW ZPCMDBuf
@ -223,16 +220,15 @@ CS.RUN.READ >GETG.A hCmdBuf Get the buffer
>SYSCALL SetEnv
rts
*--------------------------------------
CS.RUN.BATCH >DEBUG
jsr CSH.Run
CS.RUN.BATCH jsr CSH.Run
bcs .9
>GETG.A bCmdBufexec
>LDA.G bCmdBufexec
bpl .8 Empty line....nothing to do....
jsr Cmd.Parse
>GETG.A CmdBuflen
lda (ZPCMDBuf)
beq .8
jsr Cmd.Exec
@ -308,14 +304,14 @@ CS.DOEVENT lda (pEvent)
rts
*--------------------------------------
CS.CHARIN tax Save Char
>GETG.A CSH.hBuf Batch mode ?
>LDA.G CSH.hBuf Batch mode ?
beq .10
* Batch Mode
cpx #3 test Ctrl-c
bne .12
>GETG.A bExitOnEOF
>SETG.A bExit
>LDA.G bExitOnEOF
>STA.G bExit
clc
rts
@ -323,16 +319,16 @@ CS.CHARIN tax Save Char
bne .8
lda #$80
>SETG.A bPause
>STA.G bPause
clc
rts
* interactive mode
.10 >GETG.A hCmdBuf
.10 >LDA.G hCmdBuf
>SYSCALL GetMemPtr.A
>STYA ZPCMDBuf
>GETG.A bEscMode
>LDA.G bEscMode
beq .13
cpx #'['
@ -364,7 +360,7 @@ CS.CHARIN tax Save Char
clc
rts
.2 >GETG.A CmdBuflen
.2 >LDA.G CmdBuflen
cmp #CmdLine.MAX
beq .8
@ -377,7 +373,7 @@ CS.CHARIN tax Save Char
ply
sta (ZPCMDBuf),y
>GETG.A bSecureRead
>LDA.G bSecureRead
bne .8
txa
@ -394,7 +390,7 @@ CS.CHARIN.CTRL cpx #13 CR
>SYSCALL PutChar.A
lda #$ff
>SETG.A bCmdBufexec
>STA.G bCmdBufexec
clc
rts
@ -402,7 +398,7 @@ CS.CHARIN.CTRL cpx #13 CR
bne .11
lda #$ff
>SETG.A bEscMode
>STA.G bEscMode
clc
rts
@ -501,7 +497,7 @@ CmdLine.CLR ldy #0
.9 rts
*--------------------------------------
CmdLine.DEL >GETG.A CmdBuflen
CmdLine.DEL >LDA.G CmdBuflen
beq .9
dec
sta (pData),y
@ -567,7 +563,6 @@ FMT.TIME >CSTR "%H:%M:%S (%I:%M:%S%p)"
EscChars >PSTR "DBAC"
EscAscii .HS 04080A0B15
CMD .BS 256
ARGS .BS 256
TIME .BS S.TIME
STAT .BS S.STAT
bStartProc .BS 1

View File

@ -214,7 +214,7 @@ BIN.Load.YA.1 >PUSHWI K.S.STAT
jsr BIN.RelocateEXE
>LDYA BIN.CmdLine get back bin path
jsr K.NewCStr.YA make a copy of this string
jsr K.NewStr.YA make a copy of this string
bcs .98
lda BIN.hMem Keep X=hMem

View File

@ -42,15 +42,15 @@ CORE.Run jsr CORE.TskMgrRun
cmp #2 is SYS active?
bne .6
ldx SYS.CPULOADI
lda SYS.CPULOADC,x
ldx CORE.CPULOADI
lda CORE.CPULOADC,x
sta SYS.BASL0+38
dex
bpl .5
ldx #3
.5 stx SYS.CPULOADI
.5 stx CORE.CPULOADI
.6 bit OPENAPPLE
bpl CORE.Run
@ -102,8 +102,8 @@ CORE.ScreenSelect
.8 rts
*--------------------------------------
SYS.CPULOADI .BS 1
SYS.CPULOADC .AS '\|/-'
CORE.CPULOADI .BS 1
CORE.CPULOADC .AS -"/-\|"
*--------------------------------------
CORE.TskMgrRun >LDYAI TskMgr.Table+S.PS skip PS 0
>STYA pPs
@ -126,7 +126,7 @@ CORE.TskMgrRun >LDYAI TskMgr.Table+S.PS skip PS 0
ldy #S.PS.CPID
lda (pPs),y
jsr K.GetPSByID.A
jsr CORE.GetPSByID.A
bcc .7 yes, running....
lda (pPs) get S.PS.F
@ -159,7 +159,7 @@ CORE.TskMgrRun >LDYAI TskMgr.Table+S.PS skip PS 0
pha save RC
ldy #S.PS.PPID Notify Parent Process for exit code...
lda (pPs),y
jsr K.GetPSByID.A will set ZPPtr1 if success
jsr CORE.GetPSByID.A will set ZPPtr1 if success
bcs .5 parent is dead.....skipping...
lda (ZPPtr1) Parent PS is HOLD?
@ -181,7 +181,7 @@ CORE.TskMgrRun >LDYAI TskMgr.Table+S.PS skip PS 0
ldy #S.PS.PID
lda (pPs),y
jsr PS.Free.A
jsr CORE.PSFree.A
.7 lda pPs
clc
@ -194,6 +194,43 @@ CORE.TskMgrRun >LDYAI TskMgr.Table+S.PS skip PS 0
.8 clc
rts
*--------------------------------------
CORE.GetPSByID.A
pha
>LDYAI TskMgr.Table
>STYA ZPPtr1
pla
beq .8
sta .20+1
ldx #0
.1 inx
lda ZPPtr1
clc
adc #S.PS
sta ZPPtr1
bcc .2
inc ZPPtr1+1
.2 lda (ZPPtr1)
bpl .3
ldy #S.PS.PID
lda (ZPPtr1),y
.20 cmp #$ff Self Modified
beq .8
.3 cpx TskMgr.Count
bne .1
.9 lda #TSKMGR.ERRNSP
sec
rts
.8 >LDYA ZPPtr1
clc
rts
*--------------------------------------
CORE.PSSelect0 >LDYAI TskMgr.Table Select PS0
>STYA pPs
@ -207,22 +244,19 @@ CORE.PSSelect ldy #S.PS.hCS
jsr K.GetMemPtr.A
>STYA pCode
iny
* ldy #S.PS.hDS
ldy #S.PS.hDS
lda (pPs),y
beq .1
jsr K.GetMemPtr.A
>STYA pData
.1 iny
* ldy #S.PS.hSS
.1 ldy #S.PS.hSS
lda (pPs),y
jsr K.GetMemPtr.A
>STYA pStack
iny
* ldy #S.PS.SP
ldy #S.PS.SP
lda pStack
clc
adc (pPs),y
@ -243,6 +277,42 @@ CORE.PSLeave ldy #S.PS.hSS
rts
*--------------------------------------
* PS.Free.A
* In : A = PID to free
*--------------------------------------
CORE.PSFree.A jsr CORE.GetPSByID.A PS in ZPPtr1
ldy #S.PS.hARGS
jsr .2
lda (ZPPtr1) get S.PS.F
and #S.PS.F.ENV do we have to discard duplicated env & prefix ?
beq .1
ldy #S.PS.hENV
jsr .2
ldy #S.PS.hPREFIX
jsr .2
.1 ldy #S.PS.hSS
jsr .2
ldy #S.PS.hDS
jsr .2
ldy #S.PS.hCS
jsr .2
lda #0
sta (ZPPtr1) Mark TSKSLOT as free
clc
.9 rts
.2 lda (ZPPtr1),y
beq .9
jmp K.FreeMem.A
*--------------------------------------
* CORE.GetEvents :
* IN :
* OUT :

View File

@ -108,8 +108,11 @@ K.ExpandStr.YA stz K.ExpandStr.hPStr Reset Intermediate string...
jsr K.FreeMem.A yes, discard....
.81 >LDYAI K.Buf256
jsr K.NewCStr.YA
.81 ldx K.ExpandStr.Len
stz K.Buf256,x
>LDYAI K.Buf256
jsr K.NewStr.YA
bcs .9
stx K.ExpandStr.hPStr save this as temp string, in case of recurse
ldx K.ExpandStr.bFound Did we expand something ?
@ -117,7 +120,7 @@ K.ExpandStr.YA stz K.ExpandStr.hPStr Reset Intermediate string...
jmp .1 Yes, start over with hPStr
.82 ldx K.ExpandStr.hPStr
* or exit with Y,A from K.NewPStrYA
* or exit with Y,A from K.NewStrYA
.9 rts
*--------------------------------------

View File

@ -104,15 +104,11 @@ K.FileSearch.I >PULLW ZPPtr4 ZPPtr1 trashed by ExpandStr.YA
*\--------------------------------------
K.GetFullPath.YA
>STYA ZPPtr1
stz K.Buf256
ldx #0
lda (ZPPtr1)
beq .8
ldx #0
lda (ZPPtr1)
cmp #'/' full path starting with '/'?
beq .2 yes, do not append to current prefix
@ -141,7 +137,7 @@ K.GetFullPath.YA
.8 stz K.Buf256,x
>LDYAI K.Buf256
jsr K.NewPStr.YA
jsr K.NewStr.YA
rts
*/--------------------------------------
* # LoadFile

View File

@ -104,7 +104,7 @@ K.SYSCALL.JMP .DA 0 $00
.DA K.ExecProcess.YA
.DA K.CreateProcessNewEnv.YA
.DA K.CreateProcess.YA
.DA K.GetPSByID.A
.DA 0
.DA 0
.DA K.Sleep
.DA 0

View File

@ -4,48 +4,6 @@ LOMEM $A00
INC 1
AUTO 6
*/--------------------------------------
* # GetPSByID.A
* ## In :
* A = PID
* ## Out :
* Y,A = PTR to TSKSLOT
*\--------------------------------------
K.GetPSByID.A pha
>LDYAI TskMgr.Table
>STYA ZPPtr1
pla
beq .8
sta .20+1
ldx #0
.1 inx
lda ZPPtr1
clc
adc #S.PS
sta ZPPtr1
bcc .2
inc ZPPtr1+1
.2 lda (ZPPtr1)
bpl .3
ldy #S.PS.PID
lda (ZPPtr1),y
.20 cmp #$ff Self Modified
beq .8
.3 cpx TskMgr.Count
bne .1
.9 lda #TSKMGR.ERRNSP
sec
rts
.8 >LDYA ZPPtr1
clc
rts
*/--------------------------------------
* # Sleep
* Make current process suspend until next RUN
* ## In :
@ -106,7 +64,7 @@ K.CreateProcess.YA
pha save error code
lda .8+1
jsr PS.Free.A
jsr CORE.PSFree.A
pla get back error code
sec
rts
@ -122,7 +80,7 @@ K.CreateProcess.CmdLine .BS 2
* out :
* A = PSID
* we cannot use ZPPtrs1 & 2
* because of calling K.NewPStrYA & S.DupEnvA
* because of calling K.NewStrY.A & S.DupEnv.A
*--------------------------------------
PS.CreateChild >LDYAI TskMgr.Table+S.PS
>STYA ZPPtr3
@ -156,7 +114,7 @@ PS.CreateChild >LDYAI TskMgr.Table+S.PS
.4 inc TSKMGR.LASTID Get a PSID not alredy running
beq .4 not = 0
lda TSKMGR.LASTID
jsr K.GetPSByID.A
jsr CORE.GetPSByID.A
bcc .4
ldy #S.PS.PID
@ -180,7 +138,7 @@ PS.CreateChild >LDYAI TskMgr.Table+S.PS
ldy #S.PS.hPREFIX copy hPREFIX...
lda (pPs),y
jsr K.GetMemPtr.A
jsr K.NewCStr.YA
jsr K.NewStr.YA
bcs .9
txa
@ -365,42 +323,6 @@ PS.Init jsr BIN.Load.YA Y,A=filename full path
clc
.9 rts
*--------------------------------------
* PS.Free.A
* In : A = PID to free
*--------------------------------------
PS.Free.A jsr K.GetPSByID.A PS in ZPPtr1
ldy #S.PS.hARGS
jsr PS.Free.A.PsY
lda (ZPPtr1) get S.PS.F
and #S.PS.F.ENV do we have to discard duplicated env & prefix ?
beq .1
ldy #S.PS.hENV
jsr PS.Free.A.PsY
ldy #S.PS.hPREFIX
jsr PS.Free.A.PsY
.1 ldy #S.PS.hSS
jsr PS.Free.A.PsY
ldy #S.PS.hDS
jsr PS.Free.A.PsY
ldy #S.PS.hCS
jsr PS.Free.A.PsY
lda #0
sta (ZPPtr1) Mark TSKSLOT as free
clc
PS.Free.A.RTS rts
*--------------------------------------
PS.Free.A.PsY lda (ZPPtr1),y
beq PS.Free.A.RTS
jmp K.FreeMem.A
*--------------------------------------
* PS.DupEnv.A
* In:
* A = ENV hMem To Duplicate