2017-12-22 21:24:30 +00:00
|
|
|
|
NEW
|
2018-11-17 17:17:13 +00:00
|
|
|
|
PREFIX
|
2017-12-22 21:24:30 +00:00
|
|
|
|
AUTO 4,1
|
2018-10-15 06:25:40 +00:00
|
|
|
|
*--------------------------------------
|
2019-01-04 13:17:31 +00:00
|
|
|
|
.DUMMY
|
|
|
|
|
.OR ZPTMP+21
|
2018-10-15 06:25:40 +00:00
|
|
|
|
PS.Flags .BS 1
|
2018-10-26 14:46:11 +00:00
|
|
|
|
PS.ArgV .BS 2
|
2019-01-04 13:17:31 +00:00
|
|
|
|
PS.ArgSize .BS 2
|
|
|
|
|
PS.hMem .BS 1
|
|
|
|
|
.ED
|
2016-10-31 21:38:53 +00:00
|
|
|
|
*/--------------------------------------
|
2018-10-25 15:31:41 +00:00
|
|
|
|
* # ExecL
|
|
|
|
|
* ## C
|
|
|
|
|
* `int execl(const char* cmdline, short int flags);`
|
|
|
|
|
* ## ASM
|
|
|
|
|
* `>PUSHB flags`
|
|
|
|
|
* `>LDYA cmdline`
|
|
|
|
|
* `>SYSCALL execl`
|
|
|
|
|
* ## RETURN VALUE
|
|
|
|
|
* A = Child PSID
|
|
|
|
|
*\--------------------------------------
|
2018-11-30 16:00:36 +00:00
|
|
|
|
K.ExecL sty .1+1
|
2018-10-26 14:46:11 +00:00
|
|
|
|
sta .2+1
|
|
|
|
|
>PULLB PS.Flags
|
2018-11-30 16:00:36 +00:00
|
|
|
|
|
2018-10-26 14:46:11 +00:00
|
|
|
|
>LDYAI 256
|
|
|
|
|
jsr K.GetMem
|
|
|
|
|
bcs .99
|
2018-10-25 15:31:41 +00:00
|
|
|
|
|
2018-10-26 14:46:11 +00:00
|
|
|
|
stx .90+1
|
|
|
|
|
>STYA PS.ArgV
|
|
|
|
|
>PUSHYA
|
|
|
|
|
.1 ldy #$ff SELF MODIFIED
|
|
|
|
|
.2 lda #$ff SELF MODIFIED
|
2018-10-25 15:31:41 +00:00
|
|
|
|
|
2018-10-26 14:46:11 +00:00
|
|
|
|
jsr K.Args2ArgV
|
|
|
|
|
|
|
|
|
|
bcs .9
|
2018-12-20 16:23:43 +00:00
|
|
|
|
|
2018-10-26 14:46:11 +00:00
|
|
|
|
jsr PS.Exec
|
|
|
|
|
|
|
|
|
|
.9 php
|
2018-10-26 06:16:14 +00:00
|
|
|
|
pha
|
2018-10-26 14:46:11 +00:00
|
|
|
|
.90 lda #$ff SELF MODIFIED
|
|
|
|
|
jsr K.FreeMem
|
2018-10-26 06:16:14 +00:00
|
|
|
|
pla
|
2018-10-26 14:46:11 +00:00
|
|
|
|
plp
|
|
|
|
|
|
|
|
|
|
.99 rts
|
2018-10-25 15:31:41 +00:00
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # ExecV
|
2018-10-15 06:25:40 +00:00
|
|
|
|
* ## C
|
2018-10-16 15:48:03 +00:00
|
|
|
|
* `int exec(const char* argv[], short int flags);`
|
2018-10-15 06:25:40 +00:00
|
|
|
|
* ## ASM
|
|
|
|
|
* `>PUSHB flags`
|
|
|
|
|
* `>LDYA argv`
|
2018-10-15 15:39:21 +00:00
|
|
|
|
* `>SYSCALL execv`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-10-15 06:25:40 +00:00
|
|
|
|
* A = Child PSID
|
2017-08-30 15:26:34 +00:00
|
|
|
|
*\--------------------------------------
|
2018-10-26 14:46:11 +00:00
|
|
|
|
K.ExecV >STYA PS.ArgV
|
2018-10-15 06:25:40 +00:00
|
|
|
|
>PULLB PS.Flags
|
2018-10-25 15:31:41 +00:00
|
|
|
|
|
2018-11-28 14:58:42 +00:00
|
|
|
|
PS.Exec jsr PS.CreateChild A=PID,Child S.PS at ZPPtr3,PS.Load.hMem
|
2017-08-30 15:26:34 +00:00
|
|
|
|
bcs .9
|
2018-11-27 14:03:26 +00:00
|
|
|
|
sta .8+1
|
2018-12-03 12:32:46 +00:00
|
|
|
|
|
2018-11-28 14:58:42 +00:00
|
|
|
|
stz K.IOBuf
|
2018-07-05 05:42:16 +00:00
|
|
|
|
jsr PS.Load
|
2018-11-23 07:02:00 +00:00
|
|
|
|
bcs .90
|
2018-12-03 12:32:46 +00:00
|
|
|
|
|
2018-11-22 16:39:41 +00:00
|
|
|
|
jsr PS.AddArgV
|
2017-08-30 15:26:34 +00:00
|
|
|
|
bcc .8
|
|
|
|
|
|
2018-11-23 07:02:00 +00:00
|
|
|
|
.90 pha save error code
|
|
|
|
|
|
|
|
|
|
.91 lda .8+1
|
2018-10-24 15:36:45 +00:00
|
|
|
|
jsr CORE.PSFree
|
2017-08-30 15:26:34 +00:00
|
|
|
|
pla get back error code
|
|
|
|
|
sec
|
|
|
|
|
rts
|
2017-09-12 06:20:24 +00:00
|
|
|
|
|
2018-11-27 14:03:26 +00:00
|
|
|
|
.8 lda #$ff SELF MODIFIED
|
2018-12-03 12:32:46 +00:00
|
|
|
|
|
2017-08-30 15:26:34 +00:00
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
2016-09-29 15:30:15 +00:00
|
|
|
|
* PS.CreateChild
|
2016-08-17 06:25:58 +00:00
|
|
|
|
* in :
|
|
|
|
|
* out :
|
|
|
|
|
* A = PSID
|
2017-01-12 17:43:45 +00:00
|
|
|
|
* we cannot use ZPPtrs1 & 2
|
2018-12-20 16:23:43 +00:00
|
|
|
|
* because of calling K.StrDup & PS.DupEnv
|
2016-08-17 06:25:58 +00:00
|
|
|
|
*--------------------------------------
|
2018-10-23 15:36:57 +00:00
|
|
|
|
PS.CreateChild ldx CORE.PSCount
|
|
|
|
|
beq .3
|
|
|
|
|
|
|
|
|
|
ldx #0
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2018-10-15 15:39:21 +00:00
|
|
|
|
.1 lda PS.Table.PID,x
|
2018-10-17 15:31:29 +00:00
|
|
|
|
beq .4 Found an empty slot
|
2018-10-23 15:36:57 +00:00
|
|
|
|
|
2017-09-19 15:34:01 +00:00
|
|
|
|
inx
|
2018-10-23 15:36:57 +00:00
|
|
|
|
cpx CORE.PSCount
|
2018-10-15 15:39:21 +00:00
|
|
|
|
bne .1
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2018-10-23 15:36:57 +00:00
|
|
|
|
cpx #K.PS.MAX
|
|
|
|
|
bne .3
|
|
|
|
|
|
2018-10-21 20:54:07 +00:00
|
|
|
|
lda #E.OOH
|
2016-08-17 06:25:58 +00:00
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
|
2017-10-09 05:51:32 +00:00
|
|
|
|
.99 plx
|
|
|
|
|
rts
|
|
|
|
|
|
2018-10-23 15:36:57 +00:00
|
|
|
|
.3 inc CORE.PSCount
|
|
|
|
|
|
2018-10-15 15:39:21 +00:00
|
|
|
|
.4 inc CORE.LastPSID Get a PSID not already running
|
2016-08-17 06:25:58 +00:00
|
|
|
|
beq .4 not = 0
|
2017-09-19 15:34:01 +00:00
|
|
|
|
lda CORE.LastPSID
|
2018-10-17 15:31:29 +00:00
|
|
|
|
jsr CORE.GetPS Y=PS Index, X,A unmodified
|
|
|
|
|
bcc .4 running...loop
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2017-09-19 15:34:01 +00:00
|
|
|
|
lda CORE.LastPSID
|
|
|
|
|
sta PS.Table.PID,x
|
2018-10-17 15:31:29 +00:00
|
|
|
|
phx save PS Index
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2017-09-19 15:34:01 +00:00
|
|
|
|
>LDYAI S.PS
|
2018-06-21 15:12:10 +00:00
|
|
|
|
jsr K.GetMem0 Blank Everything in this S.PS
|
2017-09-19 15:34:01 +00:00
|
|
|
|
bcs .99
|
2016-08-18 15:26:11 +00:00
|
|
|
|
|
2017-09-19 15:34:01 +00:00
|
|
|
|
>STYA ZPPtr3
|
2019-01-04 13:17:31 +00:00
|
|
|
|
stx PS.hMem
|
2017-09-19 15:34:01 +00:00
|
|
|
|
txa
|
|
|
|
|
plx
|
2018-10-17 15:31:29 +00:00
|
|
|
|
sta PS.Table.hPS,x
|
2017-09-19 15:34:01 +00:00
|
|
|
|
|
2018-06-21 15:12:10 +00:00
|
|
|
|
jsr PS.SetMemOwner Set Ownership
|
2017-10-09 05:51:32 +00:00
|
|
|
|
|
2017-09-19 15:34:01 +00:00
|
|
|
|
ldy #S.PS.PID
|
|
|
|
|
lda CORE.LastPSID
|
|
|
|
|
sta (ZPPtr3),y
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.PS.hPREFIX copy hPREFIX...
|
|
|
|
|
lda (pPs),y
|
2018-06-21 15:12:10 +00:00
|
|
|
|
jsr K.GetMemPtr
|
2018-12-20 16:23:43 +00:00
|
|
|
|
>SYSCALL StrDup
|
2016-08-18 15:26:11 +00:00
|
|
|
|
bcs .9
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2018-11-28 14:58:42 +00:00
|
|
|
|
jsr PS.SetMemOwner Set Ownership
|
2017-10-06 15:25:14 +00:00
|
|
|
|
|
2016-08-17 06:25:58 +00:00
|
|
|
|
txa
|
|
|
|
|
ldy #S.PS.hPREFIX
|
2017-01-12 17:43:45 +00:00
|
|
|
|
sta (ZPPtr3),y
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2018-11-28 14:58:42 +00:00
|
|
|
|
lda #S.PS.F.DUPENV
|
|
|
|
|
bit PS.Flags need to create ENV ?
|
|
|
|
|
beq .6 no...
|
|
|
|
|
|
|
|
|
|
sta (ZPPtr3) Mark this PS with DUPENV flag
|
|
|
|
|
|
|
|
|
|
ldy #S.PS.hENV dup hENV from parent PS
|
2016-08-17 06:25:58 +00:00
|
|
|
|
lda (pPs),y
|
2018-06-22 14:59:24 +00:00
|
|
|
|
jsr PS.DupEnv
|
2016-08-18 15:26:11 +00:00
|
|
|
|
bcs .9
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.PS.hENV
|
|
|
|
|
bra .8
|
|
|
|
|
|
2018-11-28 14:58:42 +00:00
|
|
|
|
.6 ldy #S.PS.hENV reuse hENV from parent PS
|
2016-08-17 06:25:58 +00:00
|
|
|
|
lda (pPs),y
|
2018-11-28 14:58:42 +00:00
|
|
|
|
|
|
|
|
|
.8 sta (ZPPtr3),y
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2018-11-28 14:58:42 +00:00
|
|
|
|
ldy #S.PS.hStdIn
|
2016-08-18 15:26:11 +00:00
|
|
|
|
|
2016-08-17 06:25:58 +00:00
|
|
|
|
.81 lda (pPs),y
|
2017-01-12 17:43:45 +00:00
|
|
|
|
sta (ZPPtr3),y
|
2016-08-17 06:25:58 +00:00
|
|
|
|
iny
|
2017-01-12 17:43:45 +00:00
|
|
|
|
cpy #S.PS.hStdErr+1
|
2016-08-17 06:25:58 +00:00
|
|
|
|
bne .81
|
|
|
|
|
|
2016-10-29 19:58:21 +00:00
|
|
|
|
ldy #S.PS.PID
|
2016-08-17 06:25:58 +00:00
|
|
|
|
lda (pPs),y
|
|
|
|
|
|
2016-10-29 19:58:21 +00:00
|
|
|
|
ldy #S.PS.PPID
|
2017-01-12 17:43:45 +00:00
|
|
|
|
sta (ZPPtr3),y
|
2016-08-18 15:26:11 +00:00
|
|
|
|
|
|
|
|
|
lda #S.PS.F.HOLD
|
2017-10-27 14:56:46 +00:00
|
|
|
|
bit PS.Flags
|
2016-08-18 15:26:11 +00:00
|
|
|
|
beq .82
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2016-08-18 15:26:11 +00:00
|
|
|
|
ora (pPs)
|
2018-10-15 06:25:40 +00:00
|
|
|
|
sta (pPs) HOLD parent PS
|
2016-08-18 15:26:11 +00:00
|
|
|
|
|
2017-10-06 15:25:14 +00:00
|
|
|
|
.82 lda #S.PS.F.INIT
|
2017-01-12 17:43:45 +00:00
|
|
|
|
ora (ZPPtr3)
|
2017-09-12 06:20:24 +00:00
|
|
|
|
sta (ZPPtr3) Make this PS Init....
|
2017-01-12 17:43:45 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.PS.CPID
|
2017-09-19 15:34:01 +00:00
|
|
|
|
lda CORE.LastPSID
|
2017-01-12 17:43:45 +00:00
|
|
|
|
sta (pPs),y
|
|
|
|
|
|
2016-08-18 15:26:11 +00:00
|
|
|
|
clc Exit with A=PSID
|
|
|
|
|
.9 rts
|
2016-08-17 06:25:58 +00:00
|
|
|
|
*--------------------------------------
|
2018-11-22 16:39:41 +00:00
|
|
|
|
PS.Load >PUSHWI K.S.STAT
|
|
|
|
|
>LDYA PS.ArgV
|
|
|
|
|
>SYSCALL stat BANK 1
|
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
|
|
lda K.S.STAT+S.STAT.P.TYPE
|
|
|
|
|
cmp #S.FI.T.BIN
|
|
|
|
|
beq PS.LoadBIN
|
|
|
|
|
cmp #S.FI.T.TXT
|
|
|
|
|
bne .98
|
2018-11-23 16:20:19 +00:00
|
|
|
|
|
|
|
|
|
* beq .10
|
|
|
|
|
* cmp #S.FI.T.SYS
|
|
|
|
|
* bra *
|
2018-11-22 16:39:41 +00:00
|
|
|
|
|
|
|
|
|
.10 jsr PS.LoadGetHeader
|
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
|
|
>LDYAI PS.Load.ROOT
|
2018-11-23 16:20:19 +00:00
|
|
|
|
jsr K.GetEnv ZPPtr3 Trashed
|
2018-11-22 16:39:41 +00:00
|
|
|
|
bcs .97
|
|
|
|
|
|
|
|
|
|
>STYA .21+1
|
|
|
|
|
|
|
|
|
|
ldx #$ff
|
2018-12-03 12:32:46 +00:00
|
|
|
|
|
2018-11-22 16:39:41 +00:00
|
|
|
|
.2 inx
|
2018-11-23 16:20:19 +00:00
|
|
|
|
.21 lda $ffff,x SELF MODIFIED
|
|
|
|
|
sta K.IOBuf,x
|
2018-11-22 16:39:41 +00:00
|
|
|
|
bne .2
|
|
|
|
|
|
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
|
|
.3 lda K.IOBuf+128,y
|
|
|
|
|
cmp PS.Load.HEADER,y
|
|
|
|
|
bne .98
|
|
|
|
|
iny
|
|
|
|
|
cpy #3
|
|
|
|
|
bne .3
|
|
|
|
|
|
|
|
|
|
.4 iny
|
|
|
|
|
inx
|
|
|
|
|
lda K.IOBuf+128-1,y
|
2018-11-23 16:20:19 +00:00
|
|
|
|
sta K.IOBuf-1,x
|
2018-12-03 12:32:46 +00:00
|
|
|
|
beq .5
|
|
|
|
|
eor #C.CR
|
|
|
|
|
bne .4
|
|
|
|
|
|
|
|
|
|
sta K.IOBuf-1,x
|
2018-11-22 16:39:41 +00:00
|
|
|
|
|
2018-12-03 12:32:46 +00:00
|
|
|
|
.5 >PUSHWI K.S.STAT
|
2018-11-23 16:20:19 +00:00
|
|
|
|
>LDYAI K.IOBuf
|
|
|
|
|
>SYSCALL stat BANK 1
|
|
|
|
|
bcs .99
|
|
|
|
|
|
2019-01-04 13:17:31 +00:00
|
|
|
|
lda PS.hMem Restore ZPPtr3 trashed by GetEnv
|
2018-11-23 16:20:19 +00:00
|
|
|
|
jsr K.GetMemPtr
|
|
|
|
|
>STYA ZPPtr3
|
|
|
|
|
|
|
|
|
|
>LDYAI K.IOBuf
|
2018-11-23 07:02:00 +00:00
|
|
|
|
|
2018-11-22 16:39:41 +00:00
|
|
|
|
bra PS.LoadBIN.YA
|
|
|
|
|
|
|
|
|
|
.97 lda #E.BADPATH
|
|
|
|
|
.HS 2C
|
|
|
|
|
.98 lda #E.IBIN
|
|
|
|
|
sec
|
|
|
|
|
.99 rts
|
|
|
|
|
|
2018-11-28 14:58:42 +00:00
|
|
|
|
PS.LoadBIN >LDYA PS.ArgV
|
|
|
|
|
|
2018-11-22 16:39:41 +00:00
|
|
|
|
PS.LoadBIN.YA jsr BIN.Load
|
2016-08-17 06:25:58 +00:00
|
|
|
|
bcs .9
|
2017-01-12 17:43:45 +00:00
|
|
|
|
>STYA ZPPtr4 save PTR to Code Segment
|
2018-11-23 16:20:19 +00:00
|
|
|
|
|
2017-09-20 15:09:55 +00:00
|
|
|
|
phy
|
2018-04-10 15:03:29 +00:00
|
|
|
|
ldy #S.PS.ZP.CODE+1
|
2017-09-20 15:09:55 +00:00
|
|
|
|
sta (ZPPtr3),y save pCode HI...
|
|
|
|
|
dey
|
|
|
|
|
pla
|
|
|
|
|
sta (ZPPtr3),y save pCode LO...
|
|
|
|
|
|
2016-08-17 06:25:58 +00:00
|
|
|
|
txa
|
|
|
|
|
ldy #S.PS.hCS
|
2017-09-20 15:09:55 +00:00
|
|
|
|
sta (ZPPtr3),y save CS hMem in S.PS
|
2017-09-12 06:20:24 +00:00
|
|
|
|
|
2018-09-19 15:25:42 +00:00
|
|
|
|
* jsr K.GetMemByID
|
|
|
|
|
* jsr PS.SetMemOwner Set Ownership
|
2017-10-09 15:30:48 +00:00
|
|
|
|
|
2018-09-19 15:25:42 +00:00
|
|
|
|
ldy #H.BIN.F Get Bin S.PS.F
|
|
|
|
|
lda (ZPPtr4),y
|
|
|
|
|
beq .1
|
|
|
|
|
|
|
|
|
|
ldy #S.PS.F update PS S.PS.F
|
|
|
|
|
ora (ZPPtr3),y
|
|
|
|
|
sta (ZPPtr3),y
|
|
|
|
|
|
|
|
|
|
.1 ldy #H.BIN.DS.SIZE+1
|
2017-01-12 17:43:45 +00:00
|
|
|
|
lda (ZPPtr4),y Load DS.SIZE HI
|
2016-08-17 06:25:58 +00:00
|
|
|
|
tax
|
|
|
|
|
dey
|
2017-01-12 17:43:45 +00:00
|
|
|
|
ora (ZPPtr4),y
|
2017-09-12 06:20:24 +00:00
|
|
|
|
|
2016-08-17 06:25:58 +00:00
|
|
|
|
beq .2 DS.SIZE=0...
|
2017-09-12 06:20:24 +00:00
|
|
|
|
|
2017-07-01 13:44:40 +00:00
|
|
|
|
lda (ZPPtr4),y
|
|
|
|
|
tay
|
|
|
|
|
txa Y,A = DS.SIZE
|
2018-08-11 10:57:57 +00:00
|
|
|
|
ldx #S.MEM.F.INIT0+S.MEM.F.DATA
|
|
|
|
|
jsr MEM.GetMem.YAX
|
2016-08-17 06:25:58 +00:00
|
|
|
|
bcs .9
|
2017-09-12 06:20:24 +00:00
|
|
|
|
|
2017-09-20 15:09:55 +00:00
|
|
|
|
phy
|
2018-04-10 15:03:29 +00:00
|
|
|
|
ldy #S.PS.ZP.DATA+1
|
2017-09-20 15:09:55 +00:00
|
|
|
|
sta (ZPPtr3),y save pData HI...
|
|
|
|
|
dey
|
|
|
|
|
pla
|
|
|
|
|
sta (ZPPtr3),y save pData LO...
|
|
|
|
|
|
2016-08-17 06:25:58 +00:00
|
|
|
|
txa
|
|
|
|
|
ldy #S.PS.hDS
|
2017-09-20 15:09:55 +00:00
|
|
|
|
sta (ZPPtr3),y save DS hMem in S.PS
|
2017-09-12 06:20:24 +00:00
|
|
|
|
|
2018-10-17 15:31:29 +00:00
|
|
|
|
jsr PS.SetMemOwner Set Ownership
|
2017-10-09 05:51:32 +00:00
|
|
|
|
|
2018-07-05 05:42:16 +00:00
|
|
|
|
.2 ldy #H.BIN.SS.SIZE
|
2017-09-20 15:09:55 +00:00
|
|
|
|
lda (ZPPtr4),y Load SS.SIZE
|
2018-04-26 15:38:02 +00:00
|
|
|
|
|
2018-04-10 15:03:29 +00:00
|
|
|
|
ldy #S.PS.ZP.STACK
|
2017-09-20 15:09:55 +00:00
|
|
|
|
sta (ZPPtr3),y save pStack LO...
|
2017-09-12 15:24:36 +00:00
|
|
|
|
|
2017-09-20 15:09:55 +00:00
|
|
|
|
tay
|
2017-09-12 06:20:24 +00:00
|
|
|
|
|
2017-09-12 15:24:36 +00:00
|
|
|
|
bne .3 SS.SIZE.LO=0, set as default $100
|
2017-09-20 15:09:55 +00:00
|
|
|
|
lda #1 SS.SIZE.HI
|
|
|
|
|
.HS 2C bit abs
|
|
|
|
|
.3 lda #0
|
2017-09-12 15:24:36 +00:00
|
|
|
|
|
2018-08-11 10:57:57 +00:00
|
|
|
|
ldx #S.MEM.F.ALIGN+S.MEM.F.STACK
|
2018-01-17 16:31:32 +00:00
|
|
|
|
jsr MEM.GetMem.YAX
|
2017-08-28 15:35:10 +00:00
|
|
|
|
bcs .9
|
2017-09-12 06:20:24 +00:00
|
|
|
|
|
2018-04-10 15:03:29 +00:00
|
|
|
|
ldy #S.PS.ZP.STACK+1
|
2018-12-18 16:46:31 +00:00
|
|
|
|
sta (ZPPtr3),y save pStack HI...(LO already set to Stack TOP)
|
2017-09-20 15:09:55 +00:00
|
|
|
|
|
2017-08-28 15:35:10 +00:00
|
|
|
|
txa
|
|
|
|
|
ldy #S.PS.hSS
|
2017-09-20 15:09:55 +00:00
|
|
|
|
sta (ZPPtr3),y save SS hMem in S.PS
|
2017-08-28 15:35:10 +00:00
|
|
|
|
|
2018-04-10 15:03:29 +00:00
|
|
|
|
jsr PS.SetMemOwner Set Ownership
|
2017-10-09 05:51:32 +00:00
|
|
|
|
|
2018-07-05 05:42:16 +00:00
|
|
|
|
ldy #H.BIN.ZP.SIZE
|
2018-04-10 15:03:29 +00:00
|
|
|
|
lda (ZPPtr4),y
|
|
|
|
|
clc
|
|
|
|
|
adc #8 Add room for 4 saved PTR
|
|
|
|
|
ldy #S.PS.ZP.SIZE
|
|
|
|
|
sta (ZPPtr3),y
|
|
|
|
|
|
2016-08-18 15:26:11 +00:00
|
|
|
|
clc
|
|
|
|
|
.9 rts
|
2016-08-17 06:25:58 +00:00
|
|
|
|
*--------------------------------------
|
2018-11-22 16:39:41 +00:00
|
|
|
|
PS.LoadGetHeader
|
|
|
|
|
>PUSHWI 0 Aux type
|
|
|
|
|
>PUSHBI S.FI.T.TXT
|
|
|
|
|
>PUSHBI O.RDONLY
|
|
|
|
|
>LDYA PS.ArgV
|
|
|
|
|
>SYSCALL fopen
|
2018-11-23 16:20:19 +00:00
|
|
|
|
bcs PS.LoadGetHeader.RTS
|
2018-11-22 16:39:41 +00:00
|
|
|
|
sta .1+1
|
2018-12-03 12:32:46 +00:00
|
|
|
|
|
2018-11-22 16:39:41 +00:00
|
|
|
|
>PUSHWI 128
|
|
|
|
|
>PUSHWI K.IOBuf+128
|
|
|
|
|
.1 lda #$ff SELF MODIFIED
|
2018-12-03 12:32:46 +00:00
|
|
|
|
>SYSCALL fread
|
2018-11-22 16:39:41 +00:00
|
|
|
|
|
|
|
|
|
php
|
|
|
|
|
pha
|
|
|
|
|
lda .1+1
|
|
|
|
|
>SYSCALL fclose
|
|
|
|
|
pla
|
|
|
|
|
plp
|
2018-11-23 16:20:19 +00:00
|
|
|
|
PS.LoadGetHeader.RTS
|
|
|
|
|
rts
|
2018-11-22 16:39:41 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
PS.Load.ROOT .AZ "ROOT"
|
|
|
|
|
PS.Load.HEADER .AZ "#!/"
|
|
|
|
|
*--------------------------------------
|
2018-12-20 16:23:43 +00:00
|
|
|
|
* PS.DupEnv
|
|
|
|
|
* In:
|
|
|
|
|
* A = ENV hMem To Duplicate
|
|
|
|
|
* Out:
|
|
|
|
|
* A = hMem to new ENV
|
|
|
|
|
* X = Count
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
PS.DupEnv jsr K.GetMemPtr
|
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
|
|
|
|
|
>LDYAI K.ENV.SIZE
|
|
|
|
|
|
|
|
|
|
jsr K.GetMem
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
>STYA ZPPtr2 Target Buffer
|
|
|
|
|
phx save hMem
|
|
|
|
|
|
|
|
|
|
jsr PS.SetMemOwner Set Ownership
|
|
|
|
|
|
|
|
|
|
jsr PS.AddPtr1ToStrVUntil0
|
|
|
|
|
|
|
|
|
|
pla hMem
|
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
2018-11-23 07:02:00 +00:00
|
|
|
|
* hBIN + PS.ArgV -> #S.PS.hARGV
|
|
|
|
|
*--------------------------------------
|
2019-01-04 13:17:31 +00:00
|
|
|
|
PS.AddArgV stz PS.ArgSize
|
|
|
|
|
stz PS.ArgSize+1
|
2018-11-28 14:58:42 +00:00
|
|
|
|
|
|
|
|
|
lda K.IOBuf
|
2018-11-23 07:02:00 +00:00
|
|
|
|
beq .10
|
|
|
|
|
|
2018-11-28 14:58:42 +00:00
|
|
|
|
>LDYAI K.IOBuf
|
2018-11-23 16:20:19 +00:00
|
|
|
|
jsr K.strlen
|
|
|
|
|
iny +1 for \0
|
2019-01-04 13:17:31 +00:00
|
|
|
|
>STYA PS.ArgSize
|
2018-11-23 16:20:19 +00:00
|
|
|
|
ldx #0 ARGC-1
|
|
|
|
|
.HS 2C
|
2018-11-23 07:02:00 +00:00
|
|
|
|
|
2018-11-23 16:20:19 +00:00
|
|
|
|
.10 ldx #$ff ARGC-1
|
2018-11-23 07:02:00 +00:00
|
|
|
|
>LDYA PS.ArgV
|
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
|
2018-11-23 16:20:19 +00:00
|
|
|
|
.1 lda (ZPPtr1)
|
2018-11-23 07:02:00 +00:00
|
|
|
|
beq .4
|
|
|
|
|
|
2018-11-23 16:20:19 +00:00
|
|
|
|
inx
|
|
|
|
|
|
2018-11-23 07:02:00 +00:00
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
|
|
.2 iny
|
2018-11-23 16:20:19 +00:00
|
|
|
|
lda (ZPPtr1),y
|
2018-11-23 07:02:00 +00:00
|
|
|
|
bne .2
|
|
|
|
|
|
|
|
|
|
tya
|
|
|
|
|
sec
|
2019-01-04 13:17:31 +00:00
|
|
|
|
adc PS.ArgSize
|
|
|
|
|
sta PS.ArgSize
|
2018-11-23 07:02:00 +00:00
|
|
|
|
bcc .3
|
|
|
|
|
|
2019-01-04 13:17:31 +00:00
|
|
|
|
inc PS.ArgSize+1
|
2018-11-23 07:02:00 +00:00
|
|
|
|
|
2018-12-20 16:23:43 +00:00
|
|
|
|
.3 jsr MEM.AddYp1ToPtr1
|
2018-11-23 07:02:00 +00:00
|
|
|
|
bra .1
|
|
|
|
|
|
2018-11-23 16:20:19 +00:00
|
|
|
|
.4 txa
|
|
|
|
|
ldy #S.PS.ARGC
|
|
|
|
|
sta (ZPPtr3),y
|
|
|
|
|
|
2019-01-04 13:17:31 +00:00
|
|
|
|
>LDYA PS.ArgSize Add 1 for ending 0
|
2018-11-23 07:02:00 +00:00
|
|
|
|
iny
|
|
|
|
|
bne .5
|
|
|
|
|
inc
|
|
|
|
|
|
2018-11-23 16:20:19 +00:00
|
|
|
|
.5 jsr K.GetMem
|
2018-12-20 16:23:43 +00:00
|
|
|
|
bcs PS.AddPtr1ToStrV.8
|
2018-11-23 07:02:00 +00:00
|
|
|
|
|
2018-11-23 16:20:19 +00:00
|
|
|
|
>STYA ZPPtr2 Target Buffer
|
2018-11-22 16:39:41 +00:00
|
|
|
|
txa
|
2018-11-23 16:20:19 +00:00
|
|
|
|
ldy #S.PS.hARGV
|
2018-11-22 16:39:41 +00:00
|
|
|
|
sta (ZPPtr3),y
|
2018-10-15 15:39:21 +00:00
|
|
|
|
|
2018-11-28 14:58:42 +00:00
|
|
|
|
lda K.IOBuf
|
2018-11-23 16:20:19 +00:00
|
|
|
|
beq .6
|
2018-10-12 15:47:57 +00:00
|
|
|
|
|
2018-11-28 14:58:42 +00:00
|
|
|
|
>LDYAI K.IOBuf
|
2018-11-23 16:20:19 +00:00
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
jsr PS.AddPtr1ToStrV
|
2018-10-12 15:47:57 +00:00
|
|
|
|
|
2018-11-23 16:20:19 +00:00
|
|
|
|
.6 >LDYA PS.ArgV
|
|
|
|
|
>STYA ZPPtr1
|
2018-10-11 15:23:06 +00:00
|
|
|
|
*--------------------------------------
|
2018-12-20 16:23:43 +00:00
|
|
|
|
PS.AddPtr1ToStrVUntil0
|
2018-10-15 06:25:40 +00:00
|
|
|
|
.1 lda (ZPPtr1)
|
|
|
|
|
sta (ZPPtr2)
|
2018-12-20 16:23:43 +00:00
|
|
|
|
beq PS.AddPtr1ToStrV.8 Ending \0
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2018-11-23 16:20:19 +00:00
|
|
|
|
jsr PS.AddPtr1ToStrV
|
|
|
|
|
bra .1
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
PS.AddPtr1ToStrV
|
2018-12-03 12:32:46 +00:00
|
|
|
|
ldy #$ff
|
2017-09-14 15:21:06 +00:00
|
|
|
|
|
2018-10-15 06:25:40 +00:00
|
|
|
|
.2 iny
|
|
|
|
|
lda (ZPPtr1),y
|
2017-09-14 15:21:06 +00:00
|
|
|
|
sta (ZPPtr2),y
|
|
|
|
|
bne .2
|
|
|
|
|
|
2018-12-20 16:23:43 +00:00
|
|
|
|
jsr MEM.AddYp1ToPtr1
|
2018-10-15 06:25:40 +00:00
|
|
|
|
|
2018-11-23 16:20:19 +00:00
|
|
|
|
tya
|
2018-10-15 06:25:40 +00:00
|
|
|
|
sec
|
|
|
|
|
adc ZPPtr2
|
|
|
|
|
sta ZPPtr2
|
2018-12-20 16:23:43 +00:00
|
|
|
|
bcc PS.AddPtr1ToStrV.8
|
2017-01-12 17:43:45 +00:00
|
|
|
|
inc ZPPtr2+1
|
2018-11-23 16:20:19 +00:00
|
|
|
|
|
2018-12-20 16:23:43 +00:00
|
|
|
|
PS.AddPtr1ToStrV.8
|
|
|
|
|
rts
|
2017-08-29 15:19:09 +00:00
|
|
|
|
*--------------------------------------
|
2017-10-27 14:56:46 +00:00
|
|
|
|
PS.SetMemOwner lda CORE.LastPSID
|
2017-10-09 15:30:48 +00:00
|
|
|
|
ldy #S.MEM.OWNERPID
|
|
|
|
|
sta (ZPMEMMGR),y
|
|
|
|
|
rts
|
2018-05-07 14:59:51 +00:00
|
|
|
|
*/--------------------------------------
|
2018-12-04 13:20:35 +00:00
|
|
|
|
* # ExecL
|
|
|
|
|
* ## C
|
|
|
|
|
* `int kill(short int pid, short int sig);`
|
|
|
|
|
* ## ASM
|
|
|
|
|
* `>PUSHB sig`
|
|
|
|
|
* `lda pid`
|
|
|
|
|
* `>SYSCALL kill`
|
|
|
|
|
* ## RETURN VALUE
|
|
|
|
|
* A = Child PSID
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
K.Kill cmp #0
|
|
|
|
|
beq .99 CS
|
|
|
|
|
|
|
|
|
|
jsr CORE.GetPSByID
|
|
|
|
|
bcs .99
|
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
|
|
|
|
|
>PULLA
|
|
|
|
|
cmp #2
|
|
|
|
|
bcs .9
|
|
|
|
|
asl
|
|
|
|
|
tax
|
|
|
|
|
jmp (.1,x)
|
|
|
|
|
|
|
|
|
|
.1 .DA K.Kill.0
|
|
|
|
|
.DA K.Kill.1
|
|
|
|
|
|
|
|
|
|
.9 lda #E.SYN
|
|
|
|
|
* sec
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.99 >RET 1
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
K.Kill.1 lda (ZPPtr1)
|
|
|
|
|
|
|
|
|
|
and #$33
|
|
|
|
|
ora #S.PS.F.QUIT
|
|
|
|
|
sta (ZPPtr1)
|
|
|
|
|
|
2018-12-18 14:37:07 +00:00
|
|
|
|
K.Kill.0
|
2018-12-04 13:20:35 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
2017-09-21 06:35:44 +00:00
|
|
|
|
*--------------------------------------
|
2016-08-17 06:25:58 +00:00
|
|
|
|
MAN
|
2018-11-17 17:17:13 +00:00
|
|
|
|
SAVE USR/SRC/SYS/KERNEL.S.PS
|
|
|
|
|
LOAD USR/SRC/SYS/KERNEL.S
|
2016-08-17 06:25:58 +00:00
|
|
|
|
ASM
|