A2osX/BIN/CSH.S.CORE.txt

1187 lines
18 KiB
Plaintext
Raw Normal View History

NEW
2019-06-28 15:15:58 +00:00
AUTO 3,1
2020-07-31 14:46:11 +00:00
.LIST OFF
2016-08-17 06:25:58 +00:00
*--------------------------------------
2019-08-26 06:29:18 +00:00
CSH.Init >SYSCALL SListNew
2021-05-22 21:05:12 +00:00
bcs .99
2020-01-23 14:48:22 +00:00
2020-02-21 16:31:46 +00:00
>STA.G CSH.hDefines
2020-01-23 14:48:22 +00:00
2020-01-25 18:56:36 +00:00
>SYSCALL SListNew
2021-05-22 21:05:12 +00:00
bcs .99
2020-01-25 18:56:36 +00:00
2020-02-21 16:31:46 +00:00
>STA.G CSH.hTags
2020-07-31 14:46:11 +00:00
2020-02-21 16:31:46 +00:00
>SYSCALL SListNew
bcs .9
2020-01-25 18:56:36 +00:00
2020-02-21 16:31:46 +00:00
>STA.G CSH.hSymbols
2020-07-31 14:46:11 +00:00
>LDYAI 256
2018-07-13 14:38:24 +00:00
>SYSCALL GetMem
2021-05-22 21:05:12 +00:00
.99 bcs .9
2020-01-23 14:48:22 +00:00
2020-08-02 12:19:43 +00:00
>STYA ZPCSHCode
txa
>STA.G CSH.hCode
>LDYAI 256
>SYSCALL GetMem
bcs .9
2019-02-13 16:20:44 +00:00
>STYA ZPCSHConst
txa
2019-02-13 16:20:44 +00:00
>STA.G CSH.hConst
>LDYAI 256
2018-07-13 14:38:24 +00:00
>SYSCALL GetMem
bcs .9
2020-01-23 14:48:22 +00:00
2020-02-19 16:42:05 +00:00
>STYA ZPCSHData
txa
>STA.G CSH.hData
>LDYAI 256
>SYSCALL GetMem
bcs .9
2019-02-13 16:20:44 +00:00
>STYA ZPCSHStack
txa
>STA.G CSH.hStack
2020-01-23 14:48:22 +00:00
2021-05-22 21:05:12 +00:00
>LDYAI 256
>SYSCALL GetMem
bcs .9
>STYA ZPCSHfDecl
txa
>STA.G CSH.hfDecl
2020-01-25 18:56:36 +00:00
lda #0
2019-02-13 16:20:44 +00:00
>STA.G CSH.ConstPtr
>STA.G CSH.StackPtr
* clc
.9 rts
*--------------------------------------
2019-08-26 06:29:18 +00:00
CSH.Quit >LDA.G CSH.hSymbols
2020-01-23 14:48:22 +00:00
beq .1
2020-07-31 14:46:11 +00:00
2019-08-26 06:29:18 +00:00
>SYSCALL SListFree
2018-10-16 15:48:03 +00:00
2020-02-21 16:31:46 +00:00
.1 >LDA.G CSH.hTags
2020-01-25 18:56:36 +00:00
beq .2
2020-07-31 14:46:11 +00:00
2020-01-25 18:56:36 +00:00
>SYSCALL SListFree
2020-02-21 16:31:46 +00:00
.2 >LDA.G CSH.hDefines
beq .3
2020-07-31 14:46:11 +00:00
2020-02-21 16:31:46 +00:00
>SYSCALL SListFree
2020-12-23 14:54:57 +00:00
.3 lda hInclude
2020-08-26 15:25:58 +00:00
beq .4
2021-01-12 21:14:13 +00:00
2020-08-26 15:25:58 +00:00
>SYSCALL FClose
2020-12-23 14:54:57 +00:00
.4 lda hDefine
2020-01-26 19:36:49 +00:00
jsr .7
2020-07-31 14:46:11 +00:00
2020-01-26 19:36:49 +00:00
>LDA.G hFileBuf
2019-08-26 06:29:18 +00:00
jsr .7
2021-05-22 21:05:12 +00:00
>LDA.G CSH.hfDecl
jsr .7
2019-08-26 06:29:18 +00:00
>LDA.G CSH.hStack
jsr .7
2020-01-23 14:48:22 +00:00
2020-02-19 16:42:05 +00:00
>LDA.G CSH.hData
jsr .7
2019-08-26 06:29:18 +00:00
>LDA.G CSH.hConst
2020-08-02 12:19:43 +00:00
jsr .7
>LDA.G CSH.hCode
2020-07-31 14:46:11 +00:00
2019-08-26 06:29:18 +00:00
.7 beq CSH.Quit.RTS
2018-10-16 15:48:03 +00:00
>SYSCALL FreeMem
2019-02-13 16:20:44 +00:00
CSH.Quit.RTS rts
2018-10-16 15:48:03 +00:00
*--------------------------------------
2018-11-10 14:30:09 +00:00
CSH.Run jsr CSH.GetCharNB
2019-02-13 16:20:44 +00:00
bcs CSH.Quit.RTS
2019-10-03 06:25:27 +00:00
2020-01-25 18:56:36 +00:00
CSH.Run.1 cmp #C.CR empty line....
beq .2
2020-07-31 14:46:11 +00:00
2020-01-25 18:56:36 +00:00
cmp #'/'
2019-08-28 15:21:42 +00:00
bne .3 comments ...
2020-01-25 18:56:36 +00:00
jmp CSH.COMMENTS
2019-08-28 15:21:42 +00:00
.2 jmp CSH.GetNextChar Skip CR and exit
2020-01-25 18:56:36 +00:00
.3 cmp #'#' directive ?
2019-08-28 15:21:42 +00:00
bne .4
2020-02-19 16:42:05 +00:00
jmp CSH.DIR
2020-01-25 18:56:36 +00:00
.4 cmp #'}' End of block ?
2021-05-22 21:05:12 +00:00
bne .10
2020-01-25 18:56:36 +00:00
jsr CSH.CheckStack must be something on stack....
2021-05-22 21:05:12 +00:00
bcs CSH.Quit.RTS
2019-09-05 15:49:05 +00:00
jsr CSH.GetNextCharNB Skip '}'
jsr CSH.Pop was expected....
jsr CSH.Pop get stacked Cmd...
tax
2020-01-25 18:56:36 +00:00
jmp (J.CSH.KW.END,x)
2021-05-22 21:05:12 +00:00
*--------------------------------------
.10 jsr CSH.IsLetter
bcc .20
2021-05-30 20:34:03 +00:00
* TODO: PREOPS ++ --.....
2021-05-22 21:05:12 +00:00
2021-05-30 20:34:03 +00:00
bcs .29
2021-05-22 21:05:12 +00:00
*--------------------------------------
.20 >LDYA L.CSH.TMODS
jsr CSH.LookupID
bcs .50
2021-05-30 20:34:03 +00:00
jsr CSH.tDecl
2021-05-22 21:05:12 +00:00
bcs .59
2021-05-30 20:34:03 +00:00
>STYA ZPVarType Type/Qual
2021-05-22 21:05:12 +00:00
jsr CSH.AddSymbol add with undef value...
2021-05-30 20:34:03 +00:00
bcs .29 OOM or DUP
2020-01-25 18:56:36 +00:00
2021-05-30 20:34:03 +00:00
lda ZPVarQual
bit #CSH.Q.FUNC
bne .21
2021-05-22 21:05:12 +00:00
jsr CSH.GetCharNB
bcs .99
cmp #';'
2021-05-30 20:34:03 +00:00
beq .69
2021-05-22 21:05:12 +00:00
cmp #'='
2021-05-30 20:34:03 +00:00
bne .99
2021-05-22 21:05:12 +00:00
jsr CSH.GetNextCharNB skip '='
bcs .99
2021-05-30 20:34:03 +00:00
>LDYA ZPVarType T/Q
2021-05-22 21:05:12 +00:00
jsr CSH.ExpEval
bcs .9
2019-08-28 15:21:42 +00:00
2021-05-30 20:34:03 +00:00
jsr CSH.SetVarValue Y,A Type/qual, Set value to this var
.29 bcs .9
2019-08-28 15:21:42 +00:00
2021-05-22 21:05:12 +00:00
bra .68
2019-08-28 15:21:42 +00:00
2021-05-30 20:34:03 +00:00
.21 jsr CSH.fDecl
bcs .9
2020-01-25 18:56:36 +00:00
2021-05-22 21:05:12 +00:00
bra .68
*--------------------------------------
.50 jsr CSH.SavePtr Save Ptr, in case of while,for....
2021-05-30 20:34:03 +00:00
2019-09-05 06:43:09 +00:00
>LDYA L.CSH.KW
jsr CSH.LookupID
2019-08-28 15:21:42 +00:00
bcs .6 not an internal CSH keyword....
2020-02-18 15:34:56 +00:00
2019-08-27 15:13:00 +00:00
jsr CSH.KW.JMP
2021-05-22 21:05:12 +00:00
.59 bcs .9
2021-05-30 20:34:03 +00:00
bra .8
*--------------------------------------
.6 jsr CSH.GetVar I = ?
2019-08-28 15:21:42 +00:00
bcs .7
2019-02-13 16:20:44 +00:00
2019-09-03 15:35:13 +00:00
>STYA ZPVarID
2020-02-21 13:24:16 +00:00
jsr CSH.GetVarDef Get Type & ptr...
bcs .9
2020-07-31 14:46:11 +00:00
2021-05-22 21:05:12 +00:00
lda ZPVarQual
bit #CSH.Q.FUNC
beq .60
2021-05-30 20:34:03 +00:00
ldy #0 func( ?
lda #0
jsr CSH.fExec
bcs .9
bra .8
2021-05-22 21:05:12 +00:00
*--------------------------------------
.60 jsr CSH.GetCharNB
bcs .9
2020-01-25 18:56:36 +00:00
2019-09-06 12:50:27 +00:00
cmp #'=' TODO: all AOPS
bne .99
2020-01-25 18:56:36 +00:00
2019-08-27 15:13:00 +00:00
jsr CSH.GetNextChar Skip =
bcs .99
2020-01-25 18:56:36 +00:00
2021-05-30 20:34:03 +00:00
>LDYA ZPVarType T/Q
jsr CSH.ExpEval
bcs .9
2019-09-06 12:50:27 +00:00
2021-05-30 20:34:03 +00:00
jsr CSH.SetVarValue
bcs .9
2020-01-25 18:56:36 +00:00
2021-05-22 21:05:12 +00:00
.68 jsr CSH.GetCharNB
cmp #';'
2021-05-30 20:34:03 +00:00
.69 beq .8
2020-01-25 18:56:36 +00:00
2021-05-04 17:31:21 +00:00
.99 lda #E.CSYN
2020-01-25 18:56:36 +00:00
sec
.9 rts
2021-05-30 20:34:03 +00:00
*--------------------------------------
.7 ldy #0 no return value type check required
lda #0
jsr CSH.fCall Y,A = Type/Qual
2019-02-13 16:20:44 +00:00
bcs .9
2019-08-26 06:29:18 +00:00
2021-05-30 20:34:03 +00:00
jsr CSH.GetVarSize Y,A = returned value type
clc A = Sizeof, CC to ignore Pointer hMem
2020-01-23 14:48:22 +00:00
adc pStack
sta pStack Discard value on stack
2019-08-28 15:21:42 +00:00
.8 jsr CSH.GetNextCharNB Skip ;
2019-08-27 15:13:00 +00:00
bcs .9
2020-01-25 18:56:36 +00:00
2019-08-27 15:13:00 +00:00
cmp #C.CR
2019-09-03 15:35:13 +00:00
beq .80
2020-01-25 18:56:36 +00:00
2019-09-03 15:35:13 +00:00
jmp CSH.Run.1
2020-07-31 14:46:11 +00:00
2019-09-03 15:35:13 +00:00
.80 jmp CSH.GetNextChar Skip CR
2020-01-25 18:56:36 +00:00
*--------------------------------------
CSH.COMMENTS jsr CSH.GetNextChar
cmp #'/'
bne .90
jmp CSH.SkipLine skip line.....
2020-07-31 14:46:11 +00:00
2021-05-04 17:31:21 +00:00
.90 lda #E.CSYN
sec
2020-01-25 18:56:36 +00:00
rts
*--------------------------------------
2020-08-02 12:19:43 +00:00
CSH.SkipLine jsr CSH.GetNextChar
2019-02-13 16:20:44 +00:00
bcs .9
2021-05-30 20:34:03 +00:00
2019-02-13 16:20:44 +00:00
cmp #C.CR
2020-08-02 12:19:43 +00:00
bne CSH.SkipLine
2019-02-13 16:20:44 +00:00
2021-05-30 20:34:03 +00:00
jmp CSH.GetNextChar Skip CR
2020-08-02 12:19:43 +00:00
.9 rts
2019-02-13 16:20:44 +00:00
*--------------------------------------
2020-12-23 14:54:57 +00:00
CSH.SavePtr >LDYA ZPInputBufPtr
>STYA.G CSH.BufPtrSave
rts
*--------------------------------------
CSH.LookupFN sec
.HS 90 BCC
CSH.LookupID clc
>STYA ZPPtr1
ror
>STA.G CSH.LookupOpt
jsr CSH.GetIDLen
bra CSH.Lookup
CSH.LookupOP >STYA ZPPtr1
>STZ.G CSH.LookupOpt
jsr CSH.GetOPLen
CSH.Lookup phy Y = len
ldx #0
2020-12-23 14:54:57 +00:00
.1 lda (ZPPtr1)
beq .9 Ending 0, not found....
2020-12-23 14:54:57 +00:00
pla
pha Get Back Len
cmp (ZPPtr1) Same Len ?
bne .4
2020-12-23 14:54:57 +00:00
tay
.2 lda (ZPPtr1),y
.3 dey
2020-12-23 14:54:57 +00:00
cmp (ZPInputBufPtr),y
bne .4
2020-12-23 14:54:57 +00:00
tya
bne .2
2020-12-23 14:54:57 +00:00
pla Found keyword...
clc
2020-12-23 14:54:57 +00:00
adc ZPInputBufPtr ..advance Ptr to char after it..
sta ZPInputBufPtr
bcc .31
2020-12-23 14:54:57 +00:00
inc ZPInputBufPtr+1
.31 lda ZPPtr1
sec
adc (ZPPtr1)
2019-08-26 06:29:18 +00:00
tay
2019-02-13 16:20:44 +00:00
lda ZPPtr1+1
adc #0
2019-08-26 06:29:18 +00:00
clc Y,A = F() def, X = F() index
.8 rts
.4 inx
inx
2019-08-26 06:29:18 +00:00
lda (ZPPtr1)
jsr CSH.ZPPtr1AddAp1
>LDA.G CSH.LookupOpt
bpl .1
2020-07-31 14:46:11 +00:00
2021-05-30 20:34:03 +00:00
ldy #$0 Start at Y=2 for VOID func()
2020-01-24 14:21:08 +00:00
.6 iny
2021-05-30 20:34:03 +00:00
iny
lda (ZPPtr1),y
bne .6
2020-07-31 14:46:11 +00:00
tya
2019-08-26 06:29:18 +00:00
jsr CSH.ZPPtr1AddAp1
bra .1
2020-07-31 14:46:11 +00:00
.9 pla
sec
rts
*--------------------------------------
2021-06-06 19:06:49 +00:00
CSH.MainExec lda #0
>PUSHA
ldy #S.PS.ARGC
lda (pPS),y
>PUSHA push int ARGC
>PUSHW ZPCSHConst push int ARGV
stz ArgIndex
.1 lda ArgIndex
>SYSCALL ArgC
bcs .2
inc ArgIndex
pha
tya
sta (ZPCSHConst)
pla
ldy #1
sta (ZPCSHConst),y
lda ZPCSHConst
* clc
adc #2
sta ZPCSHConst
bcc .1
inc ZPCSHConst+1
bra .1
.2
*--------------------------------------
2021-05-30 20:34:03 +00:00
CSH.ZPPtr1GetNextW
jsr CSH.ZPPtr1NextW
*--------------------------------------
CSH.ZPPtr1GetW lda (ZPPtr1)
beq .8
pha
ldy #1
lda (ZPPtr1),y
ply
.8 rts
*--------------------------------------
CSH.ZPPtr1NextW jsr .1
.1 inc ZPPtr1
2020-01-24 14:21:08 +00:00
bne .8
2021-05-30 20:34:03 +00:00
2020-01-24 14:21:08 +00:00
inc ZPPtr1+1
2021-05-30 20:34:03 +00:00
2020-07-31 14:46:11 +00:00
.8 rts
2020-01-24 14:21:08 +00:00
*--------------------------------------
2019-02-13 16:20:44 +00:00
CSH.ZPPtr1AddAp1
sec
2020-07-31 14:46:11 +00:00
adc ZPPtr1
2019-02-13 16:20:44 +00:00
sta ZPPtr1
bcc .1
inc ZPPtr1+1
.1 rts
*--------------------------------------
2020-12-23 14:54:57 +00:00
* Input : ZPInputBufPtr
2020-02-20 16:54:51 +00:00
* Output : Y,A = VarID
*--------------------------------------
2020-08-02 12:19:43 +00:00
CSH.AddSymbol >LDA.G CSH.hSymbols
2020-02-19 16:42:05 +00:00
jsr CSH.NewKey
bcs .9
2020-01-25 18:56:36 +00:00
2020-02-20 07:41:52 +00:00
>STYA ZPVarID
2021-05-30 20:34:03 +00:00
>LDYA ZPVarType
2020-08-02 12:19:43 +00:00
jsr CSH.GetVarSize CS if pointer
2020-02-19 16:42:05 +00:00
sta ZPVarSizeOf
2021-01-12 21:14:13 +00:00
* clc / sec
2020-07-31 14:46:11 +00:00
2020-02-19 16:42:05 +00:00
lda ZPCSHData
sta ZPVarDataPtr
adc ZPVarSizeOf
sta ZPCSHData
2020-07-31 14:46:11 +00:00
2020-02-19 16:42:05 +00:00
lda ZPCSHData+1
sta ZPVarDataPtr+1
adc ZPVarSizeOf+1
sta ZPCSHData+1
2020-07-31 14:46:11 +00:00
2020-02-19 16:42:05 +00:00
>LDA.G CSH.DataPtr
clc
adc ZPVarSizeOf
sta (pData),y
2020-07-31 14:46:11 +00:00
2020-02-19 16:42:05 +00:00
bcs .99
2020-07-31 14:46:11 +00:00
2021-05-30 20:34:03 +00:00
jsr CSH.GetCharNB
bcs .8
cmp #'('
beq .7
lda ZPVarQual
and #CSH.Q.FUNC
beq .8
lda #E.CSYN
sec
rts
.7 lda #CSH.Q.FUNC
tsb ZPVarQual
lda ZPCSHfDecl
sta ZPVarDefPtr
lda ZPCSHfDecl+1
sta ZPVarDefPtr+1
.8 >PUSHB.G CSH.hSymbols
2020-02-19 16:42:05 +00:00
>PUSHW ZPVarID
>PUSHWI ZPVarDef
2021-05-30 20:34:03 +00:00
>PUSHWI 8
2020-02-19 16:42:05 +00:00
>SYSCALL SListAddData
.9 rts
2021-05-04 17:31:21 +00:00
.99 lda #E.OOM
2021-05-22 21:05:12 +00:00
* sec
2020-02-19 16:42:05 +00:00
rts
*--------------------------------------
2021-05-30 20:34:03 +00:00
* ZPVarDataPtr = fDef
*--------------------------------------
CSH.fExec ldx ZPPtr1
phx
ldx ZPPtr1+1 local : fdef Ptr
phx
ldx ZPPtr2 local : type
phx
ldx ZPPtr2+1 local : qual
phx
ldx ZPPtr3 local : variadic size
phx
ldx ZPPtr3+1 local : f
phx
2021-05-14 20:58:20 +00:00
2021-05-30 20:34:03 +00:00
>STYA ZPPtr2 save Type/qual
>LDYA ZPVarDefPtr
>STYA ZPPtr1
stz ZPPtr3 Reset VARIADIC byte count
jsr CSH.GetNextCharNB skip '('
bcs .10
jsr CSH.ZPPtr1GetW Y,A = Return value Type/Qual
ldx ZPPtr2
beq .1 no check required
cpy ZPPtr2
bne .91
cmp ZPPtr2+1
bne .91
.1 eor #CSH.Q.FUNC
>STYA ZPPtr2 this will be the returned type/qual
jsr CSH.ZPPtr1GetNextW advance to arg list type
beq .7 end of list, go check ending ')'
*--------------------------------------
.3 cpy #CSH.T.VARIADIC if VARIADIC, don't advance to next arg and assume type = 0
bne .4
ldy #0
lda #0
.4 jsr CSH.ExpEval Y,A = 0 if VARIADIC
bcs .93
jsr CSH.GetVarSize Y,A = Var Type/Qual
tax
lda (ZPPtr1)
eor #CSH.T.VARIADIC
bne .5
txa
clc make sure pointer only 2 bytes
adc ZPPtr3
sta ZPPtr3 Add to byte count
bra .51 stay on VARIADIC tag
.5 jsr CSH.ZPPtr1NextW
.51 jsr CSH.GetCharNB
.10 bcs .90
cmp #','
bne .6
jsr CSH.GetNextCharNB Skip ','
jsr CSH.ZPPtr1GetW
bne .3 Another ARG....
.52 bra .90 extra args....error
.6 cmp #')'
bne .90
jsr CSH.ZPPtr1GetW
beq .8 no more arg after ')', exit
cpy #CSH.T.VARIADIC
bne .90 missing arg
>PUSHB ZPPtr3 push VARIADIC byte count
.7 jsr CSH.GetCharNB
bcs .90
cmp #')'
bne .90
.8 jsr CSH.GetNextCharNB Skip )
* ldx ZPPtr3+1
* jsr CSH.Exec
* bcs .93
>LDYA ZPPtr2 type/qual
bra .93
.90 lda #E.CSYN
bra .92
.91 lda #E.TMISMATCH
.92 sec
.93 plx
stx ZPPtr3+1
plx
stx ZPPtr3
plx
stx ZPPtr2+1
plx
stx ZPPtr2
plx
stx ZPPtr1+1
plx
stx ZPPtr1
.99 rts
*--------------------------------------
CSH.fDecl >ENTER 2
lda #0
sta (pStack) hLocal
lda ZPVarType
2021-05-22 21:05:12 +00:00
jsr CSH.fDeclAddA
2021-05-30 20:34:03 +00:00
lda ZPVarQual
2021-05-22 21:05:12 +00:00
jsr CSH.fDeclAddA
2021-05-30 20:34:03 +00:00
2020-08-02 12:19:43 +00:00
jsr CSH.GetNextCharNB Skip (
bcs .9
2020-12-23 14:54:57 +00:00
2020-08-02 12:19:43 +00:00
.1 cmp #')'
2021-05-30 20:34:03 +00:00
beq .6
2021-01-12 21:14:13 +00:00
2021-05-22 21:05:12 +00:00
.2 jsr CSH.fDeclGetArg
2021-01-12 21:14:13 +00:00
bcs .99
2021-05-30 20:34:03 +00:00
pha
tya
jsr CSH.fDeclAddA
pla
jsr CSH.fDeclAddA
2021-05-22 21:05:12 +00:00
jsr CSH.GetCharNB
bcs .9
2021-05-30 20:34:03 +00:00
jsr CSH.IsLetter
bcs .5
2021-05-22 21:05:12 +00:00
2021-05-30 20:34:03 +00:00
* TODO: AddLocal
.3 jsr CSH.GetNextCharNB
bcs .9
jsr CSH.IsLetterOrDigit
bcc .3
2021-05-22 21:05:12 +00:00
2021-05-30 20:34:03 +00:00
.5 cmp #')'
beq .6
2021-05-22 21:05:12 +00:00
cmp #','
bne .9
2021-05-30 20:34:03 +00:00
2021-05-22 21:05:12 +00:00
jsr CSH.GetNextCharNB Skip ,
bcs .9
2021-05-30 20:34:03 +00:00
2021-05-22 21:05:12 +00:00
bra .2
2021-01-12 21:14:13 +00:00
2021-05-30 20:34:03 +00:00
.6 jsr CSH.GetNextCharNB Skip )
2021-05-22 21:05:12 +00:00
bcs .9
2021-01-12 21:14:13 +00:00
2021-05-22 21:05:12 +00:00
cmp #';'
2021-05-30 20:34:03 +00:00
beq .7
* TODO: f() body
bra .9
*--------------------------------------
.7 lda #0
* sta ZPVarDataPtr
* sta ZPVarDataPtr+1
2021-05-22 21:05:12 +00:00
.8 lda #0
2021-05-30 20:34:03 +00:00
jsr CSH.fDeclAddA
clc
bra .99
2021-01-12 21:14:13 +00:00
2021-05-04 17:31:21 +00:00
.9 lda #E.CSYN
2021-01-12 21:14:13 +00:00
sec
2021-05-30 20:34:03 +00:00
.99 >LEAVE
rts
2021-01-12 21:14:13 +00:00
*--------------------------------------
2021-05-30 20:34:03 +00:00
CSH.fDeclGetArg lda (ZPInputBufPtr)
cmp #'.'
bne .5
ldx #2
.1 jsr CSH.GetNextChar
bcs .9
cmp #'.'
bne .9
dex
bne .1
jsr CSH.GetNextCharNB
bcs .9
eor #')'
bne .9
ldy #CSH.T.VARIADIC Type
* lda #0 Qual
* clc
rts
.5 >LDYA L.CSH.TMODS
2020-08-02 12:19:43 +00:00
jsr CSH.LookupID
bcs .9
2021-05-30 20:34:03 +00:00
2021-05-22 21:05:12 +00:00
jsr CSH.tDecl
bcs .9
2021-05-30 20:34:03 +00:00
* Y,A = Type/Qual
2021-01-12 21:14:13 +00:00
bra .8
2021-05-30 20:34:03 +00:00
2021-05-04 17:31:21 +00:00
.9 lda #E.CSYN
2020-08-02 12:19:43 +00:00
sec
2021-05-22 21:05:12 +00:00
2021-05-30 20:34:03 +00:00
.8 rts
2020-08-02 12:19:43 +00:00
*--------------------------------------
2021-05-22 21:05:12 +00:00
CSH.fDeclAddA sta (ZPCSHfDecl)
inc ZPCSHfDecl
bne .8
2021-05-30 20:34:03 +00:00
2021-05-22 21:05:12 +00:00
inc ZPCSHfDecl+1
2021-05-30 20:34:03 +00:00
.8 rts
2021-05-22 21:05:12 +00:00
*--------------------------------------
2021-05-30 20:34:03 +00:00
CSH.tDecl >ENTER 2
lda #0
sta (pStack) Type
ldy #1
sta (pStack),y Qual
jsr .7
bcs .99
ldy #1
lda (pStack),y
pha
lda (pStack)
tay Y = Type
pla A = Qual
clc
2021-05-22 21:05:12 +00:00
2021-05-30 20:34:03 +00:00
.99 >LEAVE
rts
.7 jmp (J.CSH.TMODS,x)
2021-05-22 21:05:12 +00:00
*--------------------------------------
2020-02-19 16:42:05 +00:00
CSH.NewKey >PUSHA
2020-12-23 14:54:57 +00:00
>PUSHW ZPInputBufPtr
2019-08-26 06:29:18 +00:00
>SYSCALL SListNewKey
bcs .9
2020-02-18 15:34:56 +00:00
2020-02-20 16:54:51 +00:00
pha
2021-05-30 20:34:03 +00:00
phy
2019-08-26 06:29:18 +00:00
txa
* clc
2020-12-23 14:54:57 +00:00
adc ZPInputBufPtr
sta ZPInputBufPtr
bcc .1
2020-07-31 14:46:11 +00:00
2020-12-23 14:54:57 +00:00
inc ZPInputBufPtr+1
2020-07-31 14:46:11 +00:00
2020-02-19 16:42:05 +00:00
.1 clc
2021-05-30 20:34:03 +00:00
ply
2020-02-20 16:54:51 +00:00
pla
2019-09-03 15:35:13 +00:00
.9 rts
*--------------------------------------
2021-05-30 20:34:03 +00:00
* Y,A = Type/Qual
2019-09-03 15:35:13 +00:00
*--------------------------------------
2021-05-30 20:34:03 +00:00
CSH.SetVarValue cpy ZPVarType
2020-02-19 16:42:05 +00:00
bne .99
2019-08-26 06:29:18 +00:00
2021-05-30 20:34:03 +00:00
cmp ZPVarQual
bne .99
2020-02-19 16:42:05 +00:00
ldy #0
2020-07-31 14:46:11 +00:00
2020-02-19 16:42:05 +00:00
.1 lda (pStack)
sta (ZPVarDataPtr),y
inc pStack
2019-09-03 15:35:13 +00:00
iny
2020-02-19 16:42:05 +00:00
cpy ZPVarSizeOf
2019-09-03 15:35:13 +00:00
bne .1
2020-07-31 14:46:11 +00:00
2020-02-19 16:42:05 +00:00
clc
2019-09-03 15:35:13 +00:00
rts
2020-07-31 14:46:11 +00:00
2021-05-04 17:31:21 +00:00
.99 lda #E.TMISMATCH
2020-02-19 16:42:05 +00:00
sec
2019-10-03 06:25:27 +00:00
rts
*--------------------------------------
2020-02-18 15:34:56 +00:00
CSH.GetDefine >PUSHB.G CSH.hDefines
2020-01-26 19:36:49 +00:00
jsr CSH.Get
bcs .9
2020-07-31 14:46:11 +00:00
2020-01-26 19:36:49 +00:00
pha
2020-02-18 15:34:56 +00:00
phy
>PUSHB.G CSH.hDefines
ply
2020-01-26 19:36:49 +00:00
pla
>PUSHYA KeyID
2020-02-18 15:34:56 +00:00
>PUSHWZ Allocate..
>PUSHWZ len = 0 (string mode)
>PUSHWZ From Start
2020-01-26 19:36:49 +00:00
>SYSCALL SListGetData
2020-07-31 14:46:11 +00:00
bcs .9
2020-01-26 19:36:49 +00:00
2020-12-23 14:54:57 +00:00
stx hDefine
2020-07-31 14:46:11 +00:00
2020-12-23 14:54:57 +00:00
>LDYA ZPInputBufPtr
>STYA.G CSH.SaveDefine
2020-07-31 14:46:11 +00:00
2020-01-26 19:36:49 +00:00
txa
2020-02-28 07:21:46 +00:00
>SYSCALL GetMemPtr
2020-12-23 14:54:57 +00:00
>STYA ZPInputBufPtr
2020-01-26 19:36:49 +00:00
2020-07-31 14:46:11 +00:00
.9 rts
2020-01-26 19:36:49 +00:00
*--------------------------------------
2020-02-18 15:34:56 +00:00
CSH.GetVar >PUSHB.G CSH.hSymbols
2020-07-31 14:46:11 +00:00
2020-12-23 14:54:57 +00:00
CSH.Get >PUSHW ZPInputBufPtr
2020-02-18 15:34:56 +00:00
>SYSCALL SListLookup
2019-08-26 06:29:18 +00:00
bcs .9
2019-09-03 15:35:13 +00:00
pha
2019-08-26 06:29:18 +00:00
txa
* clc
2020-12-23 14:54:57 +00:00
adc ZPInputBufPtr
sta ZPInputBufPtr
2019-08-26 06:29:18 +00:00
bcc .1
2021-05-30 20:34:03 +00:00
2020-12-23 14:54:57 +00:00
inc ZPInputBufPtr+1
2019-08-26 15:27:28 +00:00
clc
2021-05-30 20:34:03 +00:00
2019-09-03 15:35:13 +00:00
.1 pla Y,A = VarID
2021-05-30 20:34:03 +00:00
2019-09-03 15:35:13 +00:00
.9 rts
2019-08-26 15:27:28 +00:00
*--------------------------------------
2020-02-21 13:24:16 +00:00
CSH.GetVarDef phy
pha
>PUSHB.G CSH.hSymbols
2020-07-31 14:46:11 +00:00
2020-02-21 13:24:16 +00:00
pla
>PUSHA
pla
>PUSHA KeyID
>PUSHWI ZPVarDef
2021-05-30 20:34:03 +00:00
>PUSHWI 8 8 bytes
2021-07-24 20:42:23 +00:00
>PUSHWZ From Start
2019-08-26 15:27:28 +00:00
>SYSCALL SListGetData
2019-09-05 15:49:05 +00:00
rts
*--------------------------------------
2021-05-30 20:34:03 +00:00
* Input : Value on Stack, Y,A = Type/Qual
2019-08-29 15:49:03 +00:00
* Output : CC = true, CS = false
*--------------------------------------
2021-05-30 20:34:03 +00:00
CSH.IsValue0 cpy #CSH.T.FLOAT
2019-08-29 15:49:03 +00:00
bcc .1 char,int,long
2020-02-19 16:42:05 +00:00
2021-05-30 20:34:03 +00:00
lda CSH.TYPESIZE-1,y
2020-02-19 16:42:05 +00:00
lda (ZPVarDataPtr),y
bne .9
2020-07-31 14:46:11 +00:00
.8 clc
rts
2020-07-31 14:46:11 +00:00
2020-02-21 16:31:46 +00:00
.1 jsr CSH.GetVarSize
tax
2019-09-05 06:43:09 +00:00
lda #0
2019-09-05 06:43:09 +00:00
.2 ora (pStack)
inc pStack
dex
bne .2
2020-07-31 14:46:11 +00:00
tax
beq .8
2020-07-31 14:46:11 +00:00
.9 sec
rts
*--------------------------------------
* Stack
*--------------------------------------
2019-09-05 06:43:09 +00:00
CSH.CheckStack tax
>LDA.G CSH.StackPtr
beq .9
2020-01-23 14:48:22 +00:00
2019-09-05 06:43:09 +00:00
tay
txa
cmp (ZPCSHStack),y
bne .9
2020-01-23 14:48:22 +00:00
2019-09-05 06:43:09 +00:00
clc
rts
2020-07-31 14:46:11 +00:00
2021-05-04 17:31:21 +00:00
.9 lda #E.CSYN
2019-09-05 06:43:09 +00:00
sec
rts
*--------------------------------------
CSH.Push pha
>LDA.G CSH.StackPtr
2020-01-23 14:48:22 +00:00
dec
beq .9
sta (pData),y
tay
pla
sta (ZPCSHStack),y
clc
rts
2020-07-31 14:46:11 +00:00
.9 pla
2021-05-04 17:31:21 +00:00
lda #E.STKOVERFLOW
sec
rts
*--------------------------------------
CSH.Pop >LDA.G CSH.StackPtr
beq .9
2021-05-04 17:31:21 +00:00
2020-07-31 14:46:11 +00:00
pha
2020-01-23 14:48:22 +00:00
inc
sta (pData),y
2020-01-23 14:48:22 +00:00
ply
lda (ZPCSHStack),y
clc
rts
2021-05-04 17:31:21 +00:00
.9 lda #E.STACKERROR
sec
2019-10-03 06:25:27 +00:00
rts
*--------------------------------------
* CHAR related Subs.....
*--------------------------------------
CSH.GetOPLen ldy #0
.1 iny
2020-12-23 14:54:57 +00:00
lda (ZPInputBufPtr),y
beq .8
jsr CSH.IsOPChar
bcc .1
.8 tya
rts
*--------------------------------------
CSH.GetIDLen ldy #0
.1 iny
2020-12-23 14:54:57 +00:00
lda (ZPInputBufPtr),y
beq .8
jsr CSH.IsLetterOrDigit
bcc .1
.8 tya
rts
*--------------------------------------
2019-09-05 15:49:05 +00:00
CSH.SkipStatement
clc
rts
*--------------------------------------
CSH.SkipBlock ldy #0 not in "", TOTO:skip comments
ldx #1 starting with 1 '{' for now....
2019-09-05 06:43:09 +00:00
.1 jsr CSH.GetNextCharNB
bcs .9
2021-05-30 20:34:03 +00:00
2019-09-05 06:43:09 +00:00
cmp #'{'
bne .2
2021-05-30 20:34:03 +00:00
2019-09-05 15:49:05 +00:00
tya
bmi .1
2021-05-30 20:34:03 +00:00
2019-09-05 06:43:09 +00:00
inx
bra .1
.2 cmp #'}'
2019-09-05 15:49:05 +00:00
bne .3
tya
bmi .1
2021-05-30 20:34:03 +00:00
2019-09-05 06:43:09 +00:00
dex
bne .1
2021-05-30 20:34:03 +00:00
2019-09-06 12:50:27 +00:00
clc
rts
2019-09-05 15:49:05 +00:00
.3 cmp #'"'
bne .1
2021-05-30 20:34:03 +00:00
2019-09-05 15:49:05 +00:00
tya
eor #$ff
tay
bra .1
2021-05-30 20:34:03 +00:00
2019-10-03 06:25:27 +00:00
.9 rts
2019-09-05 06:43:09 +00:00
*--------------------------------------
CSH.GetCharNB jsr CSH.GetChar
bcs CSH.GetNextCharNB.RTS
2021-05-30 20:34:03 +00:00
jsr CSH.CheckCharNB
2020-07-31 14:46:11 +00:00
bcc CSH.GetNextCharNB.RTS
*--------------------------------------
CSH.GetNextCharNB
jsr CSH.GetNextChar
bcs CSH.GetNextCharNB.RTS
2021-05-30 20:34:03 +00:00
jsr CSH.CheckCharNB
bcs CSH.GetNextCharNB
2021-05-30 20:34:03 +00:00
CSH.GetNextCharNB.RTS
rts
*--------------------------------------
2020-01-25 18:56:36 +00:00
CSH.CheckSpace jsr CSH.GetChar
bcs .90
2021-05-30 20:34:03 +00:00
2020-01-25 18:56:36 +00:00
cmp #C.SPACE
bne .90
jsr CSH.GetNextCharNB
2021-05-30 20:34:03 +00:00
bcc .99
2020-07-31 14:46:11 +00:00
2021-05-04 17:31:21 +00:00
.90 lda #E.CSYN
2020-01-25 18:56:36 +00:00
sec
2021-05-30 20:34:03 +00:00
.99 rts
2020-01-25 18:56:36 +00:00
*--------------------------------------
2018-11-10 14:30:09 +00:00
CSH.CheckCharNB cmp #C.SPACE
beq .9
2021-05-30 20:34:03 +00:00
2018-11-10 14:30:09 +00:00
cmp #C.LF
beq .9
2021-05-30 20:34:03 +00:00
2018-11-10 14:30:09 +00:00
cmp #C.TAB
beq .9
2021-05-30 20:34:03 +00:00
clc
2019-10-03 06:25:27 +00:00
.9 rts
*--------------------------------------
2020-12-23 14:54:57 +00:00
CSH.GetNextChar inc ZPInputBufPtr
bne CSH.GetChar
2021-05-30 20:34:03 +00:00
2020-12-23 14:54:57 +00:00
inc ZPInputBufPtr+1
*--------------------------------------
2020-12-23 14:54:57 +00:00
CSH.GetChar lda (ZPInputBufPtr)
2020-01-26 19:36:49 +00:00
bne .8
2020-12-23 14:54:57 +00:00
lda hDefine
beq .1
2020-07-31 14:46:11 +00:00
2020-12-23 14:54:57 +00:00
stz hDefine
2020-07-31 14:46:11 +00:00
2020-01-26 19:36:49 +00:00
phx
phy
2020-02-28 07:21:46 +00:00
>SYSCALL FreeMem
2020-12-23 14:54:57 +00:00
>LDYA.G CSH.SaveDefine
>STYA ZPInputBufPtr
2020-01-26 19:36:49 +00:00
ply
plx
2020-12-23 14:54:57 +00:00
bra CSH.GetChar
2021-01-12 21:14:13 +00:00
2020-12-23 14:54:57 +00:00
.1 lda hInclude
beq .9
2021-01-12 21:14:13 +00:00
2020-12-23 14:54:57 +00:00
stz hInclude
phx
phy
>SYSCALL FreeMem
2020-01-26 19:36:49 +00:00
2020-12-23 14:54:57 +00:00
>LDYA.G CSH.SaveInclude
>STYA ZPInputBufPtr
2020-01-26 19:36:49 +00:00
2020-12-23 14:54:57 +00:00
ply
plx
2020-01-26 19:36:49 +00:00
bra CSH.GetChar
.8 clc
rts
2020-01-26 19:36:49 +00:00
.9 lda #MLI.E.EOF
sec
rts
*---------------------------------------
2021-05-22 21:05:12 +00:00
CSH.IsEndArg
*---------------------------------------
2019-02-07 16:52:25 +00:00
CSH.IsOPChar ldx #CSH.OPChars.Cnt-1
.1 cmp CSH.OPChars,x
beq .8
2021-05-22 21:05:12 +00:00
dex
bpl .1
2021-05-22 21:05:12 +00:00
sec
rts
2021-05-22 21:05:12 +00:00
.8 clc
2019-10-03 06:25:27 +00:00
rts
*---------------------------------------
CSH.IsLetterOrDigit
jsr CSH.IsDigit10
bcc CSH.IsLetterRTS
*---------------------------------------
CSH.IsLetter cmp #'_'
bne .1
2021-05-22 21:05:12 +00:00
clc
rts
2021-05-22 21:05:12 +00:00
.1 cmp #'A'
bcc .9
2021-05-22 21:05:12 +00:00
cmp #'Z'+1
bcc CSH.IsLetterRTS
cmp #'a'
bcc .9
2021-05-22 21:05:12 +00:00
cmp #'z'+1
2021-05-22 21:05:12 +00:00
rts CC if lowercase
.9 sec
2019-10-03 06:25:27 +00:00
CSH.IsLetterRTS rts
*---------------------------------------
CSH.IsDigit10 cmp #'0'
bcc .9
2021-05-30 20:34:03 +00:00
cmp #'9'+1
rts cc if ok, cs if not
2021-05-30 20:34:03 +00:00
.9 sec
rts
2016-08-17 06:25:58 +00:00
*--------------------------------------
2021-05-30 20:34:03 +00:00
* in : Y,A = type/qual
* out : A = size
2019-09-03 15:35:13 +00:00
*--------------------------------------
2021-05-30 20:34:03 +00:00
CSH.GetVarSize and #CSH.Q.PPPOINTER
2019-09-02 06:09:28 +00:00
bne .2
2020-07-31 14:46:11 +00:00
2021-05-30 20:34:03 +00:00
lda CSH.TYPESIZE-1,y
2020-08-02 12:19:43 +00:00
clc
2019-09-02 06:09:28 +00:00
rts
2020-01-23 14:48:22 +00:00
2021-05-30 20:34:03 +00:00
.2 lda #2 pointer
sec +1 for hMem Storage
2019-09-02 06:09:28 +00:00
rts
*--------------------------------------
2016-08-17 06:25:58 +00:00
MAN
2020-07-31 14:46:11 +00:00
SAVE usr/src/bin/csh.s.core
LOAD usr/src/bin/csh.s
2016-08-17 06:25:58 +00:00
ASM