mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-22 16:31:07 +00:00
613 lines
9.7 KiB
Plaintext
613 lines
9.7 KiB
Plaintext
NEW
|
||
AUTO 3,1
|
||
.LIST OFF
|
||
*--------------------------------------
|
||
* Input:
|
||
* ZPLineBufPtr, Y,A = Expected type/qual
|
||
* Output:
|
||
* CS, A = EC
|
||
* CC, Y,A = type/qual
|
||
*--------------------------------------
|
||
CC.EXP.Eval00 lda #0
|
||
tay
|
||
|
||
CC.EXP.Eval ldx ZPPtr2 local : expected T/Q
|
||
phx
|
||
ldx ZPPtr2+1
|
||
phx
|
||
|
||
ldx ZPPtr3 local : BOP
|
||
phx
|
||
ldx ZPPtr3+1 local : PREOP
|
||
phx
|
||
|
||
>STYA ZPPtr2
|
||
|
||
lda #$ff no previous OP
|
||
pha
|
||
*--------------------------------------
|
||
.10 jsr CC.GetCharNB
|
||
bcs .19
|
||
|
||
cmp #'('
|
||
bne .20
|
||
|
||
jsr CC.GetNextCharNB skip (
|
||
bcs .19
|
||
|
||
>LDYA L.CC.TYPEQUAL
|
||
jsr CC.LookupID
|
||
bcs .12
|
||
|
||
jsr CC.EXP.Cast
|
||
bcs .19
|
||
|
||
bra .20
|
||
*--------------------------------------
|
||
.12 >LDYA ZPPtr2 expected T/Q
|
||
jsr CC.EXP.Eval
|
||
bcs .19
|
||
|
||
>STYA ZPPtr2 update T/Q
|
||
|
||
jsr CC.GetCharNB
|
||
bcs .19
|
||
|
||
cmp #')'
|
||
bne .19
|
||
|
||
jsr CC.GetNextCharNB skip )
|
||
bcc .31
|
||
|
||
.19 jmp CC.EXP.Eval.ESYN
|
||
*--------------------------------------
|
||
.20 jsr CC.ExpPreops
|
||
bcs .29
|
||
|
||
jsr CC.IsLetter define, f() or Var ?
|
||
bcs .22
|
||
|
||
jsr CC.GetDefine
|
||
bcc .10
|
||
|
||
jsr CC.SYM.Lookup
|
||
bcs .22
|
||
|
||
ldy #SYM.Q
|
||
lda (ZPSymBufPtr),y
|
||
and #SYM.Q.FUNC
|
||
bne .21
|
||
|
||
jsr CC.EXP.CheckGetSymType
|
||
bcs .29
|
||
|
||
jsr CC.EXP.Get Check T/Q & Get value on stack
|
||
bcs .29
|
||
|
||
jsr CC.SYM.FreeBufPop
|
||
|
||
bra .30
|
||
*--------------------------------------
|
||
.21 >LDYA ZPPtr2 get expected T/Q
|
||
|
||
jsr CC.F.CallRetV
|
||
bcs .29
|
||
|
||
>STYA ZPPtr2 store real T/Q
|
||
|
||
jsr CC.SYM.FreeBufPop
|
||
|
||
bra .30
|
||
*--------------------------------------
|
||
.22 jsr CC.IsDigit10 number ?
|
||
bcs .24
|
||
|
||
ldy ZPPtr2
|
||
bne .23
|
||
|
||
ldy #SYM.T.SINT
|
||
sty ZPPtr2
|
||
stz ZPPtr2+1
|
||
|
||
.23 jsr CC.EXP.GetNum
|
||
bcs .29
|
||
|
||
bra .30
|
||
*--------------------------------------
|
||
.24 cmp #'"' String literal
|
||
bne CC.EXP.Eval.ESYN
|
||
|
||
jsr CC.AddContCharP
|
||
.29 bcs CC.EXP.Eval.Err
|
||
*--------------------------------------
|
||
.30 jsr CC.GetCharNB
|
||
bcs CC.EXP.Eval.ESYN
|
||
|
||
.31 jsr CC.IsEndArg , ; ) ?
|
||
bcc CC.EXP.Eval.End
|
||
|
||
jsr CC.IsOPChar
|
||
bcs CC.EXP.Eval.ESYN
|
||
|
||
>LDYA L.CC.BOPS we are at V1 op1 V2 op2...
|
||
jsr CC.LookupOP
|
||
bcs CC.EXP.Eval.ESYN
|
||
|
||
stx ZPPtr3 save OP(n)
|
||
|
||
.33 plx get OP(n-1)
|
||
bmi .38 $ff....
|
||
|
||
cpx ZPPtr3
|
||
bcc .38 OP(n) has precedence, on stack : V1,V2
|
||
|
||
>LDYA ZPPtr2 OP(n-1) has precedence...
|
||
jsr CC.EXP.BOPS compute V(n-1) <OP(n-1)> V(n)
|
||
bcc .33
|
||
|
||
bcs CC.EXP.Eval.Err
|
||
|
||
.38 phx push back OP(n-1)
|
||
|
||
lda ZPPtr3 get OP(n)
|
||
pha push OP(n) on stack
|
||
|
||
jmp .10 go check for next token
|
||
*--------------------------------------
|
||
CC.EXP.Eval.End plx any OP on stack ?
|
||
bmi CC.EXP.Eval.Exit
|
||
|
||
>LDYA ZPPtr2 Var Type
|
||
jsr CC.EXP.BOPS
|
||
bcc CC.EXP.Eval.End
|
||
|
||
bra CC.EXP.Eval.Err
|
||
*--------------------------------------
|
||
CC.EXP.Eval.ESYN
|
||
lda #E.ESYN
|
||
|
||
CC.EXP.Eval.Err
|
||
plx
|
||
bpl CC.EXP.Eval.Err
|
||
|
||
sec
|
||
bra CC.EXP.Eval.ExitErr
|
||
*--------------------------------------
|
||
CC.EXP.Eval.Exit
|
||
>LDYA ZPPtr2 Type/Qual
|
||
clc
|
||
|
||
CC.EXP.Eval.ExitErr
|
||
plx
|
||
stx ZPPtr3+1
|
||
plx
|
||
stx ZPPtr3
|
||
|
||
plx
|
||
stx ZPPtr2+1
|
||
plx
|
||
stx ZPPtr2
|
||
|
||
rts
|
||
*--------------------------------------
|
||
CC.EXP.CheckGetSymType
|
||
lda ZPPtr2
|
||
ora ZPPtr2+1
|
||
bne .1
|
||
|
||
lda (ZPSymBufPtr)
|
||
sta ZPPtr2
|
||
|
||
ldy #SYM.Q
|
||
lda (ZPSymBufPtr),y
|
||
sta ZPPtr2+1
|
||
|
||
clc
|
||
rts
|
||
|
||
.1 >LDYA ZPPtr2
|
||
jmp CC.SYM.CheckTypeYA
|
||
*--------------------------------------
|
||
CC.EXP.Cast jsr CC.TYPE.Decl
|
||
bcs .99
|
||
|
||
>STYA ZPPtr2
|
||
|
||
jsr CC.GetCharNB
|
||
bcs .9
|
||
|
||
cmp #')'
|
||
bne .9
|
||
|
||
jsr CC.GetNextCharNB skip )
|
||
|
||
clc
|
||
rts
|
||
|
||
.9 lda #E.ESYN
|
||
sec
|
||
.99 rts
|
||
*--------------------------------------
|
||
CC.ExpPreops >LDYA L.CC.PREOPS
|
||
|
||
jsr CC.LookupOP
|
||
bcc .8
|
||
|
||
ldx #$ff
|
||
|
||
.8 stx ZPPtr3+1
|
||
|
||
jmp CC.GetCharNB
|
||
*--------------------------------------
|
||
* Y,A = Type/Qual, X = OP
|
||
*--------------------------------------
|
||
CC.EXP.BOPS cpy #SYM.T.UINT
|
||
bcs .3
|
||
|
||
cpy #SYM.T.UCHAR
|
||
beq .1
|
||
|
||
cpy #SYM.T.SCHAR
|
||
beq .2
|
||
|
||
lda #E.TMISMATCH
|
||
sec
|
||
rts
|
||
|
||
.1 lda J.CC.bBOPS,x
|
||
ldy J.CC.bBOPS+1,x
|
||
tax
|
||
lda #$20 JSR
|
||
jsr CODE.TOABSYX
|
||
clc
|
||
rts
|
||
|
||
.2 lda J.CC.cBOPS,x
|
||
ldy J.CC.cBOPS+1,x
|
||
tax
|
||
lda #$20 JSR
|
||
jsr CODE.TOABSYX
|
||
clc
|
||
rts
|
||
|
||
.3 txa
|
||
clc
|
||
adc CC.Type2FPU-SYM.T.UINT,y
|
||
tax
|
||
jsr CODE.FPUCALL
|
||
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
CC.AddContCharP ldy #0
|
||
|
||
.1 jsr CC.GetNextChar
|
||
bcs .9
|
||
|
||
cmp #C.CR
|
||
beq .9
|
||
|
||
cmp #'"'
|
||
beq .2
|
||
|
||
sta (ZPCCConst),y
|
||
iny
|
||
bra .1
|
||
|
||
.2 lda #0
|
||
sta (ZPCCConst),y
|
||
|
||
lda ZPCCConst+1 Push PTR on stack
|
||
jsr CODE.PUSHI
|
||
lda ZPCCConst
|
||
jsr CODE.PUSHI
|
||
|
||
tya
|
||
sec
|
||
adc ZPCCConst
|
||
sta ZPCCConst
|
||
bcc .3
|
||
|
||
inc ZPCCConst+1
|
||
.3 jsr CC.GetNextChar Skip "
|
||
|
||
clc
|
||
rts
|
||
|
||
.9 lda #E.ESYN
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
CC.EXP.GetNum cpy #SYM.T.FLOAT
|
||
bcc .1
|
||
|
||
beq .11
|
||
|
||
lda #E.TMISMATCH
|
||
* sec
|
||
rts
|
||
|
||
.11 >PUSHW ZPLineBufPtr
|
||
>PUSHWI ZPLineBufPtr
|
||
>SYSCALL StrToF
|
||
* bcs .9
|
||
|
||
ldy #4
|
||
|
||
.10 lda (pStack),y
|
||
jsr CODE.PUSHI
|
||
dey
|
||
bpl .10
|
||
|
||
>POP 5
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
.1 >PUSHW ZPLineBufPtr
|
||
>PUSHWI ZPLineBufPtr
|
||
>PUSHBI 10
|
||
|
||
lda CC.TYPESIGN-1,y
|
||
bmi .2
|
||
|
||
>SYSCALL StrToUL
|
||
bra .3
|
||
|
||
.2 >SYSCALL StrToL
|
||
|
||
.3 bcs .9
|
||
|
||
ldy #1 anticipate 2 bytes if *
|
||
lda ZPPtr2+1
|
||
and #SYM.Q.PPPOINTER
|
||
bne .5
|
||
|
||
ldx ZPPtr2
|
||
lda CC.TYPESIZE-1,x
|
||
|
||
dec
|
||
tay
|
||
|
||
.5 lda (pStack),y
|
||
jsr CODE.PUSHI
|
||
dey
|
||
bpl .5
|
||
|
||
>POP 4
|
||
* clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
* ZPPtr2 = expected T/Q
|
||
* ZPPtr3+1 = PREOPS
|
||
*--------------------------------------
|
||
CC.EXP.Get >LDYA L.CC.AOPS
|
||
jsr CC.LookupOP
|
||
bcs .20
|
||
|
||
>LDYA ZPPtr2 get expected T/Q
|
||
jsr CC.EXP.Eval
|
||
bcs .99
|
||
|
||
jsr CC.SYM.SetValue
|
||
bcs .99
|
||
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
.20 >LDYA L.CC.POSTOPS
|
||
jsr CC.LookupOP
|
||
bcs .1
|
||
|
||
cpx #4 '['
|
||
bne *
|
||
|
||
jmp CC.EXP.Array
|
||
*--------------------------------------
|
||
.1 ldx ZPPtr3+1 preop
|
||
bpl .8
|
||
|
||
lda ZPPtr2 target T
|
||
beq .3
|
||
|
||
lda (ZPSymBufPtr) SYM.T
|
||
cmp #SYM.T.VOID
|
||
beq .2
|
||
|
||
cmp ZPPtr2 T
|
||
bne .9
|
||
|
||
.2 lda ZPPtr2+1 Q
|
||
|
||
ldy #SYM.Q
|
||
cmp (ZPSymBufPtr),y
|
||
bne .9
|
||
|
||
.3 lda (ZPSymBufPtr) SYM.T
|
||
sta ZPPtr2 T
|
||
pha
|
||
ldy #SYM.Q
|
||
lda (ZPSymBufPtr),y
|
||
sta ZPPtr2+1 Q
|
||
ply Y,A = T/Q
|
||
|
||
jsr CC.SYM.PushValue
|
||
|
||
clc
|
||
.99 rts
|
||
|
||
.9 lda #E.TMISMATCH
|
||
sec
|
||
rts
|
||
|
||
.8 jmp (J.CC.PREOPS,x)
|
||
*--------------------------------------
|
||
CC.EXP.Array ldy #SYM.Q
|
||
lda (ZPSymBufPtr),y
|
||
and #SYM.Q.AAARRAY
|
||
beq .9
|
||
|
||
jsr CC.EXP.PushDeref push base address
|
||
|
||
ldy #SYM.T.SINT
|
||
lda #0
|
||
|
||
jsr CC.EXP.Eval
|
||
bcs .99 int16 on stack
|
||
|
||
jsr CC.GetCharNB
|
||
bcs .9
|
||
|
||
cmp #']'
|
||
bne .9
|
||
|
||
jsr CC.GetNextCharNB skip ']'
|
||
bcs .9
|
||
|
||
jsr CC.SYM.GetSymSizeOfInAXC
|
||
|
||
pha
|
||
txa
|
||
jsr CODE.PUSHI
|
||
pla
|
||
jsr CODE.PUSHI sizeof on stack
|
||
|
||
ldx #FPU.iMUL
|
||
jsr CODE.FPUCALL sizeof*int16
|
||
|
||
ldx #FPU.iAdd
|
||
jsr CODE.FPUCALL add to base address
|
||
|
||
lda (ZPSymBufPtr) SYM.T
|
||
pha
|
||
|
||
ldy #SYM.Q
|
||
lda (ZPSymBufPtr),y
|
||
sec
|
||
sbc #SYM.Q.ARRAY
|
||
ply
|
||
|
||
jsr CC.SYM.GetYASizeOfInAXC
|
||
jsr CODE.PushFromPtr A = byte count
|
||
|
||
clc
|
||
rts
|
||
|
||
.9 lda #E.ESYN
|
||
sec
|
||
.99 rts
|
||
*--------------------------------------
|
||
CC.EXP.PushAddr ldy #SYM.Addr+1
|
||
lda (ZPSymBufPtr),y
|
||
bne .7
|
||
* LOCAL
|
||
jsr CODE.PUSHpBASEp1
|
||
|
||
ldy #SYM.Addr
|
||
lda (ZPSymBufPtr),y
|
||
eor #$FF
|
||
inc
|
||
jsr CODE.LDAI
|
||
jsr CODE.PUSHpBASEpA
|
||
|
||
clc
|
||
rts
|
||
* DATASEG
|
||
.7 jsr CODE.PUSHI
|
||
|
||
ldy #SYM.Addr
|
||
lda (ZPSymBufPtr),y
|
||
jsr CODE.PUSHI
|
||
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
CC.EXP.PushDeref
|
||
ldy #SYM.Addr+1
|
||
lda (ZPSymBufPtr),y
|
||
bne .7
|
||
* LOCAL
|
||
jsr CODE.SETpBASEp1
|
||
|
||
ldy #SYM.Addr
|
||
lda (ZPSymBufPtr),y
|
||
eor #$FF
|
||
inc
|
||
jsr CODE.LDAI
|
||
jsr CODE.SETpBASEpA
|
||
|
||
jsr CODE.Deref
|
||
|
||
clc
|
||
rts
|
||
* DATASEG
|
||
.7 jsr CODE.LDAI
|
||
lda #$85 STA zp
|
||
jsr CODE.EmitByte
|
||
lda #ZPPtr1+1
|
||
jsr CODE.EmitByte
|
||
|
||
ldy #SYM.Addr
|
||
lda (ZPSymBufPtr),y
|
||
jsr CODE.LDAI
|
||
|
||
lda #$85 STA zp
|
||
jsr CODE.EmitByte
|
||
lda #ZPPtr1+1
|
||
jsr CODE.EmitByte
|
||
|
||
jsr CODE.Deref
|
||
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
CC.EXP.GetRef ldy #SYM.Addr+1
|
||
lda (ZPSymBufPtr),y
|
||
jsr CODE.PUSHI
|
||
|
||
ldy #SYM.Addr
|
||
lda (ZPSymBufPtr),y
|
||
jsr CODE.PUSHI
|
||
|
||
lda (ZPSymBufPtr) SYM.T
|
||
|
||
sta ZPPtr2 T
|
||
|
||
ldy #SYM.Q
|
||
lda (ZPSymBufPtr),y
|
||
clc
|
||
adc #SYM.Q.POINTER
|
||
bcs .9 more than ***
|
||
|
||
sta ZPPtr2+1 Q
|
||
* clc
|
||
rts
|
||
|
||
.9 lda #E.TMISMATCH
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
CC.EXP.GetDeref
|
||
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
CC.EXP.IntConst >PUSHW ZPLineBufPtr
|
||
>PUSHWI ZPLineBufPtr
|
||
>PUSHBI 10
|
||
>SYSCALL StrToUL
|
||
|
||
>PULLA
|
||
tay
|
||
|
||
>PULLA
|
||
|
||
inc pStack
|
||
inc pStack
|
||
|
||
rts
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE usr/src/bin/cc.s.exp
|
||
LOAD usr/src/bin/cc.s
|
||
ASM
|