2016-08-17 06:25:58 +00:00
|
|
|
|
PR#3
|
2017-03-29 15:48:15 +00:00
|
|
|
|
PREFIX /A2OSX.BUILD
|
2016-08-17 06:25:58 +00:00
|
|
|
|
NEW
|
|
|
|
|
INC 1
|
|
|
|
|
AUTO 6
|
|
|
|
|
.LIST OFF
|
|
|
|
|
*--------------------------------------
|
2017-07-25 14:37:19 +00:00
|
|
|
|
|
|
|
|
|
*--------------------------------------
|
2017-07-21 14:46:25 +00:00
|
|
|
|
CSH.TYPE.CHAR .EQ 1
|
|
|
|
|
CSH.TYPE.INT .EQ 2
|
|
|
|
|
CSH.TYPE.LONG .EQ 3
|
|
|
|
|
CSH.TYPE.FLOAT .EQ 4
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CSH.Init >LDYAI 256
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL GetMem0.YA
|
2017-07-21 14:46:25 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
txa
|
|
|
|
|
ldy #CSH.hSymbols
|
|
|
|
|
sta (pData),y
|
|
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
|
ldy #CSH.SymbolsPtr
|
|
|
|
|
sta (pData),y
|
|
|
|
|
|
|
|
|
|
>LDYAI 256
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL GetMem.YA
|
2017-07-21 14:46:25 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
txa
|
|
|
|
|
ldy #CSH.hData
|
|
|
|
|
sta (pData),y
|
|
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
|
ldy #CSH.DataPtr
|
|
|
|
|
sta (pData),y
|
2017-07-13 15:22:13 +00:00
|
|
|
|
|
|
|
|
|
>LDYAI 256
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL GetMem.YA
|
2017-07-13 15:22:13 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
txa
|
|
|
|
|
ldy #CSH.hStack
|
2017-07-12 15:25:23 +00:00
|
|
|
|
sta (pData),y
|
2017-07-13 15:22:13 +00:00
|
|
|
|
|
2017-07-21 14:46:25 +00:00
|
|
|
|
lda #0
|
2017-07-13 15:22:13 +00:00
|
|
|
|
ldy #CSH.StackPtr
|
|
|
|
|
sta (pData),y
|
2017-07-21 14:46:25 +00:00
|
|
|
|
|
2017-07-13 15:22:13 +00:00
|
|
|
|
* clc
|
|
|
|
|
.9 rts
|
2017-07-12 15:25:23 +00:00
|
|
|
|
*--------------------------------------
|
2017-07-21 14:46:25 +00:00
|
|
|
|
CSH.Run jsr CSH.GetBuf
|
2017-07-11 15:53:52 +00:00
|
|
|
|
|
2017-07-21 14:46:25 +00:00
|
|
|
|
jsr CSH.GetPtrs
|
2017-07-13 15:22:13 +00:00
|
|
|
|
|
2017-07-25 14:37:19 +00:00
|
|
|
|
lda #0
|
|
|
|
|
sta (pData) Reset Cmdline
|
2017-07-10 15:50:32 +00:00
|
|
|
|
|
2017-07-13 15:22:13 +00:00
|
|
|
|
jsr CSH.GetCharNB
|
2016-08-17 06:25:58 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
2017-07-13 15:22:13 +00:00
|
|
|
|
cmp #'}' End of block ?
|
2017-07-25 14:37:19 +00:00
|
|
|
|
bne .1
|
2017-07-13 15:22:13 +00:00
|
|
|
|
|
|
|
|
|
jsr CSH.CheckStack must be on stack....
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
jsr CSH.Pop was expected, get stacked Cmd...
|
|
|
|
|
tax
|
|
|
|
|
jmp (J.CSHCMDS.END,x)
|
|
|
|
|
|
2017-07-25 14:37:19 +00:00
|
|
|
|
.1 cmp #$0D
|
|
|
|
|
bne .2
|
2017-07-10 15:50:32 +00:00
|
|
|
|
|
2017-07-25 14:37:19 +00:00
|
|
|
|
jmp CSH.GetNextCharNB Skip CR
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2017-07-25 14:37:19 +00:00
|
|
|
|
.2 pha
|
|
|
|
|
jsr CSH.SavePtr Save Ptr, in case of while,for....
|
|
|
|
|
pla
|
|
|
|
|
jsr CSH.IsLetter
|
|
|
|
|
bcc .3
|
2017-07-10 15:50:32 +00:00
|
|
|
|
|
2017-07-25 14:37:19 +00:00
|
|
|
|
cmp #'#'
|
|
|
|
|
beq .5 comments : pass line to shell
|
2017-07-10 15:50:32 +00:00
|
|
|
|
|
2017-07-25 14:37:19 +00:00
|
|
|
|
bra .9 error, todo : PREOPS ++ --.....
|
|
|
|
|
|
|
|
|
|
.3 jsr CSH.GetName
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
jsr CSH.IsKeyword
|
|
|
|
|
bcs .4 not an internal CSH keyword....
|
2017-07-11 15:53:52 +00:00
|
|
|
|
|
2017-07-25 14:37:19 +00:00
|
|
|
|
stx CSH.CmdSave
|
|
|
|
|
jmp (J.CSHCMDS,x)
|
2017-07-11 15:53:52 +00:00
|
|
|
|
|
2017-07-25 14:37:19 +00:00
|
|
|
|
.4 jsr CSH.GetVar
|
|
|
|
|
bcs .5
|
|
|
|
|
jsr CSH.GetCharNB
|
|
|
|
|
bcs .9
|
|
|
|
|
cmp #'='
|
|
|
|
|
bne .99
|
|
|
|
|
|
2017-08-22 06:37:03 +00:00
|
|
|
|
jsr CSH.GetNextCharNB Skip =
|
2017-08-01 19:41:01 +00:00
|
|
|
|
bcs .99
|
2017-08-22 06:37:03 +00:00
|
|
|
|
|
2017-07-25 14:37:19 +00:00
|
|
|
|
jsr CSH.ExpEval
|
|
|
|
|
bcs .9
|
2017-07-11 15:53:52 +00:00
|
|
|
|
|
2017-07-25 14:37:19 +00:00
|
|
|
|
jsr CSH.GetChar
|
|
|
|
|
bcs .9
|
|
|
|
|
cmp #';'
|
|
|
|
|
bne .99
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2017-07-25 14:37:19 +00:00
|
|
|
|
jsr CSH.SetVar
|
|
|
|
|
bcs .9
|
2017-07-12 15:25:23 +00:00
|
|
|
|
|
2017-07-25 14:37:19 +00:00
|
|
|
|
jmp CSH.GetNextCharNB Skip ;
|
2017-07-10 15:50:32 +00:00
|
|
|
|
|
2017-07-25 14:37:19 +00:00
|
|
|
|
.99 lda #CSHERR.SYNTAX
|
|
|
|
|
sec
|
|
|
|
|
.9 rts
|
|
|
|
|
|
|
|
|
|
.5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jsr CSH.RestorePtr Restore ptr to get full cmd line to execute
|
|
|
|
|
|
|
|
|
|
jsr CSH.GetCharNB
|
|
|
|
|
|
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
|
|
.6 cmp #13
|
|
|
|
|
beq .7
|
|
|
|
|
iny
|
|
|
|
|
sta (pData),y
|
|
|
|
|
cpy #CmdLine.MAX
|
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
jsr CSH.GetNextChar
|
|
|
|
|
bcc .6
|
|
|
|
|
bra .8
|
2017-07-11 15:53:52 +00:00
|
|
|
|
|
2017-07-25 14:37:19 +00:00
|
|
|
|
.7 jsr CSH.GetNextCharNB Skip CR
|
2017-07-11 15:53:52 +00:00
|
|
|
|
|
2017-07-13 15:22:13 +00:00
|
|
|
|
.8 tya
|
2017-07-10 15:50:32 +00:00
|
|
|
|
sta (pData)
|
|
|
|
|
|
|
|
|
|
ldy #bEcho
|
2016-08-17 06:25:58 +00:00
|
|
|
|
lda (pData),y
|
2017-07-13 15:22:13 +00:00
|
|
|
|
beq .80
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2016-10-17 06:21:04 +00:00
|
|
|
|
>PUSHW pData
|
|
|
|
|
>LDYA L.MSG.ECHO
|
2017-08-25 15:02:16 +00:00
|
|
|
|
>SYSCALL PrintF.YA
|
2017-07-25 14:37:19 +00:00
|
|
|
|
|
2017-07-13 15:22:13 +00:00
|
|
|
|
.80 clc
|
2017-07-25 14:37:19 +00:00
|
|
|
|
rts
|
2016-08-17 06:25:58 +00:00
|
|
|
|
*--------------------------------------
|
2017-07-21 14:46:25 +00:00
|
|
|
|
CSH.Quit ldy #CSH.hBuf
|
|
|
|
|
lda (pData),y
|
|
|
|
|
beq .1
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL FreeMem.A
|
2017-07-21 14:46:25 +00:00
|
|
|
|
|
|
|
|
|
.1 ldy #CSH.hStack
|
|
|
|
|
lda (pData),y
|
|
|
|
|
beq .2
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL FreeMem.A
|
2017-07-21 14:46:25 +00:00
|
|
|
|
|
|
|
|
|
.2 ldy #CSH.hData
|
|
|
|
|
lda (pData),y
|
|
|
|
|
beq .3
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL FreeMem.A
|
2017-07-21 14:46:25 +00:00
|
|
|
|
|
|
|
|
|
.3 ldy #CSH.hSymbols
|
|
|
|
|
lda (pData),y
|
|
|
|
|
beq .8
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL FreeMem.A
|
2017-07-21 14:46:25 +00:00
|
|
|
|
|
|
|
|
|
.8 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CSH.GetBuf ldy #CSH.hBuf
|
|
|
|
|
lda (pData),y
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL GetMemPtr.A
|
2017-07-21 14:46:25 +00:00
|
|
|
|
>STYA ZPBufBase
|
|
|
|
|
|
|
|
|
|
ldy #CSH.BufLen
|
|
|
|
|
lda (pData),y
|
|
|
|
|
clc
|
|
|
|
|
adc ZPBufBase
|
|
|
|
|
sta CSH.GetChar.LO+1
|
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
|
lda (pData),y
|
|
|
|
|
adc ZPBufBase+1
|
|
|
|
|
sta CSH.GetChar.HI+1
|
|
|
|
|
|
|
|
|
|
CSH.SetBufPtr ldy #CSH.BufPtr
|
|
|
|
|
lda (pData),y
|
|
|
|
|
clc
|
|
|
|
|
adc ZPBufBase
|
|
|
|
|
sta ZPBufPtr
|
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
|
lda (pData),y
|
|
|
|
|
adc ZPBufBase+1
|
|
|
|
|
sta ZPBufPtr+1
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CSH.GetPtrs ldy #CSH.hSymbols
|
|
|
|
|
lda (pData),y
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL GetMemPtr.A
|
2017-07-21 14:46:25 +00:00
|
|
|
|
>STYA ZPCSHSymbols
|
|
|
|
|
|
|
|
|
|
ldy #CSH.hData
|
|
|
|
|
lda (pData),y
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL GetMemPtr.A
|
2017-07-21 14:46:25 +00:00
|
|
|
|
>STYA ZPCSHData
|
|
|
|
|
|
|
|
|
|
ldy #CSH.hStack
|
|
|
|
|
lda (pData),y
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL GetMemPtr.A
|
2017-07-21 14:46:25 +00:00
|
|
|
|
>STYA ZPCSHStack
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-07-25 14:37:19 +00:00
|
|
|
|
CSH.SavePtr phy
|
|
|
|
|
ldy #CSH.BufPtr
|
|
|
|
|
lda (pData),y
|
|
|
|
|
sta CSH.BufPtrSave
|
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
|
lda (pData),y
|
|
|
|
|
sta CSH.BufPtrSave+1
|
|
|
|
|
ply
|
2017-07-21 14:46:25 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-07-25 14:37:19 +00:00
|
|
|
|
CSH.RestorePtr phy
|
|
|
|
|
ldy #CSH.BufPtr
|
|
|
|
|
lda CSH.BufPtrSave
|
|
|
|
|
sta (pData),y
|
|
|
|
|
clc
|
|
|
|
|
adc ZPBufBase
|
|
|
|
|
sta ZPBufPtr
|
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
|
lda CSH.BufPtrSave+1
|
|
|
|
|
sta (pData),y
|
|
|
|
|
adc ZPBufBase+1
|
|
|
|
|
sta ZPBufPtr+1
|
|
|
|
|
ply
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CSH.IsKeyword phy
|
2017-07-13 15:22:13 +00:00
|
|
|
|
>LDYA L.CSHCMDS
|
2017-07-11 15:53:52 +00:00
|
|
|
|
>STYA ZPPtr2
|
|
|
|
|
|
|
|
|
|
ldx #0
|
|
|
|
|
|
|
|
|
|
.1 lda (ZPPtr2)
|
|
|
|
|
beq .9 Ending 0, not found....
|
|
|
|
|
|
2017-07-25 14:37:19 +00:00
|
|
|
|
cmp CSH.Name Same Len ?
|
2017-07-11 15:53:52 +00:00
|
|
|
|
bne .4
|
|
|
|
|
|
|
|
|
|
tay
|
|
|
|
|
|
2017-07-25 14:37:19 +00:00
|
|
|
|
.2 lda CSH.Name,y
|
2017-07-11 15:53:52 +00:00
|
|
|
|
|
|
|
|
|
cmp #'a' To Uppercase
|
|
|
|
|
bcc .3
|
|
|
|
|
cmp #'z'+1
|
|
|
|
|
bcs .3
|
|
|
|
|
eor #$20
|
|
|
|
|
|
|
|
|
|
.3 cmp (ZPPtr2),y
|
|
|
|
|
bne .4
|
|
|
|
|
dey
|
|
|
|
|
bne .2
|
|
|
|
|
|
|
|
|
|
ply
|
|
|
|
|
clc Found an internal Cmd...
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.4 inx
|
|
|
|
|
inx
|
|
|
|
|
|
|
|
|
|
lda ZPPtr2
|
|
|
|
|
sec
|
|
|
|
|
adc (ZPPtr2)
|
|
|
|
|
sta ZPPtr2
|
|
|
|
|
bcc .1
|
|
|
|
|
inc ZPPtr2+1
|
|
|
|
|
bra .1
|
|
|
|
|
|
|
|
|
|
.9 ply
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-07-13 15:22:13 +00:00
|
|
|
|
CSH.WHILE
|
|
|
|
|
CSH.IF jsr CSH.GetCharNB
|
2017-07-11 15:53:52 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
cmp #'('
|
|
|
|
|
bne .9
|
|
|
|
|
|
2017-07-13 15:22:13 +00:00
|
|
|
|
jsr CSH.GetNextCharNB
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
jsr CSH.ExpEval
|
2017-07-11 15:53:52 +00:00
|
|
|
|
bcs .99
|
|
|
|
|
|
2017-07-13 15:22:13 +00:00
|
|
|
|
jsr CSH.GetCharNB
|
2017-07-12 15:25:23 +00:00
|
|
|
|
bcs .99
|
2017-07-11 15:53:52 +00:00
|
|
|
|
cmp #')'
|
|
|
|
|
bne .9
|
|
|
|
|
|
2017-07-13 15:22:13 +00:00
|
|
|
|
jsr CSH.GetNextCharNB
|
2017-07-12 15:25:23 +00:00
|
|
|
|
bcs .99
|
|
|
|
|
cmp #'{'
|
|
|
|
|
bne .9
|
|
|
|
|
|
|
|
|
|
lda CSH.ACC
|
|
|
|
|
ora CSH.ACC+1
|
|
|
|
|
ora CSH.ACC+2
|
|
|
|
|
ora CSH.ACC+3
|
|
|
|
|
beq .6 eval returned false, skip {{....}}
|
|
|
|
|
|
2017-07-13 15:22:13 +00:00
|
|
|
|
jsr CSH.GetNextCharNB Skip '{'
|
2017-07-11 15:53:52 +00:00
|
|
|
|
|
2017-07-13 15:22:13 +00:00
|
|
|
|
lda CSH.CmdSave Push "IF" or "WHILE"
|
|
|
|
|
beq .1 if "IF", no need to push Saved Ptr
|
2017-07-12 15:25:23 +00:00
|
|
|
|
|
2017-07-13 15:22:13 +00:00
|
|
|
|
pha
|
|
|
|
|
lda CSH.BufPtrSave+1 WHILE : push loop address...
|
|
|
|
|
jsr CSH.Push
|
|
|
|
|
lda CSH.BufPtrSave
|
|
|
|
|
jsr CSH.Push
|
|
|
|
|
pla
|
2017-07-11 15:53:52 +00:00
|
|
|
|
|
2017-07-13 15:22:13 +00:00
|
|
|
|
.1 jsr CSH.Push
|
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
|
|
lda #'}' Tell '}' is expected at the end of block
|
|
|
|
|
jsr CSH.Push
|
|
|
|
|
bcs .99
|
|
|
|
|
|
2017-07-11 15:53:52 +00:00
|
|
|
|
rts
|
|
|
|
|
|
2017-07-13 15:22:13 +00:00
|
|
|
|
.6 ldx #1 expecting 1 '}' for now....
|
2017-07-12 15:25:23 +00:00
|
|
|
|
|
2017-07-13 15:22:13 +00:00
|
|
|
|
.7 jsr CSH.GetNextChar
|
2017-07-12 15:25:23 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
cmp #'{'
|
|
|
|
|
bne .71
|
|
|
|
|
inx
|
|
|
|
|
bra .7
|
|
|
|
|
|
|
|
|
|
.71 cmp #'}'
|
|
|
|
|
bne .7
|
2017-07-13 15:22:13 +00:00
|
|
|
|
txa
|
|
|
|
|
beq .9
|
2017-07-12 15:25:23 +00:00
|
|
|
|
dex
|
|
|
|
|
bne .7
|
|
|
|
|
|
2017-07-13 15:22:13 +00:00
|
|
|
|
jsr CSH.GetNextChar
|
|
|
|
|
|
2017-07-12 15:25:23 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
2017-07-11 15:53:52 +00:00
|
|
|
|
|
2017-07-13 15:22:13 +00:00
|
|
|
|
.9 lda #CSHERR.SYNTAX
|
2017-07-11 15:53:52 +00:00
|
|
|
|
sec
|
|
|
|
|
.99 rts
|
|
|
|
|
*--------------------------------------
|
2017-07-13 15:22:13 +00:00
|
|
|
|
CSH.IF.END jsr CSH.GetNextChar just skip ending '}'
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CSH.WHILE.END jsr CSH.Pop
|
|
|
|
|
ldy #CSH.BufPtr
|
|
|
|
|
sta (pData),y
|
|
|
|
|
jsr CSH.Pop
|
|
|
|
|
ldy #CSH.BufPtr+1
|
|
|
|
|
sta (pData),y
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CSH.BREAK
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CSH.CONTINUE
|
|
|
|
|
|
|
|
|
|
lda #CSHERR.SYNTAX
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-07-21 14:46:25 +00:00
|
|
|
|
CSH.CHAR lda #CSH.TYPE.CHAR
|
|
|
|
|
bra CSH.TYPE
|
|
|
|
|
CSH.INT lda #CSH.TYPE.INT
|
|
|
|
|
bra CSH.TYPE
|
|
|
|
|
CSH.LONG lda #CSH.TYPE.LONG
|
|
|
|
|
bra CSH.TYPE
|
|
|
|
|
CSH.FLOAT lda #CSH.TYPE.FLOAT
|
|
|
|
|
|
|
|
|
|
CSH.TYPE sta CSH.ACCT
|
|
|
|
|
|
|
|
|
|
jsr CSH.GetChar
|
|
|
|
|
bcs .9
|
|
|
|
|
cmp #' '
|
|
|
|
|
bne .9
|
|
|
|
|
|
2017-07-25 14:37:19 +00:00
|
|
|
|
jsr CSH.GetNextCharNB
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
jsr CSH.IsLetter
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
jsr CSH.GetName
|
2017-07-21 14:46:25 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
jsr CSH.GetCharNB
|
|
|
|
|
bcs .9
|
|
|
|
|
cmp #';'
|
|
|
|
|
beq .8 end of declaration, no value...
|
|
|
|
|
|
|
|
|
|
cmp #'='
|
|
|
|
|
bne .9
|
|
|
|
|
|
|
|
|
|
jsr CSH.GetNextCharNB
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
jsr CSH.ExpEval
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
jsr CSH.GetChar
|
|
|
|
|
bcs .9
|
|
|
|
|
cmp #';'
|
|
|
|
|
bne .9
|
|
|
|
|
|
|
|
|
|
.8 jsr CSH.AddVar
|
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
|
|
jsr CSH.GetNextCharNB Skip ;
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.9 lda #CSHERR.SYNTAX
|
|
|
|
|
sec
|
|
|
|
|
.99 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
|
|
|
|
|
lda #CSHERR.SYNTAX
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CSH.ExpEval jsr CSH.ZeroACC
|
2017-07-17 05:59:30 +00:00
|
|
|
|
|
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
|
|
jsr CSH.GetCharNB
|
|
|
|
|
bcs .9
|
|
|
|
|
cmp #')'
|
|
|
|
|
beq .8
|
2017-07-21 14:46:25 +00:00
|
|
|
|
cmp #';'
|
|
|
|
|
beq .8
|
2017-07-17 05:59:30 +00:00
|
|
|
|
|
|
|
|
|
jsr CSH.IsLetter Fnc or Var ?
|
|
|
|
|
bcs .1
|
|
|
|
|
|
|
|
|
|
bra .9
|
|
|
|
|
|
2017-07-25 14:37:19 +00:00
|
|
|
|
.1 jsr CSH.IsDigit10 number ?
|
2017-07-17 05:59:30 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
jsr CSH.GetNumInACC
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.8 clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.9 lda #CSHERR.SYNTAX
|
|
|
|
|
sec
|
|
|
|
|
.99 rts
|
|
|
|
|
*--------------------------------------
|
2017-07-25 14:37:19 +00:00
|
|
|
|
CSH.GetName ldy #0
|
|
|
|
|
|
2017-07-21 14:46:25 +00:00
|
|
|
|
.1 iny
|
2017-07-25 14:37:19 +00:00
|
|
|
|
sta CSH.Name,y
|
2017-07-21 14:46:25 +00:00
|
|
|
|
jsr CSH.GetNextChar
|
|
|
|
|
bcs .8
|
|
|
|
|
|
|
|
|
|
jsr CSH.IsLetterOrDigit
|
2017-07-25 14:37:19 +00:00
|
|
|
|
bcs .8
|
|
|
|
|
cpy #CSH.Name.MAX
|
2017-07-21 14:46:25 +00:00
|
|
|
|
bcc .1
|
|
|
|
|
|
2017-07-25 14:37:19 +00:00
|
|
|
|
lda #CSHERR.TOOLONG
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.8 sty CSH.Name
|
2017-07-21 14:46:25 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.9 lda #CSHERR.SYNTAX
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-07-17 05:59:30 +00:00
|
|
|
|
CSH.GetNumInACC ldy #0
|
|
|
|
|
|
|
|
|
|
.1 iny
|
|
|
|
|
cpy #10
|
|
|
|
|
beq .9
|
|
|
|
|
|
2017-07-21 14:46:25 +00:00
|
|
|
|
sta ARGS,y
|
|
|
|
|
jsr CSH.GetNextChar
|
2017-07-17 05:59:30 +00:00
|
|
|
|
bcs .8
|
2017-07-25 14:37:19 +00:00
|
|
|
|
jsr CSH.IsDigit10
|
2017-07-17 05:59:30 +00:00
|
|
|
|
bcc .1
|
|
|
|
|
|
2017-07-21 14:46:25 +00:00
|
|
|
|
.8 sty ARGS
|
2017-07-17 05:59:30 +00:00
|
|
|
|
|
|
|
|
|
>PUSHW L.CSH.ACC
|
2017-07-21 14:46:25 +00:00
|
|
|
|
>PUSHW L.ARGS
|
2017-07-17 05:59:30 +00:00
|
|
|
|
>SYSCALL AToI
|
|
|
|
|
bcs .9
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.9 lda #CSHERR.SYNTAX
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-07-21 14:46:25 +00:00
|
|
|
|
CSH.ZeroACC stz CSH.ACC
|
|
|
|
|
stz CSH.ACC+1
|
|
|
|
|
stz CSH.ACC+2
|
|
|
|
|
stz CSH.ACC+3
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Vars...
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CSH.AddVar jsr CSH.FindVar
|
|
|
|
|
bcc .97
|
|
|
|
|
|
|
|
|
|
ldy #CSH.SymbolsPtr
|
|
|
|
|
lda (pData),y
|
|
|
|
|
|
|
|
|
|
sec
|
2017-07-25 14:37:19 +00:00
|
|
|
|
adc CSH.Name
|
2017-07-21 14:46:25 +00:00
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
|
|
adc #2 TYPE + OFS
|
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
|
|
ldy #CSH.DataPtr
|
|
|
|
|
lda (pData),y
|
|
|
|
|
pha
|
|
|
|
|
|
|
|
|
|
ldx CSH.ACCT
|
|
|
|
|
* clc
|
|
|
|
|
adc CSH.TSIZE,x
|
|
|
|
|
bcs .98
|
|
|
|
|
|
|
|
|
|
ldx #$ff
|
|
|
|
|
|
|
|
|
|
ldy #CSH.SymbolsPtr
|
|
|
|
|
lda (pData),y
|
|
|
|
|
tay
|
|
|
|
|
|
|
|
|
|
.10 inx
|
2017-07-25 14:37:19 +00:00
|
|
|
|
lda CSH.Name,x
|
2017-07-21 14:46:25 +00:00
|
|
|
|
sta (ZPCSHSymbols),y
|
|
|
|
|
iny
|
2017-07-25 14:37:19 +00:00
|
|
|
|
cpx CSH.Name
|
2017-07-21 14:46:25 +00:00
|
|
|
|
bne .10
|
|
|
|
|
|
|
|
|
|
lda CSH.ACCT
|
|
|
|
|
sta (ZPCSHSymbols),y
|
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
|
pla Get Back Data OFS
|
|
|
|
|
pha
|
|
|
|
|
sta (ZPCSHSymbols),y
|
|
|
|
|
iny
|
|
|
|
|
|
|
|
|
|
tya
|
|
|
|
|
ldy #CSH.SymbolsPtr
|
|
|
|
|
sta (pData),y
|
|
|
|
|
|
|
|
|
|
ply Get Back Data OFS again
|
|
|
|
|
|
|
|
|
|
ldx CSH.ACCT
|
|
|
|
|
lda CSH.TSIZE,x
|
|
|
|
|
|
|
|
|
|
ldx #0
|
|
|
|
|
|
|
|
|
|
.1 pha
|
|
|
|
|
lda CSH.ACC,x
|
|
|
|
|
sta (ZPCSHData),y
|
|
|
|
|
iny
|
|
|
|
|
inx
|
|
|
|
|
pla
|
|
|
|
|
dec
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
tya
|
|
|
|
|
ldy #CSH.DataPtr
|
|
|
|
|
sta (pData),y
|
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.97 lda #CSHERR.DUP
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.98 pla
|
|
|
|
|
.99 lda #CSHERR.OOM
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CSH.SetVar
|
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-07-25 14:37:19 +00:00
|
|
|
|
CSH.GetVar jsr CSH.FindVar
|
|
|
|
|
bcs .9
|
|
|
|
|
|
2017-07-21 14:46:25 +00:00
|
|
|
|
clc
|
2017-07-25 14:37:19 +00:00
|
|
|
|
.9 rts
|
2017-07-21 14:46:25 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
CSH.FindVar >LDYA ZPCSHSymbols
|
|
|
|
|
>STYA ZPPTR1
|
|
|
|
|
|
|
|
|
|
.1 ldy #0
|
|
|
|
|
|
|
|
|
|
lda (ZPPTR1),y
|
|
|
|
|
beq .9
|
|
|
|
|
|
2017-07-25 14:37:19 +00:00
|
|
|
|
cmp CSH.Name
|
2017-07-21 14:46:25 +00:00
|
|
|
|
bne .4
|
|
|
|
|
|
|
|
|
|
pha Save Name len...
|
|
|
|
|
|
|
|
|
|
ldx #0
|
|
|
|
|
|
|
|
|
|
.2 iny
|
|
|
|
|
inx
|
|
|
|
|
lda (ZPPTR1),y
|
2017-07-25 14:37:19 +00:00
|
|
|
|
cmp CSH.Name,x
|
2017-07-21 14:46:25 +00:00
|
|
|
|
bne .3
|
|
|
|
|
|
2017-07-25 14:37:19 +00:00
|
|
|
|
cpx CSH.Name
|
2017-07-21 14:46:25 +00:00
|
|
|
|
bne .2
|
|
|
|
|
|
|
|
|
|
pla
|
|
|
|
|
sec
|
|
|
|
|
adc ZPPTR1
|
|
|
|
|
sta ZPPTR1
|
|
|
|
|
bcc .8
|
|
|
|
|
inc ZPPTR1+1
|
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
.8 rts
|
|
|
|
|
|
|
|
|
|
.3 pla
|
|
|
|
|
.4 sec
|
|
|
|
|
adc ZPPTR1
|
|
|
|
|
bcc .5
|
|
|
|
|
inc ZPPTR1+1
|
|
|
|
|
clc
|
|
|
|
|
|
|
|
|
|
.5 adc #2 Skip Type+OFS
|
|
|
|
|
sta ZPPTR1
|
|
|
|
|
bcc .1
|
|
|
|
|
inc ZPPTR1+1
|
|
|
|
|
bra .1
|
|
|
|
|
|
|
|
|
|
.9 sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Stack
|
|
|
|
|
*--------------------------------------
|
2017-07-13 15:22:13 +00:00
|
|
|
|
CSH.Push pha
|
|
|
|
|
ldy #CSH.StackPtr
|
2017-07-12 15:25:23 +00:00
|
|
|
|
lda (pData),y
|
2017-07-13 15:22:13 +00:00
|
|
|
|
tay
|
2017-07-12 15:25:23 +00:00
|
|
|
|
|
2017-07-13 15:22:13 +00:00
|
|
|
|
pla
|
|
|
|
|
sta (ZPCSHStack),y
|
|
|
|
|
iny
|
|
|
|
|
beq .9
|
|
|
|
|
tya
|
|
|
|
|
ldy #CSH.StackPtr
|
2017-07-12 15:25:23 +00:00
|
|
|
|
sta (pData),y
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
2017-07-13 15:22:13 +00:00
|
|
|
|
.9 lda #CSHERR.SOVERFLW
|
2017-07-12 15:25:23 +00:00
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-07-13 15:22:13 +00:00
|
|
|
|
CSH.Pop ldy #CSH.StackPtr
|
2017-07-12 15:25:23 +00:00
|
|
|
|
lda (pData),y
|
|
|
|
|
beq .9
|
|
|
|
|
dec
|
2017-07-13 15:22:13 +00:00
|
|
|
|
tay
|
2017-07-12 15:25:23 +00:00
|
|
|
|
sta (pData),y
|
2017-07-13 15:22:13 +00:00
|
|
|
|
lda (ZPCSHStack),y
|
2017-07-12 15:25:23 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
2017-07-13 15:22:13 +00:00
|
|
|
|
.9 lda #CSHERR.SYNTAX
|
2017-07-12 15:25:23 +00:00
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-07-13 15:22:13 +00:00
|
|
|
|
CSH.CheckStack pha
|
|
|
|
|
ldy #CSH.StackPtr
|
2017-07-12 15:25:23 +00:00
|
|
|
|
lda (pData),y
|
|
|
|
|
beq .9
|
2017-07-13 15:22:13 +00:00
|
|
|
|
dec
|
2017-07-12 15:25:23 +00:00
|
|
|
|
tay
|
2017-07-13 15:22:13 +00:00
|
|
|
|
pla
|
|
|
|
|
cmp (ZPCSHStack),y
|
2017-07-12 15:25:23 +00:00
|
|
|
|
bne .9
|
2017-07-13 15:22:13 +00:00
|
|
|
|
|
|
|
|
|
tya
|
|
|
|
|
ldy #CSH.StackPtr
|
|
|
|
|
sta (pData),y
|
|
|
|
|
|
2017-07-11 15:53:52 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
2017-07-12 15:25:23 +00:00
|
|
|
|
|
2017-07-13 15:22:13 +00:00
|
|
|
|
.9 lda #CSHERR.SYNTAX
|
2017-07-12 15:25:23 +00:00
|
|
|
|
sec
|
2017-07-13 15:22:13 +00:00
|
|
|
|
rts
|
2017-07-12 15:25:23 +00:00
|
|
|
|
*--------------------------------------
|
2017-07-21 14:46:25 +00:00
|
|
|
|
* CHAR related Subs.....
|
|
|
|
|
*--------------------------------------
|
2017-07-13 15:22:13 +00:00
|
|
|
|
CSH.GetCharNB jsr CSH.GetChar
|
|
|
|
|
bcs CSH.GetNextCharNB.RTS
|
|
|
|
|
jsr CSH.CheckCharNB
|
|
|
|
|
bcc CSH.GetNextCharNB.RTS
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CSH.GetNextCharNB
|
|
|
|
|
jsr CSH.GetNextChar
|
|
|
|
|
bcs CSH.GetNextCharNB.RTS
|
|
|
|
|
jsr CSH.CheckCharNB
|
|
|
|
|
bcs CSH.GetNextCharNB
|
|
|
|
|
CSH.GetNextCharNB.RTS
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CSH.CheckCharNB cmp #32 SPACE
|
|
|
|
|
beq .9
|
|
|
|
|
cmp #13 CR
|
|
|
|
|
beq .9
|
|
|
|
|
cmp #10 LF
|
|
|
|
|
beq .9
|
|
|
|
|
cmp #8 TAB
|
|
|
|
|
beq .9
|
2017-07-12 15:25:23 +00:00
|
|
|
|
clc
|
2017-07-13 15:22:13 +00:00
|
|
|
|
.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
|
|
|
|
|
|
|
|
|
|
inc ZPBufPtr
|
|
|
|
|
bne CSH.GetChar
|
|
|
|
|
inc ZPBufPtr+1
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CSH.GetChar lda ZPBufPtr
|
2017-07-21 14:46:25 +00:00
|
|
|
|
CSH.GetChar.LO eor #$ff Self Modified
|
|
|
|
|
bne CSH.GetChar.8
|
2017-07-13 15:22:13 +00:00
|
|
|
|
|
|
|
|
|
lda ZPBufPtr+1
|
2017-07-21 14:46:25 +00:00
|
|
|
|
CSH.GetChar.HI eor #$ff Self Modified
|
|
|
|
|
bne CSH.GetChar.8
|
2017-07-13 15:22:13 +00:00
|
|
|
|
|
|
|
|
|
lda #MLI.ERR.EOF
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
|
2017-07-21 14:46:25 +00:00
|
|
|
|
CSH.GetChar.8 lda (ZPBufPtr)
|
2017-07-13 15:22:13 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
*---------------------------------------
|
2017-07-17 05:59:30 +00:00
|
|
|
|
CSH.IsLetterOrDigit
|
2017-07-25 14:37:19 +00:00
|
|
|
|
jsr CSH.IsDigit10
|
2017-07-17 05:59:30 +00:00
|
|
|
|
bcc CSH.IsLetterRTS
|
|
|
|
|
*---------------------------------------
|
2017-07-25 14:37:19 +00:00
|
|
|
|
CSH.IsLetter cmp #'_'
|
|
|
|
|
bne .1
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.1 cmp #'A'
|
2017-07-13 15:22:13 +00:00
|
|
|
|
bcc .9
|
|
|
|
|
|
|
|
|
|
cmp #'Z'+1
|
|
|
|
|
bcc CSH.IsLetterRTS
|
|
|
|
|
|
|
|
|
|
cmp #'a'
|
|
|
|
|
bcc .9
|
|
|
|
|
cmp #'z'+1
|
|
|
|
|
rts CC if lowercase
|
|
|
|
|
|
|
|
|
|
.9 sec
|
|
|
|
|
|
|
|
|
|
CSH.IsLetterRTS rts
|
|
|
|
|
*---------------------------------------
|
2017-07-25 14:37:19 +00:00
|
|
|
|
CSH.IsDigit10 cmp #'0'
|
2017-07-13 15:22:13 +00:00
|
|
|
|
bcc .9
|
|
|
|
|
cmp #'9'+1
|
|
|
|
|
rts cc if ok, cs if not
|
|
|
|
|
|
|
|
|
|
.9 sec
|
|
|
|
|
rts
|
2016-08-17 06:25:58 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
2017-07-13 15:22:13 +00:00
|
|
|
|
SAVE /A2OSX.SRC/SBIN/SHELL.S.CSH
|
2017-03-29 15:48:15 +00:00
|
|
|
|
LOAD /A2OSX.SRC/SBIN/SHELL.S
|
2016-08-17 06:25:58 +00:00
|
|
|
|
ASM
|