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.ExecProcessYA .EQ $A2
SYS.CreateProcessNewEnvYA .EQ $A4 SYS.CreateProcessNewEnvYA .EQ $A4
SYS.CreateProcessYA .EQ $A6 SYS.CreateProcessYA .EQ $A6
SYS.GetPSByIDA .EQ $A8 * .EQ $A8
* .EQ $AA * .EQ $AA
SYS.Sleep .EQ $AC SYS.Sleep .EQ $AC
* .EQ $AE * .EQ $AE

View File

@ -115,17 +115,37 @@ AUTO 6
*-------------------------------------- *--------------------------------------
* Global DATA Segment Access * Global DATA Segment Access
*-------------------------------------- *--------------------------------------
.MA GETG.A .MA LDA.G
ldy #]1 ldy #]1
lda (pData),y lda (pData),y
.EM .EM
*-------------------------------------- *--------------------------------------
.MA SETG.A .MA STA.G
ldy #]1 ldy #]1
sta (pData),y sta (pData),y
.EM .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 ldy #]1
lda (pData),y lda (pData),y
pha pha
@ -134,7 +154,7 @@ AUTO 6
ply ply
.EM .EM
*-------------------------------------- *--------------------------------------
.MA SETG.YA .MA STYA.G
phy phy
ldy #]1+1 ldy #]1+1
sta (pData),y sta (pData),y

View File

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

View File

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

View File

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

View File

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

View File

@ -214,7 +214,7 @@ BIN.Load.YA.1 >PUSHWI K.S.STAT
jsr BIN.RelocateEXE jsr BIN.RelocateEXE
>LDYA BIN.CmdLine get back bin path >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 bcs .98
lda BIN.hMem Keep X=hMem lda BIN.hMem Keep X=hMem

View File

@ -42,15 +42,15 @@ CORE.Run jsr CORE.TskMgrRun
cmp #2 is SYS active? cmp #2 is SYS active?
bne .6 bne .6
ldx SYS.CPULOADI ldx CORE.CPULOADI
lda SYS.CPULOADC,x lda CORE.CPULOADC,x
sta SYS.BASL0+38 sta SYS.BASL0+38
dex dex
bpl .5 bpl .5
ldx #3 ldx #3
.5 stx SYS.CPULOADI .5 stx CORE.CPULOADI
.6 bit OPENAPPLE .6 bit OPENAPPLE
bpl CORE.Run bpl CORE.Run
@ -102,8 +102,8 @@ CORE.ScreenSelect
.8 rts .8 rts
*-------------------------------------- *--------------------------------------
SYS.CPULOADI .BS 1 CORE.CPULOADI .BS 1
SYS.CPULOADC .AS '\|/-' CORE.CPULOADC .AS -"/-\|"
*-------------------------------------- *--------------------------------------
CORE.TskMgrRun >LDYAI TskMgr.Table+S.PS skip PS 0 CORE.TskMgrRun >LDYAI TskMgr.Table+S.PS skip PS 0
>STYA pPs >STYA pPs
@ -126,7 +126,7 @@ CORE.TskMgrRun >LDYAI TskMgr.Table+S.PS skip PS 0
ldy #S.PS.CPID ldy #S.PS.CPID
lda (pPs),y lda (pPs),y
jsr K.GetPSByID.A jsr CORE.GetPSByID.A
bcc .7 yes, running.... bcc .7 yes, running....
lda (pPs) get S.PS.F lda (pPs) get S.PS.F
@ -159,7 +159,7 @@ CORE.TskMgrRun >LDYAI TskMgr.Table+S.PS skip PS 0
pha save RC pha save RC
ldy #S.PS.PPID Notify Parent Process for exit code... ldy #S.PS.PPID Notify Parent Process for exit code...
lda (pPs),y 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... bcs .5 parent is dead.....skipping...
lda (ZPPtr1) Parent PS is HOLD? lda (ZPPtr1) Parent PS is HOLD?
@ -181,7 +181,7 @@ CORE.TskMgrRun >LDYAI TskMgr.Table+S.PS skip PS 0
ldy #S.PS.PID ldy #S.PS.PID
lda (pPs),y lda (pPs),y
jsr PS.Free.A jsr CORE.PSFree.A
.7 lda pPs .7 lda pPs
clc clc
@ -194,6 +194,43 @@ CORE.TskMgrRun >LDYAI TskMgr.Table+S.PS skip PS 0
.8 clc .8 clc
rts 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 CORE.PSSelect0 >LDYAI TskMgr.Table Select PS0
>STYA pPs >STYA pPs
@ -207,22 +244,19 @@ CORE.PSSelect ldy #S.PS.hCS
jsr K.GetMemPtr.A jsr K.GetMemPtr.A
>STYA pCode >STYA pCode
iny ldy #S.PS.hDS
* ldy #S.PS.hDS
lda (pPs),y lda (pPs),y
beq .1 beq .1
jsr K.GetMemPtr.A jsr K.GetMemPtr.A
>STYA pData >STYA pData
.1 iny .1 ldy #S.PS.hSS
* ldy #S.PS.hSS
lda (pPs),y lda (pPs),y
jsr K.GetMemPtr.A jsr K.GetMemPtr.A
>STYA pStack >STYA pStack
iny ldy #S.PS.SP
* ldy #S.PS.SP
lda pStack lda pStack
clc clc
adc (pPs),y adc (pPs),y
@ -243,6 +277,42 @@ CORE.PSLeave ldy #S.PS.hSS
rts 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 : * CORE.GetEvents :
* IN : * IN :
* OUT : * OUT :

View File

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

View File

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

View File

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

View File

@ -4,48 +4,6 @@ LOMEM $A00
INC 1 INC 1
AUTO 6 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 * # Sleep
* Make current process suspend until next RUN * Make current process suspend until next RUN
* ## In : * ## In :
@ -106,7 +64,7 @@ K.CreateProcess.YA
pha save error code pha save error code
lda .8+1 lda .8+1
jsr PS.Free.A jsr CORE.PSFree.A
pla get back error code pla get back error code
sec sec
rts rts
@ -122,7 +80,7 @@ K.CreateProcess.CmdLine .BS 2
* out : * out :
* A = PSID * A = PSID
* we cannot use ZPPtrs1 & 2 * 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 PS.CreateChild >LDYAI TskMgr.Table+S.PS
>STYA ZPPtr3 >STYA ZPPtr3
@ -156,7 +114,7 @@ PS.CreateChild >LDYAI TskMgr.Table+S.PS
.4 inc TSKMGR.LASTID Get a PSID not alredy running .4 inc TSKMGR.LASTID Get a PSID not alredy running
beq .4 not = 0 beq .4 not = 0
lda TSKMGR.LASTID lda TSKMGR.LASTID
jsr K.GetPSByID.A jsr CORE.GetPSByID.A
bcc .4 bcc .4
ldy #S.PS.PID ldy #S.PS.PID
@ -180,7 +138,7 @@ PS.CreateChild >LDYAI TskMgr.Table+S.PS
ldy #S.PS.hPREFIX copy hPREFIX... ldy #S.PS.hPREFIX copy hPREFIX...
lda (pPs),y lda (pPs),y
jsr K.GetMemPtr.A jsr K.GetMemPtr.A
jsr K.NewCStr.YA jsr K.NewStr.YA
bcs .9 bcs .9
txa txa
@ -365,42 +323,6 @@ PS.Init jsr BIN.Load.YA Y,A=filename full path
clc clc
.9 rts .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 * PS.DupEnv.A
* In: * In:
* A = ENV hMem To Duplicate * A = ENV hMem To Duplicate