A2osX/BIN/SH.S.CORE.txt

785 lines
14 KiB
Plaintext
Raw Normal View History

2019-01-28 16:33:30 +00:00
NEW
2019-04-15 05:40:13 +00:00
AUTO 3,1
2019-01-28 16:33:30 +00:00
.LIST OFF
*--------------------------------------
2020-01-20 15:24:53 +00:00
CORE.Init lda #PUSHD.STACK
2020-01-18 19:37:32 +00:00
>STA.G PUSHD.STACK
2019-10-03 06:25:27 +00:00
.9 rts
2019-01-31 16:34:02 +00:00
*--------------------------------------
2019-04-01 15:24:01 +00:00
CORE.FUNCRESET >LDA.G hFuncList
2019-07-31 15:10:59 +00:00
beq .8
2019-04-01 15:24:01 +00:00
>SYSCALL SListFree
>STZ.G hFuncList
2019-08-15 12:48:58 +00:00
.8 rts
2019-08-05 13:30:58 +00:00
*--------------------------------------
2019-08-15 12:48:58 +00:00
CORE.Load.YAX stx M32.ACC X = Code to Execute
2019-08-05 13:30:58 +00:00
2020-01-09 15:54:14 +00:00
>SYSCALL StrVDup Y,A = ArgV
2019-08-15 12:48:58 +00:00
bcs .9
2019-09-08 12:09:47 +00:00
2019-08-15 12:48:58 +00:00
stx M32.ACC+1 X = hARGV
2019-09-08 12:09:47 +00:00
sta M32.ACC+2 A = ARGC
2019-08-05 13:30:58 +00:00
lda #8
jsr CORE.StkCheck
2019-08-15 12:48:58 +00:00
bcs .9
2020-02-02 18:24:40 +00:00
2019-08-05 13:30:58 +00:00
>LDYA ZPInputBuf
jsr CORE.StkPushYA
2020-01-06 16:27:52 +00:00
jsr CORE.StkPushInputBufPtr
2019-08-05 13:30:58 +00:00
ldy #S.PS.ARGC
lda (pPS),y
jsr CORE.StkPush old ARGC
ldy #S.PS.hARGV
lda (pPS),y
2019-08-15 12:48:58 +00:00
jsr CORE.StkPush old hARGV
2019-08-05 13:30:58 +00:00
ldy #S.PS.ARGC
lda M32.ACC+2 new ARGC
2020-01-09 15:54:14 +00:00
dec Skip ARG0 in count
2019-08-05 13:30:58 +00:00
sta (pPS),y
2020-01-09 15:54:14 +00:00
2019-08-05 13:30:58 +00:00
iny #S.PS.hARGV
2020-01-09 15:54:14 +00:00
2019-08-05 13:30:58 +00:00
lda M32.ACC+1
2019-08-15 12:48:58 +00:00
sta (pPS),y new hARGV
2019-08-05 13:30:58 +00:00
lda M32.ACC new code
jsr CORE.StkPush
2019-08-15 12:48:58 +00:00
* lda M32.ACC
2019-08-05 13:30:58 +00:00
>SYSCALL GetMemPtr
>STYA ZPInputBuf
>STYA ZPInputBufPtr
2019-08-15 12:48:58 +00:00
* clc
.9 rts
2019-01-28 16:33:30 +00:00
*--------------------------------------
2019-02-14 14:51:24 +00:00
* http://heirloom.sourceforge.net/sh/sh.1.html
*--------------------------------------
2020-01-20 15:24:53 +00:00
* CORE.Run
* Input : ZPInputBufPtr (String)
2019-02-03 21:58:26 +00:00
* Tokenize ZPArgVBuf
2019-02-01 16:32:29 +00:00
* :LOOP
* if CmdSep=| :
* set hStdIn = hStdOut
* set hStdOut = Std
* GetCmd from line until | or EOL
* if CmdSep=| :
* create PIPE
* set hStdOut -> PIPE
* CORE.Exec &
* :LOOP
* else CORE.Exec
*--------------------------------------
* SET VAR = `cmd args`, FOR VAR IN `cmd args`
* create PIPE
* set hStdOut -> PIPE
* CORE.Exec `cmd args` &
* set READMODE
* set hStdIn = hStdOut
* set hStdOut = Std
*--------------------------------------
2019-08-12 07:40:16 +00:00
CORE.Run.EOF jsr CORE.StkPull
2019-08-15 12:48:58 +00:00
bcs *
cmp #$C0+C.. check CALL . CL context
beq .1
cmp #$C0+C.CALL
beq .1
cmp #$C0+C.CLEXEC
2019-08-12 07:40:16 +00:00
bne .9
2019-08-15 12:48:58 +00:00
.1 jsr CMD.EXIT.FILE
2019-08-12 07:40:16 +00:00
jsr IO.Reset
lda #0
sec
2020-01-20 15:24:53 +00:00
jmp CORE.Run.Exit Ending 0, CS,A=0
2019-11-30 13:37:55 +00:00
2019-08-15 12:48:58 +00:00
.9 lda #E.UNEXPEOF
2019-08-12 07:40:16 +00:00
sec
2020-01-20 15:24:53 +00:00
jmp CORE.Run.Exit
CORE.Run.RTS rts
2019-08-12 07:40:16 +00:00
*--------------------------------------
2019-10-26 14:33:37 +00:00
CORE.Run jsr IO.Reset
2020-01-20 16:34:59 +00:00
>LDYAI 256
2020-01-20 15:24:53 +00:00
>SYSCALL GetMem
bcs CORE.Run.RTS
>STYA ZPArgVBuf
txa
>STA.G CORE.hArgVBuf
2019-10-26 14:33:37 +00:00
clc
.HS B0 BCS
CORE.Run.1 sec coming from PIPE OUT
ror
>STA.G CORE.bPipeIn
2020-01-20 15:24:53 +00:00
>LDYA ZPInputBufPtr Save Actual ptr for looping
2019-02-07 16:52:25 +00:00
>STYA ZPInputCmdPtr
2020-01-20 15:24:53 +00:00
>LDYA ZPArgVBuf Reset ArgV Buffer
2019-02-08 16:13:43 +00:00
>STYA ZPArgVBufPtr
2019-10-26 14:33:37 +00:00
2020-01-20 15:24:53 +00:00
lda #0
2019-02-11 16:44:56 +00:00
sta (ZPArgVBuf)
2020-01-20 16:34:59 +00:00
2020-01-20 15:24:53 +00:00
sec
ror CORE.IntCmd assume external
2019-10-26 14:33:37 +00:00
2019-04-15 05:40:13 +00:00
lda #S.PS.F.HOLD
2019-08-12 07:40:16 +00:00
sta CORE.PSFlags
2019-10-25 15:09:13 +00:00
2020-01-20 15:24:53 +00:00
jsr CORE.GetCharNB
2019-08-12 07:40:16 +00:00
bcs CORE.Run.EOF
2019-10-25 15:09:13 +00:00
2019-10-26 14:33:37 +00:00
cmp #C.CR empty line ?
2019-03-14 16:51:02 +00:00
bne .33
jsr CORE.GetNextChar skip CR...
bra .8
2019-10-25 15:09:13 +00:00
2019-03-14 16:51:02 +00:00
.33 cmp #'#' commented line?
2019-08-12 07:40:16 +00:00
bne .4
2019-02-07 16:52:25 +00:00
2019-03-14 16:51:02 +00:00
.12 jsr CORE.SkipLine
2019-02-11 16:44:56 +00:00
2019-10-26 14:33:37 +00:00
.8 lda #0
2019-02-14 14:51:24 +00:00
clc
2020-01-20 15:24:53 +00:00
.9 jmp CORE.Run.Exit EOL, CS,A=0
2019-10-25 15:09:13 +00:00
2019-02-11 06:58:33 +00:00
.4 >LDYA L.CMD internal command ?
2019-02-11 16:44:56 +00:00
jsr CORE.LookupInputBuf
2019-03-02 20:47:58 +00:00
bcc .41
2019-11-30 13:37:55 +00:00
2019-03-15 16:20:28 +00:00
.40 jsr CORE.ArgV.Add external cmd, go check context
2019-03-02 20:47:58 +00:00
bra .42
2019-11-30 13:37:55 +00:00
.41 stx CORE.IntCmd
asl CORE.IntCmd
jsr CORE.SkipCharsA
2019-03-04 16:44:33 +00:00
.42 jsr CORE.StkGet
2019-03-15 16:20:28 +00:00
bcs CORE.Run.7 no particular context, exec...
2019-11-30 13:37:55 +00:00
2019-03-04 16:44:33 +00:00
tax
2019-07-31 15:10:59 +00:00
lda CORE.IntCmd
2019-03-04 16:44:33 +00:00
bmi .45
2019-11-30 13:37:55 +00:00
2019-03-04 16:46:46 +00:00
and #$3F
2019-03-12 16:50:16 +00:00
cmp #C.SWITCH SWITCH....FI ?
2019-03-15 16:20:28 +00:00
bcs CORE.Run.7
2019-03-02 20:47:58 +00:00
2019-03-04 16:44:33 +00:00
.45 txa
bpl .43 context is FALSE, skip line
2019-10-03 06:25:27 +00:00
asl
2019-03-15 16:20:28 +00:00
bmi CORE.Run.7 parent context is true, exec
2019-03-04 22:20:26 +00:00
.43 jsr CORE.GetCharNB
2019-03-02 20:47:58 +00:00
bcs .44 EOF
cmp #C.CR
beq .44
cmp #';' TODO ";"
2019-03-04 22:20:26 +00:00
beq .44
jsr CORE.GetNextChar
bra .43
2019-11-30 13:37:55 +00:00
2019-03-02 20:47:58 +00:00
.44 jsr CORE.GetNextCharNB Skip EoL char
clc
2020-01-20 15:24:53 +00:00
jmp CORE.Run.Exit
2019-03-14 16:51:02 +00:00
*--------------------------------------
2019-03-15 16:20:28 +00:00
CORE.Run.5 >LDYA L.CORE.IO
2019-02-11 16:44:56 +00:00
jsr CORE.LookupInputBuf
2019-03-15 16:20:28 +00:00
bcs CORE.Run.6
2019-02-18 12:52:10 +00:00
2019-02-11 16:44:56 +00:00
jsr CORE.SkipCharsA
2019-02-11 06:58:33 +00:00
jsr CORE.IO.JMP
2020-01-12 20:38:33 +00:00
bcc CORE.Run.7
2020-01-20 15:24:53 +00:00
jmp CORE.Run.Exit
2019-10-25 15:09:13 +00:00
2019-03-15 16:20:28 +00:00
CORE.Run.6 jsr CORE.ArgV.Add
2019-10-25 15:09:13 +00:00
2019-03-15 16:20:28 +00:00
CORE.Run.7 jsr CORE.GetCharNB
2019-10-26 14:33:37 +00:00
bcs .2 Nothing to skip
2019-02-11 06:58:33 +00:00
jsr CORE.IsEndCmd
2019-03-15 16:20:28 +00:00
bcs CORE.Run.5
2019-10-25 15:09:13 +00:00
2019-10-26 14:33:37 +00:00
tax
jsr CORE.GetNextCharNB Skip EoL char
cpx #'|' Pipe OUT ?
bne .2
sec
.1 .HS 90 BCC
.2 clc
ror
>STA.G CORE.bPipeOut
2019-10-25 15:09:13 +00:00
2019-10-26 14:33:37 +00:00
>LDA.G CORE.bPipeIn
bpl .3
jsr IO.Pipe.In
2020-01-20 15:24:53 +00:00
bcs CORE.Run.Exit
2019-10-26 14:33:37 +00:00
.3 >LDA.G CORE.bPipeOut
2020-01-20 15:24:53 +00:00
bpl .7
2019-10-26 14:33:37 +00:00
2019-02-11 06:58:33 +00:00
jsr IO.Pipe.Out
2020-01-20 15:24:53 +00:00
bcs CORE.Run.Exit
2019-02-18 12:52:10 +00:00
2019-10-26 14:33:37 +00:00
lda #S.PS.F.HOLD Run in the background...
trb CORE.PSFlags
lda #S.PS.F.CLOSEONX ...and close PIPE OUT on exit
tsb CORE.PSFlags
jsr CORE.ExecCmd
2019-10-25 15:09:13 +00:00
php
pha
2019-10-31 10:30:27 +00:00
lda CORE.IntCmd $ff if external
eor #$80
asl if cc Was external...
jsr IO.Reset.OutC restore Output, NO close if EXTERNAL
2019-10-26 14:33:37 +00:00
>LDA.G CORE.bPipeIn
2019-10-31 10:30:27 +00:00
bpl .6
2019-10-26 14:33:37 +00:00
jsr IO.Pop.In restore Input
2019-10-31 10:30:27 +00:00
.6 pla
2019-10-25 15:09:13 +00:00
plp
2020-01-20 15:24:53 +00:00
bcs CORE.Run.Exit
2019-10-26 14:33:37 +00:00
jmp CORE.Run.1 Loop with Pipe IN
2020-01-20 15:24:53 +00:00
.7 jsr CORE.ExecCmd
*--------------------------------------
CORE.Run.Exit php
pha
>LDA.G CORE.hArgVBuf
2020-01-20 16:34:59 +00:00
beq .1
2020-01-20 15:24:53 +00:00
>SYSCALL freemem
>STZ.G CORE.hArgVBuf
2020-01-20 16:34:59 +00:00
.1 pla
2020-01-20 15:24:53 +00:00
plp
rts
2019-02-07 16:52:25 +00:00
*--------------------------------------
2019-02-11 06:58:33 +00:00
* Input : ZPArgVBuf
*--------------------------------------
2019-10-26 14:33:37 +00:00
CORE.ExecCmd lda #0
2019-02-11 16:44:56 +00:00
sta (ZPArgVBufPtr)
2019-03-02 20:47:58 +00:00
>LDYA ZPArgVBuf
2019-02-11 16:44:56 +00:00
>STYA ZPArgVBufPtr
2019-02-11 06:58:33 +00:00
2020-01-20 15:24:53 +00:00
ldx CORE.IntCmd
2019-02-11 06:58:33 +00:00
bmi CORE.ExecExtCmd
2019-11-30 13:37:55 +00:00
2019-02-11 06:58:33 +00:00
jmp (J.CMD,x)
2019-10-12 14:20:09 +00:00
2019-08-12 07:40:16 +00:00
CORE.ExecExtCmd >PUSHB CORE.PSFlags
2019-10-12 14:20:09 +00:00
2019-02-18 12:52:10 +00:00
>LDYA ZPArgVBuf
2019-02-01 16:32:29 +00:00
>SYSCALL execv
2019-01-28 16:33:30 +00:00
bcs .9
2019-10-12 14:20:09 +00:00
2019-02-01 16:32:29 +00:00
tax CPID
2019-08-12 07:40:16 +00:00
lda CORE.PSFlags
2019-02-01 16:32:29 +00:00
and #S.PS.F.HOLD
bne .4
2019-10-25 15:09:13 +00:00
2019-10-31 15:59:11 +00:00
>LDA.G CORE.bPipeOut
bmi .4
2019-02-01 16:32:29 +00:00
txa
>PUSHA
>PUSHBI 1
2019-02-25 14:47:31 +00:00
>PUSHW L.MSG.PID
2019-10-26 14:33:37 +00:00
jmp IO.PrintErr
2019-10-25 15:09:13 +00:00
2019-02-01 16:32:29 +00:00
.4 >SLEEP Suspend this PID
sec
ldy #S.PS.RC CPID will update S.PS.RC
lda (pPs),y
bne .9
2019-10-25 15:09:13 +00:00
2019-02-01 16:32:29 +00:00
.8 clc
.9 rts
*--------------------------------------
2019-03-14 16:51:02 +00:00
CORE.SkipLine jsr CORE.GetNextCharNB
bcs .8 EOF
cmp #C.CR EOL
bne CORE.SkipLine
jsr CORE.GetNextChar skip CR...
.8 rts
*--------------------------------------
2019-02-11 16:44:56 +00:00
* search ZPInputBufPtr/ZPArgVBufPtr in Y,A table
2019-02-07 16:52:25 +00:00
*--------------------------------------
2019-02-11 16:44:56 +00:00
CORE.LookupInputBuf
2019-08-15 12:48:58 +00:00
sec
.HS 90 BCC
CORE.LookupArgVBuf
clc
>STYA ZPPtr1 Keywords table
2019-02-11 16:44:56 +00:00
>LDYA ZPArgVBufPtr
2019-08-15 12:48:58 +00:00
bcc CORE.Lookup
>LDYA ZPInputBufPtr
2019-02-11 16:44:56 +00:00
CORE.Lookup >STYA ZPPtr2
2019-02-07 16:52:25 +00:00
ldx #0
2019-11-30 13:37:55 +00:00
2019-02-11 16:44:56 +00:00
.1 ldy #$ff
2019-11-30 13:37:55 +00:00
2019-08-15 12:48:58 +00:00
.2 jsr .7 get next valid char in src text
bcs .3
2019-11-30 13:37:55 +00:00
2019-08-15 12:48:58 +00:00
.20 jsr ToUpperCase
eor (ZPPtr1),y match table char ?
asl compare only 7 bits
bne .4 no match...get next table keyword
bcc .2 not last char in this keyword
jsr .7 next char in text...
bcc .4 valid....failed
.8 tya Keyword Len
2019-02-07 16:52:25 +00:00
2019-02-11 16:44:56 +00:00
clc
2019-08-15 12:48:58 +00:00
rts
.3 dey
lda (ZPPtr1),y was last char in this keyword ?
bmi .8
2019-11-30 13:37:55 +00:00
2019-08-15 12:48:58 +00:00
iny
.41 jsr IncPtr1 skip chars to next keyword
2019-02-07 16:52:25 +00:00
2019-08-15 12:48:58 +00:00
.4 lda (ZPPtr1)
bpl .41
2019-07-31 15:10:59 +00:00
jsr IncPtr1
2019-11-30 13:37:55 +00:00
2019-02-11 16:44:56 +00:00
.6 inx
2019-08-15 12:48:58 +00:00
lda (ZPPtr1) Array Ending 0, lookup failed
2019-02-07 16:52:25 +00:00
bne .1
2020-01-11 17:13:27 +00:00
2019-03-05 16:49:34 +00:00
lda #E.SYN
2020-01-11 17:13:27 +00:00
.9 sec
2019-02-11 06:58:33 +00:00
rts
2020-01-06 07:03:37 +00:00
2019-08-15 12:48:58 +00:00
.7 iny
lda (ZPPtr2),y Get Src text char...
beq .9 end of text
jsr CORE.IsSpaceOrEndCmd
bcc .9 end of valid chars
clc
rts
2019-02-11 06:58:33 +00:00
*--------------------------------------
* ArgV
*--------------------------------------
2020-01-13 13:33:30 +00:00
CORE.ArgV.Add lda #C.SPACE
2019-07-31 15:10:59 +00:00
sta ZPTmpW
2020-01-13 13:33:30 +00:00
ldy #0
2019-02-12 16:47:34 +00:00
jsr CORE.GetCharNB
bcs .9
2019-02-15 16:38:17 +00:00
cmp #'"'
bne .10
2020-01-13 13:33:30 +00:00
2019-07-31 15:10:59 +00:00
sta ZPTmpW
2019-02-15 16:38:17 +00:00
bra .1
2020-01-13 13:33:30 +00:00
2019-03-07 16:48:30 +00:00
.10 cmp #'('
2019-02-15 16:38:17 +00:00
bne .11
2020-01-13 13:33:30 +00:00
2019-03-07 20:40:06 +00:00
ldx #')'
2019-07-31 15:10:59 +00:00
stx ZPTmpW
2019-03-07 20:40:06 +00:00
2019-03-07 16:48:30 +00:00
bra .12
.11 cmp #'`'
bne .12
2019-07-31 15:10:59 +00:00
sta ZPTmpW
2020-01-13 13:33:30 +00:00
.12 sta (ZPArgVBufPtr),y
iny
2019-02-11 06:58:33 +00:00
2019-02-15 16:38:17 +00:00
.1 jsr CORE.GetNextChar
bcs .5
2020-01-13 13:33:30 +00:00
2019-07-31 15:10:59 +00:00
.2 cmp ZPTmpW
2019-02-18 16:05:40 +00:00
bne .3
2020-01-13 15:01:23 +00:00
2019-02-18 16:05:40 +00:00
jsr CORE.GetNextChar
bra .5
2019-02-11 06:58:33 +00:00
2020-01-13 13:33:30 +00:00
.3 ldx ZPTmpW
cpx #C.SPACE
2019-02-21 11:34:28 +00:00
bne .40
2020-01-13 13:33:30 +00:00
2019-02-21 11:34:28 +00:00
jsr CORE.IsEndCmd
bcc .5
2020-01-13 13:33:30 +00:00
.40 sta (ZPArgVBufPtr),y
iny
2019-02-11 06:58:33 +00:00
.4 jsr CORE.GetNextChar
2019-02-15 16:38:17 +00:00
bcc .2
2020-01-13 13:33:30 +00:00
2019-02-12 16:47:34 +00:00
.5 lda #0
2020-01-13 13:33:30 +00:00
sta (ZPArgVBufPtr),y
2019-02-12 16:47:34 +00:00
2020-01-13 13:33:30 +00:00
>LDYA ZPArgVBufPtr
2020-01-13 15:01:23 +00:00
>STYA ZPArgVBufPrev
2020-01-17 11:23:11 +00:00
>SYSCALL Expand
2019-02-12 16:47:34 +00:00
bcs .9
2020-01-13 13:33:30 +00:00
2019-02-12 16:47:34 +00:00
phx
>STYA ZPPtr1
ldy #$ff
2019-02-15 16:38:17 +00:00
.7 iny
2019-02-12 16:47:34 +00:00
lda (ZPPtr1),y
2020-01-13 13:33:30 +00:00
sta (ZPArgVBufPtr),y
bne .7
tya
2020-01-13 15:53:33 +00:00
beq .8 Empty string....
2020-01-13 13:33:30 +00:00
sec
adc ZPArgVBufPtr
sta ZPArgVBufPtr
bcc .8
inc ZPArgVBufPtr+1
.8 pla
2019-02-12 16:47:34 +00:00
>SYSCALL freemem
.9 rts
2019-02-11 06:58:33 +00:00
*--------------------------------------
CORE.ArgV.Next lda (ZPArgVBufPtr)
beq .8
2020-01-07 13:44:38 +00:00
2019-02-14 14:51:24 +00:00
>LDYA ZPArgVBufPtr
>STYA ZPArgVBufPrev
2020-01-07 13:44:38 +00:00
2019-02-11 06:58:33 +00:00
.1 jsr CORE.ArgV.NextChar
lda (ZPArgVBufPtr)
bne .1
2020-01-07 13:44:38 +00:00
2019-02-11 06:58:33 +00:00
jsr CORE.ArgV.NextChar
lda (ZPArgVBufPtr)
.8 rts
*--------------------------------------
2020-01-13 13:33:30 +00:00
CORE.ArgV.NextChar
inc ZPArgVBufPtr
bne .8
inc ZPArgVBufPtr+1
.8 rts
*--------------------------------------
2019-02-11 06:58:33 +00:00
* IO
*--------------------------------------
2019-04-01 06:07:56 +00:00
CORE.IO.JMP txa
asl
tax
jmp (J.CORE.IO,x)
2019-02-11 06:58:33 +00:00
2019-08-12 07:40:16 +00:00
CORE.IO.AMP lda #S.PS.F.HOLD
trb CORE.PSFlags
2019-02-11 06:58:33 +00:00
clc
CORE.IO.RTS rts
CORE.IO.IN lda #O.RDONLY+O.TEXT
jsr CORE.IO.Open
bcs CORE.IO.RTS
jmp IO.Set.In
CORE.IO.OUTA
CORE.IO.1OUTA lda #O.WRONLY+O.APPEND+O.CREATE+O.TEXT
bra CORE.IO.OUT.1
CORE.IO.OUT
CORE.IO.1OUT lda #O.WRONLY+O.TRUNC+O.CREATE+O.TEXT
CORE.IO.OUT.1 jsr CORE.IO.Open
bcs CORE.IO.RTS
jmp IO.Set.Out
CORE.IO.2OUTA lda #O.WRONLY+O.APPEND+O.CREATE+O.TEXT
bra CORE.IO.2OUT.1
CORE.IO.2OUT lda #O.WRONLY+O.TRUNC+O.CREATE+O.TEXT
CORE.IO.2OUT.1 jsr CORE.IO.Open
bcs CORE.IO.RTS
jmp IO.Set.Err
*--------------------------------------
CORE.IO.Open pha Open Mode
jsr CORE.GetCharNB
bcs .9 no arg left....
2019-02-18 12:52:10 +00:00
jsr CORE.ArgV.Add Get Filename
>LDYA ZPArgVBufPrev
>STYA ZPArgVBufPtr Discard filename
2019-08-02 14:36:49 +00:00
plx
jmp IO.FOpenYAX
2019-02-11 06:58:33 +00:00
.9 pla
2019-03-05 16:49:34 +00:00
lda #E.SYN
2019-02-11 06:58:33 +00:00
sec
2019-10-03 06:25:27 +00:00
rts
2019-02-11 06:58:33 +00:00
*--------------------------------------
* Input Buffer
2019-02-07 16:52:25 +00:00
*--------------------------------------
2019-02-08 16:13:43 +00:00
CORE.IsSpaceOrEndCmd
cmp #C.SPACE
beq CORE.IsEndCmd.8
2019-02-21 11:34:28 +00:00
CORE.IsEndCmd cmp #';'
2019-02-08 16:13:43 +00:00
beq CORE.IsEndCmd.8
2019-02-21 11:34:28 +00:00
cmp #C.CR
2019-02-08 16:13:43 +00:00
beq CORE.IsEndCmd.8
2019-02-07 16:52:25 +00:00
cmp #'|'
2019-02-08 16:13:43 +00:00
beq CORE.IsEndCmd.8
2019-02-07 16:52:25 +00:00
sec
rts
2019-02-08 16:13:43 +00:00
CORE.IsEndCmd.8 clc
2019-02-07 16:52:25 +00:00
rts
*--------------------------------------
CORE.GetCharNB jsr CORE.GetChar
bcs CORE.GetNextCharNB.RTS
jsr CORE.CheckCharNB
bcc CORE.GetNextCharNB.RTS
*--------------------------------------
CORE.GetNextCharNB
jsr CORE.GetNextChar
bcs CORE.GetNextCharNB.RTS
jsr CORE.CheckCharNB
bcs CORE.GetNextCharNB
CORE.GetNextCharNB.RTS
rts
*--------------------------------------
CORE.CheckCharNB
cmp #C.SPACE
beq .9
cmp #C.LF
beq .9
cmp #C.TAB
beq .9
clc
2019-10-03 06:25:27 +00:00
.9 rts
2019-02-07 16:52:25 +00:00
*--------------------------------------
CORE.GetNextChar
inc ZPInputBufPtr
bne CORE.GetChar
inc ZPInputBufPtr+1
*--------------------------------------
CORE.GetChar lda (ZPInputBufPtr)
beq .9
clc
rts
2019-01-28 16:33:30 +00:00
.9 sec
rts
*--------------------------------------
2019-02-11 16:44:56 +00:00
CORE.SkipCharsA clc
adc ZPInputBufPtr
sta ZPInputBufPtr
bcc .8
inc ZPInputBufPtr+1
2019-10-03 06:25:27 +00:00
.8 rts
2019-02-11 16:44:56 +00:00
*--------------------------------------
2019-02-11 06:58:33 +00:00
* Stack
*--------------------------------------
2019-11-30 13:37:55 +00:00
CORE.StkPopCtx jsr CORE.StkPull
CORE.StkPopCtxA and #$3F
cmp #C.IF
beq .8 IF : Nothing
ldx #2
cmp #C.WHILE WHILE : One Ptr = 2 bytes
beq CORE.StkPopX
cmp #C.SWITCH SWITCH : hValue
beq .2
ldx #1
cmp #C.CASE CASE : C.CASE + hValue
beq .1
2019-12-12 14:13:32 +00:00
cmp #C.FOR
beq .3
2019-11-30 13:37:55 +00:00
cmp #C.DEFAULT DEFAULT : C.DEFAULT + hValue
bne .9
2019-12-12 14:13:32 +00:00
2019-11-30 13:37:55 +00:00
.1 jsr CORE.StkPopX
2019-12-20 21:17:17 +00:00
.2 jsr CORE.StkPullFree
2019-11-30 13:37:55 +00:00
.8 clc
rts
2019-12-12 14:13:32 +00:00
.3 jsr CORE.StkPull Get FOR sub cmd
beq .4 FOR List
2019-12-20 21:17:17 +00:00
jsr CORE.StkPullFree hVARNAME
2019-12-12 14:13:32 +00:00
2019-12-20 21:17:17 +00:00
jsr CORE.StkPullFclose hFILE/hPIPE
2019-12-12 14:13:32 +00:00
ldx #2 CmdPtr
jmp CORE.StkPopX
2019-12-20 21:17:17 +00:00
.4 jsr CORE.StkPullFree hVARNAME
2019-12-12 14:13:32 +00:00
2019-12-20 21:17:17 +00:00
jsr CORE.StkPullFclose hFILE/hPIPE
2019-11-30 13:37:55 +00:00
2019-12-12 14:13:32 +00:00
ldx #4 ListPtr,CmdPtr
jmp CORE.StkPopX
2019-11-30 13:37:55 +00:00
.9 lda #E.STACKERROR
sec
rts
*--------------------------------------
CORE.StkPopX lda (pData)
.1 dec
dex
bne .1
sta (pData)
clc
rts
*--------------------------------------
2019-04-03 15:52:24 +00:00
CORE.StkCheck sec
adc (pData) StackPtr
cmp #CORE.STACK.MAX
2019-08-05 13:30:58 +00:00
bcc .8
2019-04-03 15:52:24 +00:00
lda #E.STKOVERFLOW
2019-11-30 13:37:55 +00:00
* sec
2019-10-03 06:25:27 +00:00
.8 rts
2019-04-03 15:52:24 +00:00
*--------------------------------------
2019-05-31 07:31:41 +00:00
CORE.StkPushYAX phx
jsr CORE.StkPushYA
bcs CORE.StkPushYA.9
bra CORE.StkPush.1
2019-01-28 16:33:30 +00:00
*--------------------------------------
2020-01-06 16:27:52 +00:00
CORE.StkPushInputBufPtr
>LDYA ZPInputBufPtr
*--------------------------------------
2019-04-03 11:46:50 +00:00
CORE.StkPushYA phy
jsr CORE.StkPush
2019-05-31 07:31:41 +00:00
bcc CORE.StkPush.1
CORE.StkPushYA.9
plx
2019-09-18 15:33:00 +00:00
CORE.StkPushYA.RTS
2019-05-31 07:31:41 +00:00
rts
2019-04-03 11:46:50 +00:00
*--------------------------------------
2019-09-18 15:33:00 +00:00
CORE.PushVarName
>LDYA ZPVarNamePtr
>SYSCALL strdup
bcs CORE.StkPushYA.RTS
txa
*--------------------------------------
2019-01-31 16:34:02 +00:00
CORE.StkPush pha
2019-05-31 07:31:41 +00:00
CORE.StkPush.1 lda (pData) StackPtr
2019-01-28 16:33:30 +00:00
inc
cmp #CORE.STACK.MAX
2019-07-31 20:41:37 +00:00
bcs .9
2019-11-15 14:40:48 +00:00
2019-01-28 16:33:30 +00:00
sta (pData) StackPtr
tay
pla
sta (pData),y
* clc
rts
2019-11-15 14:40:48 +00:00
2019-01-28 16:33:30 +00:00
.9 pla
lda #E.STKOVERFLOW
* sec
rts
*--------------------------------------
2019-03-08 16:36:21 +00:00
CORE.StkGetCtx jsr CORE.StkGet
tax
bcs .1 no context...
2019-07-31 20:41:37 +00:00
2019-08-15 12:48:58 +00:00
cmp #$C0+C.. in a call...
2019-04-01 15:24:01 +00:00
beq .1 CS
2019-03-08 16:36:21 +00:00
2019-08-15 12:48:58 +00:00
cmp #$C0+C.CALL
beq .1 CS
cmp #$C0+C.CLEXEC
beq .1 CS
2019-03-08 16:36:21 +00:00
and #$80 get current..
lsr becomes parent
2019-08-15 12:48:58 +00:00
bra .8
2019-03-08 16:36:21 +00:00
.1 lda #$40 ...set Parent = true
2019-08-15 12:48:58 +00:00
.8 sta CORE.TestResult
2019-04-01 15:24:01 +00:00
2019-03-08 16:36:21 +00:00
txa
rts
*--------------------------------------
2019-05-31 07:31:41 +00:00
CORE.StkPullInputBufPtr
2019-04-04 15:44:20 +00:00
jsr CORE.StkPull
2019-05-31 07:31:41 +00:00
bcs .9
2019-04-04 15:44:20 +00:00
sta ZPInputBufPtr
2019-05-31 07:31:41 +00:00
jsr CORE.StkPull
bcs .9
sta ZPInputBufPtr+1
2019-10-03 06:25:27 +00:00
.9 rts
2019-04-04 15:44:20 +00:00
*--------------------------------------
2019-12-20 21:17:17 +00:00
CORE.StkPullFClose
jsr CORE.StkPull
>SYSCALL fclose
rts
*--------------------------------------
CORE.StkPullFree
jsr CORE.StkPull
>SYSCALL freemem
rts
*--------------------------------------
2019-01-31 16:34:02 +00:00
CORE.StkPull jsr CORE.StkGet
2019-01-28 16:33:30 +00:00
bcs .9
dey
pha
tya
sta (pData) StackPtr
pla
2019-10-03 06:25:27 +00:00
.9 rts
2019-01-28 16:33:30 +00:00
*--------------------------------------
CORE.StkGet lda (pData) StackPtr
2019-08-12 07:40:16 +00:00
beq .9
2019-01-28 16:33:30 +00:00
tay
lda (pData),y
clc
rts
2019-08-12 07:40:16 +00:00
.9 lda #E.STACKERROR
2019-05-31 07:31:41 +00:00
sec
rts
*--------------------------------------
2019-01-28 16:33:30 +00:00
MAN
2019-02-08 16:13:43 +00:00
SAVE USR/SRC/BIN/SH.S.CORE
LOAD USR/SRC/BIN/SH.S
2019-01-28 16:33:30 +00:00
ASM