2020-08-02 12:19:43 +00:00
|
|
|
|
NEW
|
|
|
|
|
AUTO 3,1
|
|
|
|
|
.LIST OFF
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Input:
|
2020-12-23 14:54:57 +00:00
|
|
|
|
* ZPInputBufPtr, A = Expected type
|
2020-08-02 12:19:43 +00:00
|
|
|
|
* Output:
|
|
|
|
|
* CS, A = EC
|
|
|
|
|
* CC, X = Var Type, Value on Stack
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CSH.ExpEval ldx ZPPtr1
|
|
|
|
|
phx
|
|
|
|
|
ldx ZPPtr1+1 local : used by lookup
|
|
|
|
|
phx
|
|
|
|
|
ldx ZPPtr2 local : VarType
|
|
|
|
|
phx
|
|
|
|
|
ldx ZPPtr2+1 local : BOP
|
|
|
|
|
phx
|
|
|
|
|
|
|
|
|
|
sta ZPPtr2 local : expected type
|
|
|
|
|
|
|
|
|
|
lda #$ff
|
|
|
|
|
pha
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.10 jsr CSH.GetCharNB
|
|
|
|
|
bcs .19
|
|
|
|
|
|
|
|
|
|
.11 cmp #'('
|
|
|
|
|
bne .20
|
|
|
|
|
|
|
|
|
|
jsr CSH.GetNextCharNB skip (
|
|
|
|
|
bcs .19
|
|
|
|
|
|
|
|
|
|
lda ZPPtr2
|
|
|
|
|
|
|
|
|
|
jsr CSH.ExpEval
|
|
|
|
|
bcs .19
|
|
|
|
|
stx ZPPtr2
|
|
|
|
|
|
|
|
|
|
jsr CSH.GetCharNB
|
|
|
|
|
bcs .19
|
|
|
|
|
cmp #')'
|
|
|
|
|
bne .19
|
|
|
|
|
|
|
|
|
|
jsr CSH.GetNextCharNB skip )
|
|
|
|
|
bcc .31
|
|
|
|
|
.19 jmp .90
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.20 jsr CSH.IsLetter define, Fnc or Var ?
|
|
|
|
|
bcs .22
|
|
|
|
|
|
|
|
|
|
jsr CSH.GetDefine
|
|
|
|
|
bcc .10
|
|
|
|
|
|
|
|
|
|
jsr CSH.GetVar
|
|
|
|
|
bcs .21
|
|
|
|
|
|
|
|
|
|
ldx ZPPtr2 YA=VarID, X=expected var type (or 0=any)
|
|
|
|
|
|
|
|
|
|
jsr CSH.GetVarValueOnStack Y,A = VarID, Get value on stack
|
|
|
|
|
bcs .29
|
|
|
|
|
|
|
|
|
|
stx ZPPtr2 store real var type
|
|
|
|
|
bra .30
|
|
|
|
|
|
|
|
|
|
.21 lda ZPPtr2 var type
|
|
|
|
|
jsr CSH.fCall X = function index
|
|
|
|
|
bcs .29
|
|
|
|
|
|
|
|
|
|
stx ZPPtr2 store real var type
|
|
|
|
|
bra .30
|
|
|
|
|
|
|
|
|
|
.22 jsr CSH.IsDigit10 number ?
|
|
|
|
|
bcs .24
|
|
|
|
|
|
|
|
|
|
ldx ZPPtr2
|
|
|
|
|
bne .23
|
|
|
|
|
|
2021-01-12 21:14:13 +00:00
|
|
|
|
ldx #CSH.T.SINT
|
2020-08-02 12:19:43 +00:00
|
|
|
|
stx ZPPtr2
|
|
|
|
|
|
|
|
|
|
.23 jsr CSH.GetNumOnStack
|
|
|
|
|
bcs .29
|
|
|
|
|
bra .30
|
|
|
|
|
|
|
|
|
|
.24 cmp #'"' String literal
|
|
|
|
|
bne .90
|
|
|
|
|
jsr CSH.AddContCharP
|
|
|
|
|
.29 bcs .99
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.30 jsr CSH.GetCharNB
|
|
|
|
|
bcs .90
|
|
|
|
|
|
|
|
|
|
.31 cmp #','
|
|
|
|
|
beq .80
|
2020-12-23 14:54:57 +00:00
|
|
|
|
|
2020-08-02 12:19:43 +00:00
|
|
|
|
cmp #')'
|
|
|
|
|
beq .80
|
2020-12-23 14:54:57 +00:00
|
|
|
|
|
2020-08-02 12:19:43 +00:00
|
|
|
|
cmp #';'
|
|
|
|
|
beq .80
|
|
|
|
|
|
|
|
|
|
jsr CSH.IsOPChar
|
|
|
|
|
bcs .90
|
|
|
|
|
|
|
|
|
|
>LDYA L.CSH.BOPS we are at V1 op1 V2 op2...
|
|
|
|
|
jsr CSH.LookupOP
|
|
|
|
|
bcs .90
|
|
|
|
|
|
|
|
|
|
stx ZPPtr2+1 save OP(n)
|
|
|
|
|
|
|
|
|
|
.32 pla get OP(n-1)
|
|
|
|
|
bmi .33 $ff....
|
|
|
|
|
|
|
|
|
|
cmp ZPPtr2+1
|
|
|
|
|
bcc .33 OP(n) has precedence, on stack : V1,V2
|
|
|
|
|
|
|
|
|
|
tax OP(n-1) has precedence...
|
|
|
|
|
|
|
|
|
|
lda ZPPtr2 Var Type
|
|
|
|
|
jsr CSH.BOP.EXEC compute V(n-1) <OP(n-1)> V(n)
|
|
|
|
|
bcc .32
|
|
|
|
|
|
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
|
|
.33 pha push back OP(n-1)
|
|
|
|
|
lda ZPPtr2+1 get OP(n)
|
|
|
|
|
pha push OP(n) on stack
|
|
|
|
|
|
|
|
|
|
jmp .10 go check for next token
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.80 plx any OP on stack ?
|
|
|
|
|
bmi .88
|
|
|
|
|
|
|
|
|
|
lda ZPPtr2 Var Type
|
|
|
|
|
jsr CSH.BOP.EXEC
|
|
|
|
|
bcc .80
|
|
|
|
|
|
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
|
|
.90 lda #CSH.E.SYNTAX
|
|
|
|
|
|
|
|
|
|
.99 plx
|
|
|
|
|
bpl .99
|
|
|
|
|
|
|
|
|
|
sec
|
|
|
|
|
.HS 90 BCC
|
|
|
|
|
.88 clc
|
|
|
|
|
|
|
|
|
|
ldx ZPPtr2 X = Var Type
|
|
|
|
|
|
|
|
|
|
ply
|
|
|
|
|
sty ZPPtr2+1
|
|
|
|
|
ply
|
|
|
|
|
sty ZPPtr2
|
|
|
|
|
ply
|
|
|
|
|
sty ZPPtr1+1
|
|
|
|
|
ply
|
|
|
|
|
sty ZPPtr1
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CSH.AddContCharP
|
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
|
|
.1 jsr CSH.GetNextChar
|
|
|
|
|
bcs .9
|
|
|
|
|
cmp #C.CR
|
|
|
|
|
beq .9
|
|
|
|
|
cmp #'"'
|
|
|
|
|
beq .2
|
|
|
|
|
sta (ZPCSHConst),y
|
|
|
|
|
iny
|
|
|
|
|
bra .1
|
|
|
|
|
|
|
|
|
|
.2 lda #0
|
|
|
|
|
sta (ZPCSHConst),y
|
|
|
|
|
>PUSHW ZPCSHConst Push PTR on stack
|
|
|
|
|
|
|
|
|
|
tya
|
|
|
|
|
sec
|
|
|
|
|
adc ZPCSHConst
|
|
|
|
|
sta ZPCSHConst
|
|
|
|
|
bcc .3
|
|
|
|
|
inc ZPCSHConst+1
|
|
|
|
|
.3 jsr CSH.GetNextChar Skip "
|
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
.9 lda #CSH.E.SYNTAX
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CSH.GetNumOnStack
|
|
|
|
|
txa
|
|
|
|
|
beq .99
|
|
|
|
|
|
2021-01-12 21:14:13 +00:00
|
|
|
|
cpx #CSH.T.ULONG+1
|
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
|
|
cpx #CSH.T.FLOAT
|
|
|
|
|
bne .1
|
2020-08-02 12:19:43 +00:00
|
|
|
|
|
2020-12-23 14:54:57 +00:00
|
|
|
|
>PUSHW ZPInputBufPtr
|
|
|
|
|
>PUSHWI ZPInputBufPtr
|
2020-08-02 12:19:43 +00:00
|
|
|
|
>SYSCALL StrToF
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
2020-12-23 14:54:57 +00:00
|
|
|
|
.1 >PUSHW ZPInputBufPtr
|
|
|
|
|
>PUSHWI ZPInputBufPtr
|
2020-08-02 12:19:43 +00:00
|
|
|
|
>PUSHBI 10
|
|
|
|
|
phx
|
2021-01-12 21:14:13 +00:00
|
|
|
|
|
2020-08-02 12:19:43 +00:00
|
|
|
|
bcc .2
|
2021-01-12 21:14:13 +00:00
|
|
|
|
|
2020-08-02 12:19:43 +00:00
|
|
|
|
>SYSCALL StrToUL
|
|
|
|
|
bra .3
|
|
|
|
|
|
|
|
|
|
.2 >SYSCALL StrToL
|
|
|
|
|
|
|
|
|
|
.3 plx
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
lda CSH.TYPESIZE,x
|
|
|
|
|
cmp #4
|
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
cmp #2
|
|
|
|
|
bne .4
|
2021-01-12 21:14:13 +00:00
|
|
|
|
|
2020-08-02 12:19:43 +00:00
|
|
|
|
ldy #1
|
|
|
|
|
>PULLA
|
|
|
|
|
sta (pStack),y
|
|
|
|
|
>PULLA
|
|
|
|
|
sta (pStack),y
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.4 >PULLA
|
|
|
|
|
inc pStack
|
|
|
|
|
inc pStack
|
|
|
|
|
sta (pStack)
|
2021-01-12 21:14:13 +00:00
|
|
|
|
|
2020-08-02 12:19:43 +00:00
|
|
|
|
.8 clc
|
|
|
|
|
.9 rts
|
|
|
|
|
|
|
|
|
|
.99 lda #CSH.E.TMISMATCH
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
|
|
|
|
SAVE usr/src/bin/csh.s.exp
|
|
|
|
|
LOAD usr/src/bin/csh.s
|
|
|
|
|
ASM
|