A2osX/BIN/CSH.S.CORE.txt

1147 lines
19 KiB
Plaintext
Raw Normal View History

NEW
2019-06-28 15:15:58 +00:00
AUTO 3,1
2016-08-17 06:25:58 +00:00
.LIST OFF
*--------------------------------------
2019-08-26 06:29:18 +00:00
CSH.Init >SYSCALL SListNew
bcs .9
>STA.G CSH.hSymbols
>LDYAI 256
2018-07-13 14:38:24 +00:00
>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
2019-02-13 16:20:44 +00:00
>STYA ZPCSHStack
txa
>STA.G CSH.hStack
2019-02-13 16:20:44 +00:00
lda #$0
>STA.G CSH.ConstPtr
>STA.G CSH.StackPtr
sta (ZPCSHConst)
sta (ZPCSHStack)
* clc
.9 rts
*--------------------------------------
2019-08-26 06:29:18 +00:00
CSH.Quit >LDA.G CSH.hSymbols
>SYSCALL SListFree
2018-10-16 15:48:03 +00:00
2019-08-26 06:29:18 +00:00
>LDA.G hFileBuf
jsr .7
>LDA.G CSH.hStack
jsr .7
2018-10-16 15:48:03 +00:00
2019-08-26 06:29:18 +00:00
>LDA.G CSH.hConst
jsr .7
2018-10-16 15:48:03 +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
2018-11-08 16:45:05 +00:00
2019-08-28 15:21:42 +00:00
CSH.Run.1 cmp #'#'
bne .3 comments ...
.1 jsr CSH.GetNextChar
bcs .2
cmp #C.CR
bne .1
2019-08-28 15:21:42 +00:00
.2 jmp CSH.GetNextChar Skip CR and exit
.3 cmp #C.CR
beq .2
cmp #'}' End of block ?
bne .4
jsr CSH.CheckStack must be something on stack....
bcs .9
jsr CSH.Pop was expected, get stacked Cmd...
tax
jmp (J.CSH.KW.END,x)
2019-08-28 15:21:42 +00:00
.4 pha
jsr CSH.SavePtr Save Ptr, in case of while,for....
pla
jsr CSH.IsLetter
2019-08-28 15:21:42 +00:00
bcc .5
2019-08-28 15:21:42 +00:00
bra .99 error, todo : PREOPS ++ --.....
2019-08-28 15:21:42 +00:00
.5 >LDYA L.CSH.KW
jsr CSH.LookupID
2019-08-28 15:21:42 +00:00
bcs .6 not an internal CSH keyword....
txa
>STA.G CSH.CmdSave
2019-08-27 15:13:00 +00:00
jsr CSH.KW.JMP
bcs .9
2019-08-28 15:21:42 +00:00
bra .8
2019-08-28 15:21:42 +00:00
.6 jsr CSH.GetVar
bcs .7
2019-02-13 16:20:44 +00:00
jsr CSH.GetCharNB
bcs .9
cmp #'='
bne .99
2019-08-27 15:13:00 +00:00
jsr CSH.GetNextChar Skip =
bcs .99
jsr CSH.ExpEval
bcs .9
2019-08-26 15:27:28 +00:00
jsr CSH.SetVarValue
bcs .9
jsr CSH.GetChar
cmp #';'
bne .99
2016-08-17 06:25:58 +00:00
2019-08-28 15:21:42 +00:00
bra .8
2019-08-28 15:21:42 +00:00
.7 lda #0 no return value type check required
2019-08-26 06:29:18 +00:00
jsr CSH.FnEval X = function index
2019-02-13 16:20:44 +00:00
bcs .9
2019-08-26 06:29:18 +00:00
2019-08-28 15:21:42 +00:00
.8 jsr CSH.GetNextCharNB Skip ;
2019-08-27 15:13:00 +00:00
bcs .9
cmp #C.CR
bne CSH.Run.1
jmp CSH.GetNextChar Skip CR
2019-02-13 16:20:44 +00:00
.99 lda #CSH.E.SYNTAX
sec
.9 rts
2016-08-17 06:25:58 +00:00
*--------------------------------------
2019-08-26 06:29:18 +00:00
* Built in Keywords
*--------------------------------------
2019-08-27 15:13:00 +00:00
CSH.KW.JMP jmp (J.CSH.KW,x)
CSH.WHILE
CSH.IF jsr CSH.GetCharNB
bcs .9
cmp #'('
bne .9
jsr CSH.GetNextCharNB
bcs .9
jsr CSH.ExpEval
bcs .99
jsr CSH.GetCharNB
bcs .99
cmp #')'
bne .9
jsr CSH.GetNextCharNB
bcs .99
cmp #'{'
bne .9
2019-08-26 15:27:28 +00:00
jsr CSH.IsValue0
bcc .6 Value=0, skip {{....}}
jsr CSH.GetNextCharNB Skip '{'
bcs .99
2017-11-14 16:57:34 +00:00
>LDA.G CSH.CmdSave get back Token ("IF" or "WHILE")
tax
jsr CSH.Keyword.start
bcs .99
lda #'}' Tell '}' is expected at the end of block
jsr CSH.Push
bcs .99
rts
.6 ldx #1 expecting 1 '}' for now....
.7 jsr CSH.GetNextChar
bcs .9
cmp #'{'
bne .71
inx
bra .7
.71 cmp #'}'
bne .7
txa
beq .9
dex
bne .7
jsr CSH.GetNextChar
clc
rts
.9 lda #CSH.E.SYNTAX
sec
.99 rts
CSH.Keyword.Start
jmp (J.CSH.KW.START,x)
*--------------------------------------
2017-11-14 16:57:34 +00:00
CSH.IF.START jmp CSH.Push Push "IF" Token
*--------------------------------------
CSH.WHILE.START pha
>LDA.G CSH.BufPtrSave+1 WHILE : push loop address...
jsr CSH.Push
>LDA.G CSH.BufPtrSave
jsr CSH.Push
pla
2017-11-14 16:57:34 +00:00
jmp CSH.Push Push "WHILE" Token
*--------------------------------------
CSH.IF.END jsr CSH.GetNextChar just skip ending '}'
clc
rts
*--------------------------------------
CSH.WHILE.END jsr CSH.Pop
2018-11-10 14:30:09 +00:00
sta ZPFileBufPtr
jsr CSH.Pop
2018-11-10 14:30:09 +00:00
sta ZPFileBufPtr+1
clc
rts
*--------------------------------------
CSH.ELSE
CSH.DO
CSH.FOR
CSH.SWITCH
CSH.CASE
CSH.BREAK
CSH.CONTINUE
lda #CSH.E.SYNTAX
sec
rts
*--------------------------------------
2019-08-26 06:29:18 +00:00
* Built in Types
*--------------------------------------
CSH.SIGNED jsr CSH.GetChar
bcs .9
2019-08-26 06:29:18 +00:00
cmp #C.SPACE
bne .9
jsr CSH.GetNextCharNB
bcs .9
>LDYA L.CSH.STYPES
jsr CSH.LookupID
bcs .9
jmp (J.CSH.STYPES,x)
.9 lda #CSH.E.SYNTAX
sec
rts
*--------------------------------------
CSH.UNSIGNED jsr CSH.GetChar
bcs .9
2019-08-26 06:29:18 +00:00
cmp #C.SPACE
bne .9
jsr CSH.GetNextCharNB
bcs .9
>LDYA L.CSH.STYPES
jsr CSH.LookupID
bcs .9
jmp (J.CSH.UTYPES,x)
.9 lda #CSH.E.SYNTAX
sec
rts
*--------------------------------------
2019-08-26 06:29:18 +00:00
CSH.CHAR ldx #CSH.T.CHAR
bra CSH.TYPE
2019-08-26 06:29:18 +00:00
CSH.UCHAR ldx #CSH.T.UCHAR
bra CSH.TYPE
2019-08-26 06:29:18 +00:00
CSH.INT ldx #CSH.T.INT
bra CSH.TYPE
2019-08-26 06:29:18 +00:00
CSH.UINT ldx #CSH.T.UINT
bra CSH.TYPE
2019-08-26 06:29:18 +00:00
CSH.LONG ldx #CSH.T.LONG
bra CSH.TYPE
2019-08-26 06:29:18 +00:00
CSH.ULONG ldx #CSH.T.ULONG
bra CSH.TYPE
2019-08-26 06:29:18 +00:00
CSH.FLOAT ldx #CSH.T.FLOAT
2019-08-26 06:29:18 +00:00
CSH.TYPE stx ZPVarType
jsr CSH.GetChar
bcs .9
2019-08-26 06:29:18 +00:00
cmp #C.SPACE
bne .9
jsr CSH.GetNextCharNB
bcs .9
jsr CSH.IsLetter
bcs .9
2019-08-26 06:29:18 +00:00
txa VAR TYPE
jsr CSH.AddVar add with undefined value...
bcs .99 OOM or DUP
2019-08-26 06:29:18 +00:00
>STYA ZPVarID
jsr CSH.GetCharNB
bcs .9
cmp #';'
beq .8 end of declaration, no value...
cmp #'='
bne .9
2019-08-27 15:13:00 +00:00
jsr CSH.GetNextCharNB Skip =
bcs .9
2019-08-26 06:29:18 +00:00
lda ZPVarType
jsr CSH.ExpEval
bcs .99
2019-08-28 15:21:42 +00:00
lda ZPVarType
2019-08-26 15:27:28 +00:00
jsr CSH.SetVarValue Update value to this var
2019-08-28 15:21:42 +00:00
bcs .99
jsr CSH.GetChar
bcs .9
cmp #';'
bne .9
2019-08-27 15:13:00 +00:00
.8 clc
rts
.90 lda #CSH.E.DUP
sec
rts
.9 lda #CSH.E.SYNTAX
sec
.99 rts
*--------------------------------------
2019-08-26 06:29:18 +00:00
* Input:
* ZPFileBufPtr, A = Expected type
* Output:
* CS, A = EC
* CC, A, Y,A or x bytes on Stack
*--------------------------------------
CSH.FnEval ldx ZPPtr1
phx
ldx ZPPtr1+1
phx
ldx ZPPtr2
phx
sta ZPPtr2 save Type
>LDYA L.CSH.FN
jsr CSH.LookupFn
phx X = function index
bcs .90
>STYA ZPPtr1 f() definition, starting at returned type
jsr CSH.GetCharNB
bcs .90
cmp #'('
bne .90
jsr CSH.GetNextCharNB skip '('
bcs .90
lda ZPPtr2 Expected type in 0, ignore
beq .1
cmp (ZPPtr1) Get Return value Type
bne .91
.1 inc ZPPtr1 advance to arg list type
bne .2
inc ZPPtr1+1
.2 lda (ZPPtr1) get type of next arg
beq .7 end of list, go check ending ')'
.3 eor #CSH.T.VARIADIC if VARIADIC, don't advance to next arg and assume type = 0
beq .4
lda (ZPPtr1) get type again...
inc ZPPtr1
bne .4
inc ZPPtr1+1
.4 jsr CSH.ExpEval
2019-08-28 15:21:42 +00:00
2019-08-26 06:29:18 +00:00
bcs .9
lda (ZPPtr1) no more arg in fn definition
beq .7
.5 jsr CSH.GetCharNB
bcs .9
cmp #','
2019-08-28 15:21:42 +00:00
bne .6
2019-08-26 06:29:18 +00:00
jsr CSH.GetNextCharNB Skip ,
lda (ZPPtr1)
bne .3 Another ARG....
2019-08-28 15:21:42 +00:00
bra .9 extra args....error
.6 cmp #')'
bne .90
lda (ZPPtr1)
eor #CSH.T.VARIADIC
beq .8
bra .90 missing arg
2019-08-26 06:29:18 +00:00
.7 jsr CSH.GetCharNB
bcs .90
2019-08-28 15:21:42 +00:00
2019-08-26 06:29:18 +00:00
cmp #')'
bne .90
2019-08-28 15:21:42 +00:00
.8 jsr CSH.GetNextCharNB Skip )
2019-08-27 15:13:00 +00:00
plx restore X = function index
pla
sta ZPPtr2
pla
sta ZPPtr1+1
pla
sta ZPPtr1
2019-08-26 06:29:18 +00:00
jmp (J.CSH.EXEC,x)
.90 lda #CSH.E.SYNTAX
.HS 2C BIT ABS
.91 lda #CSH.E.TMISMATCH
sec
2019-08-28 15:21:42 +00:00
.9 plx Discard function index
plx
2019-08-26 06:29:18 +00:00
stx ZPPtr2
plx
stx ZPPtr1+1
plx
stx ZPPtr1
2019-08-28 15:21:42 +00:00
2019-08-26 06:29:18 +00:00
.99 rts
*--------------------------------------
* Input:
* ZPFileBufPtr, A = Expected type
* Output:
* CS, A = EC
* CC, A, Y,A or x bytes on Stack
*--------------------------------------
2019-08-27 15:13:00 +00:00
CSH.ExpEval ldx ZPPtr1
phx
ldx ZPPtr1+1
phx
2019-08-28 15:21:42 +00:00
ldx ZPPtr2 local : VarType
2019-08-26 06:29:18 +00:00
phx
2019-08-28 15:21:42 +00:00
ldx ZPPtr2+1 local : BOP1
2019-08-26 06:29:18 +00:00
phx
2019-08-28 15:21:42 +00:00
sta ZPPtr2
2019-08-26 15:27:28 +00:00
2019-02-08 16:13:43 +00:00
.10 lda #$ff
2019-08-26 06:29:18 +00:00
sta ZPPtr2+1 Reset BOP1
2019-02-08 16:13:43 +00:00
jsr CSH.GetCharNB
2019-08-27 15:13:00 +00:00
bcs .33
2019-08-26 06:29:18 +00:00
.20 jsr CSH.IsLetter Fnc or Var ?
bcs .2
2019-08-26 15:27:28 +00:00
jsr CSH.GetVar
bcs .1
2019-08-27 15:13:00 +00:00
2019-08-28 15:21:42 +00:00
ldx ZPPtr2 var type
2019-08-26 15:27:28 +00:00
jsr CSH.GetVarValue Get value on stack
2019-08-28 15:21:42 +00:00
bcs .99
bra .11
2019-08-28 15:21:42 +00:00
.1 lda ZPPtr2 var type
jsr CSH.FnEval X = function index
bcs .99
bra .11
.2 jsr CSH.IsDigit10 number ?
2019-02-13 16:20:44 +00:00
bcs .3
2019-08-26 15:27:28 +00:00
jsr CSH.GetNumOnStack
2019-08-27 15:13:00 +00:00
bcs .99
.11 jsr CSH.GetCharNB
2019-08-27 15:13:00 +00:00
bcs .90
2019-08-26 06:29:18 +00:00
cmp #','
beq .8
cmp #')'
beq .8
cmp #';'
beq .8
jsr CSH.IsOPChar
2019-08-27 15:13:00 +00:00
.33 bcs .90
>LDYA L.CSH.BOPS
jsr CSH.LookupOP
2019-08-27 15:13:00 +00:00
bcs .90
2019-08-26 06:29:18 +00:00
lda ZPPtr2+1 previous OP...
bpl .5 go check precedence
2019-08-26 06:29:18 +00:00
stx ZPPtr2+1
2019-08-26 15:27:28 +00:00
jsr CSH.PushValueOnStack
jsr CSH.GetCharNB
2019-08-26 06:29:18 +00:00
bcc .20 go check for an ARG
2019-08-27 15:13:00 +00:00
bra .90
2019-02-13 16:20:44 +00:00
2019-08-26 06:29:18 +00:00
.3 cmp #'"' String literal
2019-08-27 15:13:00 +00:00
bne .90
2019-02-13 16:20:44 +00:00
jsr CSH.AddContCharP
bcs .99
jmp .11
2019-08-26 06:29:18 +00:00
.5 cpx ZPPtr2+1
2019-02-13 16:20:44 +00:00
bcs .6
* new OP has precedence, stack ACC
2019-02-13 16:20:44 +00:00
jmp .10
* Old OP has precedence, compute ACC=ARG <BOP> ACC
2019-08-26 06:29:18 +00:00
.6 lda ZPPtr2+1
2019-02-08 16:13:43 +00:00
jsr CSH.Compute
2019-08-27 15:13:00 +00:00
bcs .99
2019-02-08 16:13:43 +00:00
jsr CSH.GetCharNB
2019-08-27 15:13:00 +00:00
bcs .90
2019-02-08 16:13:43 +00:00
jmp .10
2019-08-26 06:29:18 +00:00
.8 lda ZPPtr2+1
bmi .80
2019-08-27 15:13:00 +00:00
jsr CSH.Compute
bcc .80
bcs .99
2019-08-27 15:13:00 +00:00
.90 lda #CSH.E.SYNTAX
.99 sec
.HS 90 BCC
.80 clc
plx
2019-08-26 06:29:18 +00:00
stx ZPPtr2+1
plx
stx ZPPtr2
2019-08-27 15:13:00 +00:00
plx
stx ZPPtr1+1
plx
stx ZPPtr1
2019-08-26 06:29:18 +00:00
rts
*--------------------------------------
2019-02-13 16:20:44 +00:00
CSH.AddContCharP
ldy #0
.1 jsr CSH.GetNextChar
bcs .9
cmp #C.CR
beq .9
cmp #'"'
beq .2
sta (ZPCSHConst),y
iny
bra .1
2019-08-27 15:13:00 +00:00
.2 lda #0
2019-02-13 16:20:44 +00:00
sta (ZPCSHConst),y
2019-08-27 15:13:00 +00:00
>PUSHW ZPCSHConst Push PTR on stack
2019-08-26 06:29:18 +00:00
2019-08-27 15:13:00 +00:00
tya
2019-02-13 16:20:44 +00:00
sec
adc ZPCSHConst
sta ZPCSHConst
bcc .3
inc ZPCSHConst+1
2019-08-27 15:13:00 +00:00
.3 jsr CSH.GetNextChar Skip "
2019-02-13 16:20:44 +00:00
clc
rts
.9 lda #CSH.E.SYNTAX
sec
rts
*--------------------------------------
2018-11-10 14:30:09 +00:00
CSH.SavePtr >LDYA ZPFileBufPtr
>STYA.G CSH.BufPtrSave
rts
*--------------------------------------
CSH.RestorePtr >LDYA.G CSH.BufPtrSave
2018-11-10 14:30:09 +00:00
>STYA ZPFileBufPtr
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
.1 lda (ZPPtr1)
beq .9 Ending 0, not found....
pla
pha Get Back Len
cmp (ZPPtr1) Same Len ?
bne .4
tay
.2 lda (ZPPtr1),y
.3 dey
2018-11-10 14:30:09 +00:00
cmp (ZPFileBufPtr),y
bne .4
tya
bne .2
pla Found keyword...
clc
2018-11-10 14:30:09 +00:00
adc ZPFileBufPtr ..advance Ptr to char after it..
sta ZPFileBufPtr
bcc .31
2018-11-10 14:30:09 +00:00
inc ZPFileBufPtr+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
2019-08-26 06:29:18 +00:00
>LDA.G CSH.LookupOpt
bpl .1
ldy #$ff
.6 iny
lda (ZPPtr1),y
bne .6
tya
2019-08-26 06:29:18 +00:00
jsr CSH.ZPPtr1AddAp1
bra .1
.9 pla
sec
rts
*--------------------------------------
2019-02-13 16:20:44 +00:00
CSH.ZPPtr1AddAp1
sec
adc ZPPtr1
sta ZPPtr1
bcc .1
inc ZPPtr1+1
.1 rts
*--------------------------------------
2019-08-26 15:27:28 +00:00
CSH.GetNumOnStack
lda ZPVarType
cmp #CSH.T.FLOAT
bcc .1
2019-02-07 16:52:25 +00:00
2018-11-10 14:30:09 +00:00
>PUSHWI ZPFileBufPtr
>LDYA ZPFileBufPtr
>SYSCALL StrToF
2019-08-27 15:13:00 +00:00
clc
rts
.1 >PUSHBI 10
2018-11-10 14:30:09 +00:00
>PUSHWI ZPFileBufPtr
>LDYA ZPFileBufPtr
>SYSCALL StrToL
2019-08-26 15:27:28 +00:00
.9 rts
*--------------------------------------
2019-08-26 06:29:18 +00:00
* Input : ZPFileBufPtr, A = Var Type, Value on Stack
* Output : Y,A = ZPVarID
*--------------------------------------
2019-08-26 06:29:18 +00:00
CSH.AddVar sta ZPVarType
2019-08-26 06:29:18 +00:00
>PUSHW ZPFileBufPtr
>LDA.G CSH.hSymbols
>SYSCALL SListNewKey
bcs .9
2019-08-26 06:29:18 +00:00
>STYA ZPVarID
txa
* clc
adc ZPFileBufPtr
sta ZPFileBufPtr
bcc .1
2019-08-26 06:29:18 +00:00
inc ZPFileBufPtr+1
2019-08-26 06:29:18 +00:00
.1 ldy #2
2019-08-26 06:29:18 +00:00
lda ZPVarType
2019-08-28 15:21:42 +00:00
sta ZPVarData
2019-08-26 06:29:18 +00:00
and #CSH.Q.PPPOINTER
bne .2 Pointer, always 2 bytes
2019-08-26 06:29:18 +00:00
lda ZPVarType
and #$1f
tax
ldy CSH.TSIZE,x
.2 iny +1 for Type
lda #0
2019-08-26 06:29:18 +00:00
>PUSHYA DataLen
2019-08-28 15:21:42 +00:00
>PUSHW ZPVarData
2019-08-26 06:29:18 +00:00
>PUSHW ZPVarID
>LDA.G CSH.hSymbols
>SYSCALL SListAddData
bcs .9
2019-08-28 15:21:42 +00:00
>LDYA ZPVarID
2019-08-26 06:29:18 +00:00
.9 rts
*--------------------------------------
2019-08-28 15:21:42 +00:00
CSH.GetVar >PUSHW ZPFileBufPtr
2019-08-26 06:29:18 +00:00
>LDA.G CSH.hSymbols
>SYSCALL SListLookup
bcs .9
>STYA ZPVarID
txa
* clc
adc ZPFileBufPtr
sta ZPFileBufPtr
bcc .1
2019-08-26 06:29:18 +00:00
inc ZPFileBufPtr+1
2019-08-26 15:27:28 +00:00
clc
2019-08-28 15:21:42 +00:00
.1
2019-08-26 15:27:28 +00:00
.9
CSH.GetVar.RTS rts
*--------------------------------------
2019-08-28 15:21:42 +00:00
* Input : ZPFileBufPtr, X = Var Type (or 0)
* Output : Value on Stack, X = Var Type
2019-08-26 15:27:28 +00:00
*--------------------------------------
2019-08-28 15:21:42 +00:00
CSH.GetVarValue stx ZPVarType
2019-08-26 15:27:28 +00:00
.1 >PUSHWI 0
>PUSHWI 6
>PUSHWI ZPVarData
2019-08-28 15:21:42 +00:00
>PUSHW ZPVarID
2019-08-26 15:27:28 +00:00
>LDA.G CSH.hSymbols
>SYSCALL SListGetData
bcs CSH.GetVar.RTS
2019-08-28 15:21:42 +00:00
2019-08-26 15:27:28 +00:00
CSH.PushValueOnStack
ldx ZPVarType
2019-08-28 15:21:42 +00:00
beq .1
2019-08-26 15:27:28 +00:00
cpx ZPVarData
bne .99
2019-08-28 15:21:42 +00:00
.1 ldx ZPVarData
2019-08-26 15:27:28 +00:00
ldy CSH.TSIZE,x
2019-08-26 15:27:28 +00:00
.2 lda ZPVarData,y
>PUSHA
dey
bne .2
clc
rts
2019-08-28 15:21:42 +00:00
2019-08-26 15:27:28 +00:00
.99 lda #CSH.E.TMISMATCH
sec
2019-08-26 06:29:18 +00:00
.9 rts
*--------------------------------------
2019-08-26 15:27:28 +00:00
CSH.SetVarValue cmp ZPVarType
bne .9
2019-08-28 15:21:42 +00:00
sta ZPVarData
tax
2019-08-26 15:27:28 +00:00
ldy CSH.TSIZE,x Byte count to transfer
2019-08-26 15:27:28 +00:00
ldx #1
2019-08-26 15:27:28 +00:00
.1 >PULLA
sta ZPVarData,x
inx
dey
bne .1
2019-08-26 15:27:28 +00:00
2019-08-28 15:21:42 +00:00
>PUSHBI 0
ldx ZPVarType
lda CSH.TSIZE,x
inc +1 including TYPE
>PUSHA
>PUSHWI ZPVarData
>PUSHW ZPVarID
>LDA.G CSH.hSymbols
>SYSCALL SListSetData
rts
.9 lda #CSH.E.TMISMATCH
sec
rts
*--------------------------------------
2019-08-26 15:27:28 +00:00
CSH.IsValue0 ldx ZPVarType
cpx #CSH.T.FLOAT
bne .1 char,int,long
2019-08-26 15:27:28 +00:00
ldy CSH.TSIZE,x
lda ZPVarData,y
bne .9
.8 clc
rts
.1 tax
lda CSH.TSIZE,x
tax
lda #0
2019-08-26 15:27:28 +00:00
ldy #1
2019-08-26 15:27:28 +00:00
.2 ora ZPVarData,y
iny
dex
bne .2
tax
beq .8
.9 sec
rts
*--------------------------------------
2019-02-08 16:13:43 +00:00
CSH.Compute tax
jmp (J.CSH.BOPS,x)
*--------------------------------------
CSH.BOPS.ADD
clc
rts
2019-08-26 15:27:28 +00:00
CSH.BOPS.SUB lda ZPVarType
cmp #CSH.T.FLOAT
beq .8
clc
rts
2019-08-26 15:27:28 +00:00
.8 >FPU FSUB
2018-06-14 15:31:36 +00:00
bcs .9
2018-06-14 15:31:36 +00:00
.9 rts
CSH.BOPS.MUL
2017-11-14 16:57:34 +00:00
clc
rts
2019-08-26 15:27:28 +00:00
CSH.BOPS.DIV lda ZPVarType
2017-11-14 16:57:34 +00:00
cmp #CSH.T.FLOAT
beq .8
clc
rts
2019-08-26 15:27:28 +00:00
.8
2019-08-26 06:29:18 +00:00
>FPU FDIV
2019-08-26 15:27:28 +00:00
2019-08-26 06:29:18 +00:00
clc
2017-11-14 16:57:34 +00:00
rts
CSH.BOPS.MOD
CSH.BOPS.SHL
CSH.BOPS.SHR
CSH.BOPS.L
CSH.BOPS.G
CSH.BOPS.LE
CSH.BOPS.GE
CSH.BOPS.EQ
CSH.BOPS.NE
CSH.BOPS.AND
CSH.BOPS.OR
CSH.BOPS.EOR
CSH.BOPS.LAND
CSH.BOPS.LOR
clc
rts
*--------------------------------------
* Stack
*--------------------------------------
CSH.Push pha
>LDA.G CSH.StackPtr
inc
beq .9
sta (pData),y
dec
tay
pla
sta (ZPCSHStack),y
clc
rts
.9 pla
lda #CSH.E.SOVERFLW
sec
rts
*--------------------------------------
CSH.Pop >LDA.G CSH.StackPtr
beq .9
dec
sta (pData),y
tay
lda (ZPCSHStack),y
clc
rts
.9 lda #CSH.E.SYNTAX
sec
rts
*--------------------------------------
CSH.CheckStack tax
>LDA.G CSH.StackPtr
beq .9
dec
tay
txa
cmp (ZPCSHStack),y
bne .9
tya
>STA.G CSH.StackPtr
clc
rts
.9 lda #CSH.E.SYNTAX
sec
rts
*--------------------------------------
* CHAR related Subs.....
*--------------------------------------
CSH.GetOPLen ldy #0
.1 iny
2018-11-10 14:30:09 +00:00
lda (ZPFileBufPtr),y
beq .8
jsr CSH.IsOPChar
bcc .1
.8 tya
rts
*--------------------------------------
CSH.GetIDLen ldy #0
.1 iny
2018-11-10 14:30:09 +00:00
lda (ZPFileBufPtr),y
beq .8
jsr CSH.IsLetterOrDigit
bcc .1
.8 tya
rts
*--------------------------------------
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
*--------------------------------------
2018-11-10 14:30:09 +00:00
CSH.CheckCharNB cmp #C.SPACE
beq .9
2018-11-10 14:30:09 +00:00
cmp #C.LF
beq .9
2018-11-10 14:30:09 +00:00
cmp #C.TAB
beq .9
clc
.9 rts
*--------------------------------------
2018-11-10 14:30:09 +00:00
CSH.GetNextChar inc ZPFileBufPtr
bne CSH.GetChar
2018-11-10 14:30:09 +00:00
inc ZPFileBufPtr+1
*--------------------------------------
2018-11-10 14:30:09 +00:00
CSH.GetChar lda (ZPFileBufPtr)
beq .9
clc
rts
.9 lda #MLI.E.EOF
sec
rts
*---------------------------------------
2019-02-07 16:52:25 +00:00
CSH.IsOPChar ldx #CSH.OPChars.Cnt-1
.1 cmp CSH.OPChars,x
beq .8
dex
bpl .1
sec
rts
.8 clc
rts
*---------------------------------------
CSH.IsLetterOrDigit
jsr CSH.IsDigit10
bcc CSH.IsLetterRTS
*---------------------------------------
CSH.IsLetter cmp #'_'
bne .1
clc
rts
.1 cmp #'A'
bcc .9
cmp #'Z'+1
bcc CSH.IsLetterRTS
cmp #'a'
bcc .9
cmp #'z'+1
rts CC if lowercase
.9 sec
CSH.IsLetterRTS rts
*---------------------------------------
CSH.IsDigit10 cmp #'0'
bcc .9
cmp #'9'+1
rts cc if ok, cs if not
.9 sec
rts
2016-08-17 06:25:58 +00:00
*--------------------------------------
2019-08-26 06:29:18 +00:00
* EXEC
*--------------------------------------
2019-08-26 15:27:28 +00:00
EXEC.printf >PULLYA
2019-08-26 06:29:18 +00:00
>SYSCALL printf
bcs .9
2019-08-26 15:27:28 +00:00
2019-08-26 06:29:18 +00:00
.9 rts
*--------------------------------------
2019-08-26 15:27:28 +00:00
EXEC.puts >PULLYA
2019-08-26 06:29:18 +00:00
>SYSCALL puts
bcs .9
.9 rts
*--------------------------------------
EXEC.cos >FPU COS
rts
*--------------------------------------
EXEC.getchar >SYSCALL getchar
rts
*--------------------------------------
2016-08-17 06:25:58 +00:00
MAN
2019-01-26 16:33:03 +00:00
SAVE USR/SRC/BIN/CSH.S.CORE
LOAD USR/SRC/BIN/CSH.S
2016-08-17 06:25:58 +00:00
ASM