2016-08-17 08:25:58 +02:00
|
|
|
|
PR#3
|
2017-03-29 17:48:15 +02:00
|
|
|
|
PREFIX /A2OSX.BUILD
|
2017-03-15 17:44:15 +01:00
|
|
|
|
LOMEM $A00
|
2016-08-17 08:25:58 +02:00
|
|
|
|
INC 1
|
|
|
|
|
AUTO 6
|
2016-10-31 22:38:53 +01:00
|
|
|
|
*/--------------------------------------
|
2017-08-30 17:26:34 +02:00
|
|
|
|
* # ExecProcessNewEnv.YA
|
2017-09-12 08:20:24 +02:00
|
|
|
|
* # ExecProcess.YA (Blocking Parent PID)
|
2017-08-30 17:26:34 +02:00
|
|
|
|
* # CreateProcessNewEnv.YA
|
|
|
|
|
* # CreateProcess.YA (Non Blocking)
|
|
|
|
|
* ## In:
|
|
|
|
|
* Y,A = PTR To Cmd Line
|
|
|
|
|
* ## Out:
|
|
|
|
|
* A = Child PSID
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
K.ExecProcessNewEnv.YA
|
|
|
|
|
ldx #S.PS.F.ENV+S.PS.F.HOLD
|
|
|
|
|
.HS 2C bit abs
|
|
|
|
|
K.ExecProcess.YA
|
|
|
|
|
ldx #S.PS.F.HOLD
|
|
|
|
|
.HS 2C bit abs
|
|
|
|
|
K.CreateProcessNewEnv.YA
|
|
|
|
|
ldx #S.PS.F.ENV
|
|
|
|
|
.HS 2C bit abs
|
|
|
|
|
K.CreateProcess.YA
|
|
|
|
|
ldx #0
|
|
|
|
|
stx K.CreateProcess.Flags
|
|
|
|
|
>STYA K.CreateProcess.CmdLine
|
|
|
|
|
|
2017-08-31 17:35:15 +02:00
|
|
|
|
jsr PS.CreateChild Child S.PS at ZPPtr3
|
2017-08-30 17:26:34 +02:00
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
sta .8+1
|
|
|
|
|
|
|
|
|
|
>LDYA K.CreateProcess.CmdLine
|
2017-08-31 17:35:15 +02:00
|
|
|
|
jsr PS.CmdLine2Args Y,A = Args[0]
|
2017-08-30 17:26:34 +02:00
|
|
|
|
bcs .9
|
2017-09-12 08:20:24 +02:00
|
|
|
|
|
2017-08-30 17:26:34 +02:00
|
|
|
|
jsr PS.Init
|
|
|
|
|
bcc .8
|
|
|
|
|
|
|
|
|
|
pha save error code
|
|
|
|
|
lda .8+1
|
2017-09-08 16:49:23 +02:00
|
|
|
|
jsr CORE.PSFree.A
|
2017-08-30 17:26:34 +02:00
|
|
|
|
pla get back error code
|
|
|
|
|
sec
|
|
|
|
|
rts
|
2017-09-12 08:20:24 +02:00
|
|
|
|
|
2017-08-30 17:26:34 +02:00
|
|
|
|
.8 lda #$ff self modified
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
K.CreateProcess.Flags .BS 1
|
|
|
|
|
K.CreateProcess.CmdLine .BS 2
|
2016-08-17 08:25:58 +02:00
|
|
|
|
*--------------------------------------
|
2016-09-29 17:30:15 +02:00
|
|
|
|
* PS.CreateChild
|
2016-08-17 08:25:58 +02:00
|
|
|
|
* in :
|
|
|
|
|
* out :
|
|
|
|
|
* A = PSID
|
2017-01-12 18:43:45 +01:00
|
|
|
|
* we cannot use ZPPtrs1 & 2
|
2017-09-08 16:49:23 +02:00
|
|
|
|
* because of calling K.NewStrY.A & S.DupEnv.A
|
2016-08-17 08:25:58 +02:00
|
|
|
|
*--------------------------------------
|
2016-10-03 17:59:36 +02:00
|
|
|
|
PS.CreateChild >LDYAI TskMgr.Table+S.PS
|
2017-01-12 18:43:45 +01:00
|
|
|
|
>STYA ZPPtr3
|
2016-08-17 08:25:58 +02:00
|
|
|
|
|
|
|
|
|
ldx #0
|
|
|
|
|
|
|
|
|
|
.1 inx
|
2017-01-12 18:43:45 +01:00
|
|
|
|
cpx TskMgr.Count
|
2016-08-17 08:25:58 +02:00
|
|
|
|
beq .2
|
|
|
|
|
|
2017-01-12 18:43:45 +01:00
|
|
|
|
lda (ZPPtr3) Found an empty slot
|
2016-08-17 08:25:58 +02:00
|
|
|
|
bpl .3
|
2017-01-12 18:43:45 +01:00
|
|
|
|
lda ZPPtr3
|
2016-08-17 08:25:58 +02:00
|
|
|
|
clc
|
2016-10-03 17:59:36 +02:00
|
|
|
|
adc #S.PS
|
2017-01-12 18:43:45 +01:00
|
|
|
|
sta ZPPtr3
|
2016-08-17 08:25:58 +02:00
|
|
|
|
bcc .1
|
2017-01-12 18:43:45 +01:00
|
|
|
|
inc ZPPtr3+1
|
2016-08-17 08:25:58 +02:00
|
|
|
|
|
|
|
|
|
bra .1
|
|
|
|
|
|
|
|
|
|
.2 cpx #K.PS.MAX
|
2016-08-18 17:26:11 +02:00
|
|
|
|
bne .3
|
2016-08-17 08:25:58 +02:00
|
|
|
|
|
|
|
|
|
lda #TSKMGR.ERROOH
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
|
2017-01-12 18:43:45 +01:00
|
|
|
|
.3 inc TskMgr.Count
|
2016-08-17 08:25:58 +02:00
|
|
|
|
|
|
|
|
|
.4 inc TSKMGR.LASTID Get a PSID not alredy running
|
|
|
|
|
beq .4 not = 0
|
|
|
|
|
lda TSKMGR.LASTID
|
2017-09-08 16:49:23 +02:00
|
|
|
|
jsr CORE.GetPSByID.A
|
2016-08-17 08:25:58 +02:00
|
|
|
|
bcc .4
|
|
|
|
|
|
2016-10-29 21:58:21 +02:00
|
|
|
|
ldy #S.PS.PID
|
2016-08-17 08:25:58 +02:00
|
|
|
|
lda TSKMGR.LASTID
|
2017-01-12 18:43:45 +01:00
|
|
|
|
sta (ZPPtr3),y
|
2016-08-17 08:25:58 +02:00
|
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
|
ldy #S.PS.hCS
|
2016-08-18 17:26:11 +02:00
|
|
|
|
|
2017-01-12 18:43:45 +01:00
|
|
|
|
.5 sta (ZPPtr3),y Blank Everything in this S.PS
|
2016-08-17 08:25:58 +02:00
|
|
|
|
iny
|
2016-10-03 17:59:36 +02:00
|
|
|
|
cpy #S.PS
|
2016-08-17 08:25:58 +02:00
|
|
|
|
bne .5
|
|
|
|
|
|
2016-08-18 17:26:11 +02:00
|
|
|
|
lda #S.PS.F.ENV
|
2016-09-21 17:20:37 +02:00
|
|
|
|
bit K.CreateProcess.Flags need to create ENV & Prefix ?
|
2016-08-18 17:26:11 +02:00
|
|
|
|
beq .6 no...
|
|
|
|
|
|
2017-01-12 18:43:45 +01:00
|
|
|
|
sta (ZPPtr3) Mark this PS with ENV flag
|
2016-08-17 08:25:58 +02:00
|
|
|
|
|
|
|
|
|
ldy #S.PS.hPREFIX copy hPREFIX...
|
|
|
|
|
lda (pPs),y
|
2017-08-25 08:37:21 +02:00
|
|
|
|
jsr K.GetMemPtr.A
|
2017-09-08 16:49:23 +02:00
|
|
|
|
jsr K.NewStr.YA
|
2016-08-18 17:26:11 +02:00
|
|
|
|
bcs .9
|
2016-08-17 08:25:58 +02:00
|
|
|
|
|
|
|
|
|
txa
|
|
|
|
|
ldy #S.PS.hPREFIX
|
2017-01-12 18:43:45 +01:00
|
|
|
|
sta (ZPPtr3),y
|
2016-08-17 08:25:58 +02:00
|
|
|
|
|
|
|
|
|
ldy #S.PS.hENV ...and hENV from parent PS
|
|
|
|
|
lda (pPs),y
|
2017-08-25 08:37:21 +02:00
|
|
|
|
jsr PS.DupEnv.A
|
2016-08-18 17:26:11 +02:00
|
|
|
|
bcs .9
|
2016-08-17 08:25:58 +02:00
|
|
|
|
|
|
|
|
|
ldy #S.PS.hENV
|
2017-01-12 18:43:45 +01:00
|
|
|
|
sta (ZPPtr3),y
|
2016-08-17 08:25:58 +02:00
|
|
|
|
bra .8
|
|
|
|
|
|
|
|
|
|
.6 ldy #S.PS.hPREFIX reuse same hPREFIX...
|
|
|
|
|
lda (pPs),y
|
2017-01-12 18:43:45 +01:00
|
|
|
|
sta (ZPPtr3),y
|
2016-08-17 08:25:58 +02:00
|
|
|
|
|
|
|
|
|
ldy #S.PS.hENV ...and hENV from parent PS
|
|
|
|
|
lda (pPs),y
|
2017-01-12 18:43:45 +01:00
|
|
|
|
sta (ZPPtr3),y
|
2016-08-17 08:25:58 +02:00
|
|
|
|
|
2017-01-12 18:43:45 +01:00
|
|
|
|
.8 ldy #S.PS.hStdIn
|
2016-08-18 17:26:11 +02:00
|
|
|
|
|
2016-08-17 08:25:58 +02:00
|
|
|
|
.81 lda (pPs),y
|
2017-01-12 18:43:45 +01:00
|
|
|
|
sta (ZPPtr3),y
|
2016-08-17 08:25:58 +02:00
|
|
|
|
iny
|
2017-01-12 18:43:45 +01:00
|
|
|
|
cpy #S.PS.hStdErr+1
|
2016-08-17 08:25:58 +02:00
|
|
|
|
bne .81
|
|
|
|
|
|
2016-10-29 21:58:21 +02:00
|
|
|
|
ldy #S.PS.PID
|
2016-08-17 08:25:58 +02:00
|
|
|
|
lda (pPs),y
|
|
|
|
|
|
2016-10-29 21:58:21 +02:00
|
|
|
|
ldy #S.PS.PPID
|
2017-01-12 18:43:45 +01:00
|
|
|
|
sta (ZPPtr3),y
|
2016-08-18 17:26:11 +02:00
|
|
|
|
|
|
|
|
|
lda #S.PS.F.HOLD
|
2016-09-21 17:20:37 +02:00
|
|
|
|
bit K.CreateProcess.Flags
|
2016-08-18 17:26:11 +02:00
|
|
|
|
beq .82
|
2016-08-17 08:25:58 +02:00
|
|
|
|
|
2016-08-18 17:26:11 +02:00
|
|
|
|
ora (pPs)
|
|
|
|
|
sta (pPs) HOLD parent PS if ExecProcess
|
|
|
|
|
|
|
|
|
|
.82 lda #S.PS.F.INUSE+S.PS.F.INIT
|
2017-01-12 18:43:45 +01:00
|
|
|
|
ora (ZPPtr3)
|
2017-09-12 08:20:24 +02:00
|
|
|
|
sta (ZPPtr3) Make this PS Init....
|
2017-01-12 18:43:45 +01:00
|
|
|
|
|
|
|
|
|
ldy #S.PS.CPID
|
2016-08-18 17:26:11 +02:00
|
|
|
|
lda TSKMGR.LASTID
|
2017-01-12 18:43:45 +01:00
|
|
|
|
sta (pPs),y
|
|
|
|
|
|
2016-08-18 17:26:11 +02:00
|
|
|
|
clc Exit with A=PSID
|
|
|
|
|
.9 rts
|
2016-08-17 08:25:58 +02:00
|
|
|
|
*--------------------------------------
|
2017-08-30 17:26:34 +02:00
|
|
|
|
PS.CmdLine2Args >STYA ZPPtr1
|
2017-09-12 08:20:24 +02:00
|
|
|
|
|
2017-08-30 17:26:34 +02:00
|
|
|
|
ldy #0
|
2017-09-12 08:20:24 +02:00
|
|
|
|
|
2017-08-30 17:26:34 +02:00
|
|
|
|
.1 lda (ZPPtr1),y compute strlen in Y,X
|
|
|
|
|
beq .2
|
|
|
|
|
cmp #'"' skip "" in computation....
|
|
|
|
|
beq .1
|
|
|
|
|
iny
|
|
|
|
|
bne .1 max 255
|
2017-09-12 08:20:24 +02:00
|
|
|
|
|
2017-08-30 17:26:34 +02:00
|
|
|
|
.2 tya +2 for ending 0 for last string, and endig 0 for array
|
|
|
|
|
clc
|
|
|
|
|
adc #2
|
|
|
|
|
tay
|
|
|
|
|
lda #0
|
|
|
|
|
bcc .3
|
|
|
|
|
inc
|
|
|
|
|
|
|
|
|
|
.3 jsr K.GetMem.YA
|
2016-08-17 08:25:58 +02:00
|
|
|
|
bcs .9
|
2017-08-31 17:35:15 +02:00
|
|
|
|
|
2017-08-30 17:26:34 +02:00
|
|
|
|
phy save PTR.LO
|
|
|
|
|
pha save PTR.HI
|
|
|
|
|
>STYA ZPPtr2
|
|
|
|
|
|
2017-08-31 17:35:15 +02:00
|
|
|
|
txa
|
|
|
|
|
ldy #S.PS.hARGS
|
|
|
|
|
sta (ZPPtr3),y
|
|
|
|
|
|
2017-08-30 17:26:34 +02:00
|
|
|
|
stz PS.CmdLine2Args.bInQuote
|
2016-08-17 08:25:58 +02:00
|
|
|
|
|
2017-08-30 17:26:34 +02:00
|
|
|
|
ldy #0
|
|
|
|
|
ldx #0 Arg Count
|
2016-08-17 08:25:58 +02:00
|
|
|
|
|
2017-08-30 17:26:34 +02:00
|
|
|
|
.4 lda (ZPPtr1),y
|
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
cmp #'"' found a quote ?
|
|
|
|
|
bne .5
|
|
|
|
|
lda PS.CmdLine2Args.bInQuote
|
|
|
|
|
eor #$ff
|
|
|
|
|
sta PS.CmdLine2Args.bInQuote
|
|
|
|
|
bra .71
|
|
|
|
|
|
|
|
|
|
.5 cmp #' '
|
|
|
|
|
bne .70
|
|
|
|
|
|
|
|
|
|
bit PS.CmdLine2Args.bInQuote
|
|
|
|
|
bmi .70
|
|
|
|
|
|
|
|
|
|
inx Found one arg !!!
|
|
|
|
|
lda #0
|
|
|
|
|
|
|
|
|
|
.70 sta (ZPPtr2) yes, set this token len
|
|
|
|
|
.71 inc ZPPtr2
|
|
|
|
|
bne .72
|
|
|
|
|
inc ZPPtr2+1
|
|
|
|
|
.72 iny
|
|
|
|
|
bne .4
|
|
|
|
|
|
|
|
|
|
.8 lda #0
|
|
|
|
|
sta (ZPPtr2) set Array Ending 0
|
|
|
|
|
|
2017-08-31 17:35:15 +02:00
|
|
|
|
txa
|
|
|
|
|
ldy #S.PS.ARGC
|
|
|
|
|
sta (ZPPtr3),y
|
|
|
|
|
|
2017-08-30 17:26:34 +02:00
|
|
|
|
pla get back PTR.HI
|
|
|
|
|
ply get back PTR.LO
|
2017-08-31 17:35:15 +02:00
|
|
|
|
|
2017-08-30 17:26:34 +02:00
|
|
|
|
clc
|
|
|
|
|
.9 rts
|
2016-10-12 08:28:57 +02:00
|
|
|
|
|
2017-08-30 17:26:34 +02:00
|
|
|
|
PS.CmdLine2Args.bInQuote
|
|
|
|
|
.BS 1
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
PS.Init jsr BIN.Load.YA Y,A=filename full path
|
2016-08-17 08:25:58 +02:00
|
|
|
|
bcs .9
|
2017-09-12 08:20:24 +02:00
|
|
|
|
|
2017-01-12 18:43:45 +01:00
|
|
|
|
>STYA ZPPtr4 save PTR to Code Segment
|
2016-08-17 08:25:58 +02:00
|
|
|
|
txa
|
|
|
|
|
ldy #S.PS.hCS
|
2017-01-12 18:43:45 +01:00
|
|
|
|
sta (ZPPtr3),y save CS hMem in TSKSLOT
|
2017-09-12 08:20:24 +02:00
|
|
|
|
|
2016-09-30 17:04:55 +02:00
|
|
|
|
ldy #H.BIN.EXE.DS.SIZE+1
|
2017-01-12 18:43:45 +01:00
|
|
|
|
lda (ZPPtr4),y Load DS.SIZE HI
|
2016-08-17 08:25:58 +02:00
|
|
|
|
tax
|
|
|
|
|
dey
|
2017-01-12 18:43:45 +01:00
|
|
|
|
ora (ZPPtr4),y
|
2017-09-12 08:20:24 +02:00
|
|
|
|
|
2016-08-17 08:25:58 +02:00
|
|
|
|
beq .2 DS.SIZE=0...
|
2017-09-12 08:20:24 +02:00
|
|
|
|
|
2017-07-01 15:44:40 +02:00
|
|
|
|
lda (ZPPtr4),y
|
|
|
|
|
tay
|
|
|
|
|
txa Y,A = DS.SIZE
|
2017-08-25 08:37:21 +02:00
|
|
|
|
jsr K.GetMem0.YA
|
2016-08-17 08:25:58 +02:00
|
|
|
|
bcs .9
|
2017-09-12 08:20:24 +02:00
|
|
|
|
|
2016-08-17 08:25:58 +02:00
|
|
|
|
txa
|
|
|
|
|
ldy #S.PS.hDS
|
2017-01-12 18:43:45 +01:00
|
|
|
|
sta (ZPPtr3),y save DS hMem in TSKSLOT
|
2017-09-12 08:20:24 +02:00
|
|
|
|
|
2017-09-12 17:24:36 +02:00
|
|
|
|
.2 ldy #H.BIN.EXE.SS.SIZE
|
|
|
|
|
lda (ZPPtr4),y Load SS.SIZE.LO
|
|
|
|
|
|
|
|
|
|
ldy #S.PS.SP
|
|
|
|
|
sta (ZPPtr3),y Init SP to top of hSS
|
2017-09-12 08:20:24 +02:00
|
|
|
|
|
2017-09-12 17:24:36 +02:00
|
|
|
|
lda #0
|
2017-09-12 08:20:24 +02:00
|
|
|
|
tay
|
2017-09-12 17:24:36 +02:00
|
|
|
|
bne .3 SS.SIZE.LO=0, set as default $100
|
|
|
|
|
inc SS.SIZE.HI
|
|
|
|
|
|
|
|
|
|
.3 >PUSHYA
|
2017-09-12 08:20:24 +02:00
|
|
|
|
>PUSHBI S.MEM.F.ALIGN
|
|
|
|
|
jsr K.GetMem
|
2017-08-28 17:35:10 +02:00
|
|
|
|
bcs .9
|
2017-09-12 08:20:24 +02:00
|
|
|
|
|
2017-08-28 17:35:10 +02:00
|
|
|
|
txa
|
|
|
|
|
ldy #S.PS.hSS
|
2017-09-11 17:29:08 +02:00
|
|
|
|
sta (ZPPtr3),y save SS hMem in TSKSLOT
|
2017-08-28 17:35:10 +02:00
|
|
|
|
|
2016-08-18 17:26:11 +02:00
|
|
|
|
clc
|
|
|
|
|
.9 rts
|
2016-08-17 08:25:58 +02:00
|
|
|
|
*--------------------------------------
|
2017-08-25 08:37:21 +02:00
|
|
|
|
* PS.DupEnv.A
|
2016-08-17 08:25:58 +02:00
|
|
|
|
* In:
|
|
|
|
|
* A = ENV hMem To Duplicate
|
|
|
|
|
* Out:
|
|
|
|
|
* A = hMem to new ENV
|
|
|
|
|
*--------------------------------------
|
2017-08-25 08:37:21 +02:00
|
|
|
|
PS.DupEnv.A jsr K.GetMemPtr.A
|
2017-01-12 18:43:45 +01:00
|
|
|
|
>STYA ZPPtr1
|
2017-09-14 17:21:06 +02:00
|
|
|
|
|
2017-07-01 15:44:40 +02:00
|
|
|
|
>LDYAI K.ENV.SIZE
|
2017-08-25 08:37:21 +02:00
|
|
|
|
jsr K.GetMem.YA
|
2016-08-17 08:25:58 +02:00
|
|
|
|
bcs .9
|
2017-09-14 17:21:06 +02:00
|
|
|
|
|
2017-01-12 18:43:45 +01:00
|
|
|
|
>STYA ZPPtr2
|
2017-09-14 17:21:06 +02:00
|
|
|
|
|
2016-08-17 08:25:58 +02:00
|
|
|
|
ldy #0
|
|
|
|
|
|
2017-01-12 18:43:45 +01:00
|
|
|
|
.1 lda (ZPPtr1),y
|
|
|
|
|
sta (ZPPtr2),y
|
2016-08-17 08:25:58 +02:00
|
|
|
|
beq .8
|
|
|
|
|
|
2017-09-14 17:21:06 +02:00
|
|
|
|
.2 iny
|
|
|
|
|
bne .3
|
|
|
|
|
inc ZPPtr1+1
|
|
|
|
|
inc ZPPtr2+1
|
|
|
|
|
|
|
|
|
|
.3 lda (ZPPtr1),y
|
|
|
|
|
sta (ZPPtr2),y
|
|
|
|
|
bne .2
|
|
|
|
|
|
|
|
|
|
iny
|
2016-08-17 08:25:58 +02:00
|
|
|
|
bne .1
|
2017-01-12 18:43:45 +01:00
|
|
|
|
inc ZPPtr1+1
|
|
|
|
|
inc ZPPtr2+1
|
2016-08-17 08:25:58 +02:00
|
|
|
|
bra .1
|
|
|
|
|
|
|
|
|
|
.8 txa
|
|
|
|
|
clc
|
|
|
|
|
.9 rts
|
2017-08-29 17:19:09 +02:00
|
|
|
|
*--------------------------------------
|
2016-08-17 08:25:58 +02:00
|
|
|
|
MAN
|
2017-03-29 17:48:15 +02:00
|
|
|
|
SAVE /A2OSX.SRC/SYS/KERNEL.S.PS
|
|
|
|
|
LOAD /A2OSX.SRC/SYS/KERNEL.S
|
2016-08-17 08:25:58 +02:00
|
|
|
|
ASM
|