A2osX/BIN/CC.S.EXP.txt

613 lines
9.7 KiB
Plaintext
Raw Normal View History

NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
* Input:
* ZPLineBufPtr, Y,A = Expected type/qual
* Output:
* CS, A = EC
2022-01-30 21:47:08 +00:00
* CC, Y,A = type/qual
*--------------------------------------
2022-01-30 21:47:08 +00:00
CC.EXP.Eval00 lda #0
tay
2022-01-30 21:47:08 +00:00
CC.EXP.Eval ldx ZPPtr2 local : expected T/Q
phx
ldx ZPPtr2+1
phx
ldx ZPPtr3 local : BOP
phx
2022-01-30 21:47:08 +00:00
ldx ZPPtr3+1 local : PREOP
phx
2022-01-30 21:47:08 +00:00
>STYA ZPPtr2
lda #$ff no previous OP
pha
*--------------------------------------
.10 jsr CC.GetCharNB
bcs .19
2022-01-30 21:47:08 +00:00
cmp #'('
bne .20
jsr CC.GetNextCharNB skip (
bcs .19
2022-01-30 21:47:08 +00:00
>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
2022-01-30 21:47:08 +00:00
.19 jmp CC.EXP.Eval.ESYN
*--------------------------------------
2022-01-30 21:47:08 +00:00
.20 jsr CC.ExpPreops
bcs .29
jsr CC.IsLetter define, f() or Var ?
bcs .22
jsr CC.GetDefine
bcc .10
2022-01-30 21:47:08 +00:00
jsr CC.SYM.Lookup
bcs .22
2022-01-30 21:47:08 +00:00
ldy #SYM.Q
lda (ZPSymBufPtr),y
and #SYM.Q.FUNC
bne .21
2022-01-30 21:47:08 +00:00
jsr CC.EXP.CheckGetSymType
bcs .29
jsr CC.EXP.Get Check T/Q & Get value on stack
bcs .29
2022-01-30 21:47:08 +00:00
jsr CC.SYM.FreeBufPop
bra .30
*--------------------------------------
.21 >LDYA ZPPtr2 get expected T/Q
2022-01-30 21:47:08 +00:00
jsr CC.F.CallRetV
bcs .29
>STYA ZPPtr2 store real T/Q
2022-01-30 21:47:08 +00:00
jsr CC.SYM.FreeBufPop
bra .30
*--------------------------------------
.22 jsr CC.IsDigit10 number ?
bcs .24
ldy ZPPtr2
bne .23
2022-01-30 21:47:08 +00:00
ldy #SYM.T.SINT
sty ZPPtr2
stz ZPPtr2+1
2022-01-30 21:47:08 +00:00
.23 jsr CC.EXP.GetNum
bcs .29
bra .30
2022-01-30 21:47:08 +00:00
*--------------------------------------
.24 cmp #'"' String literal
2022-01-30 21:47:08 +00:00
bne CC.EXP.Eval.ESYN
jsr CC.AddContCharP
2022-01-30 21:47:08 +00:00
.29 bcs CC.EXP.Eval.Err
*--------------------------------------
.30 jsr CC.GetCharNB
2022-01-30 21:47:08 +00:00
bcs CC.EXP.Eval.ESYN
2022-01-30 21:47:08 +00:00
.31 jsr CC.IsEndArg , ; ) ?
bcc CC.EXP.Eval.End
jsr CC.IsOPChar
2022-01-30 21:47:08 +00:00
bcs CC.EXP.Eval.ESYN
2022-01-30 21:47:08 +00:00
>LDYA L.CC.BOPS we are at V1 op1 V2 op2...
jsr CC.LookupOP
2022-01-30 21:47:08 +00:00
bcs CC.EXP.Eval.ESYN
stx ZPPtr3 save OP(n)
2022-01-30 21:47:08 +00:00
.33 plx get OP(n-1)
bmi .38 $ff....
cpx ZPPtr3
2022-01-30 21:47:08 +00:00
bcc .38 OP(n) has precedence, on stack : V1,V2
>LDYA ZPPtr2 OP(n-1) has precedence...
2022-01-30 21:47:08 +00:00
jsr CC.EXP.BOPS compute V(n-1) <OP(n-1)> V(n)
bcc .33
2022-01-30 21:47:08 +00:00
bcs CC.EXP.Eval.Err
2022-01-30 21:47:08 +00:00
.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
*--------------------------------------
2022-01-30 21:47:08 +00:00
CC.EXP.Eval.End plx any OP on stack ?
bmi CC.EXP.Eval.Exit
>LDYA ZPPtr2 Var Type
2022-01-30 21:47:08 +00:00
jsr CC.EXP.BOPS
bcc CC.EXP.Eval.End
2022-01-30 21:47:08 +00:00
bra CC.EXP.Eval.Err
*--------------------------------------
CC.EXP.Eval.ESYN
lda #E.ESYN
2022-01-30 21:47:08 +00:00
CC.EXP.Eval.Err
plx
bpl CC.EXP.Eval.Err
sec
2022-01-30 21:47:08 +00:00
bra CC.EXP.Eval.ExitErr
*--------------------------------------
CC.EXP.Eval.Exit
>LDYA ZPPtr2 Type/Qual
clc
2022-01-30 21:47:08 +00:00
CC.EXP.Eval.ExitErr
plx
stx ZPPtr3+1
plx
stx ZPPtr3
2022-01-30 21:47:08 +00:00
plx
stx ZPPtr2+1
plx
stx ZPPtr2
rts
*--------------------------------------
2022-01-30 21:47:08 +00:00
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
2022-01-30 21:47:08 +00:00
ldx #$ff
.8 stx ZPPtr3+1
2022-01-30 21:47:08 +00:00
jmp CC.GetCharNB
*--------------------------------------
* Y,A = Type/Qual, X = OP
*--------------------------------------
2022-01-30 21:47:08 +00:00
CC.EXP.BOPS cpy #SYM.T.UINT
bcs .3
2022-01-30 21:47:08 +00:00
cpy #SYM.T.UCHAR
beq .1
2022-01-30 21:47:08 +00:00
cpy #SYM.T.SCHAR
beq .2
lda #E.TMISMATCH
sec
rts
2022-01-30 21:47:08 +00:00
.1 lda J.CC.bBOPS,x
ldy J.CC.bBOPS+1,x
tax
2022-01-30 21:47:08 +00:00
lda #$20 JSR
jsr CODE.TOABSYX
clc
rts
2022-01-30 21:47:08 +00:00
.2 lda J.CC.cBOPS,x
ldy J.CC.cBOPS+1,x
tax
2022-01-30 21:47:08 +00:00
lda #$20 JSR
jsr CODE.TOABSYX
clc
rts
.3 txa
clc
2022-01-30 21:47:08 +00:00
adc CC.Type2FPU-SYM.T.UINT,y
tax
jsr CODE.FPUCALL
clc
rts
*--------------------------------------
2022-01-30 21:47:08 +00:00
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
*--------------------------------------
2022-01-30 21:47:08 +00:00
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
2022-01-30 21:47:08 +00:00
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
*--------------------------------------
2022-01-30 21:47:08 +00:00
* ZPPtr2 = expected T/Q
* ZPPtr3+1 = PREOPS
*--------------------------------------
CC.EXP.Get >LDYA L.CC.AOPS
jsr CC.LookupOP
bcs .20
2022-01-30 21:47:08 +00:00
>LDYA ZPPtr2 get expected T/Q
jsr CC.EXP.Eval
bcs .99
2022-01-30 21:47:08 +00:00
jsr CC.SYM.SetValue
bcs .99
2022-01-30 21:47:08 +00:00
clc
rts
*--------------------------------------
.20 >LDYA L.CC.POSTOPS
jsr CC.LookupOP
bcs .1
2022-01-30 21:47:08 +00:00
cpx #4 '['
bne *
2022-01-30 21:47:08 +00:00
jmp CC.EXP.Array
*--------------------------------------
.1 ldx ZPPtr3+1 preop
bpl .8
2022-01-30 21:47:08 +00:00
lda ZPPtr2 target T
beq .3
2022-01-30 21:47:08 +00:00
lda (ZPSymBufPtr) SYM.T
cmp #SYM.T.VOID
beq .2
2022-01-30 21:47:08 +00:00
cmp ZPPtr2 T
bne .9
2022-01-30 21:47:08 +00:00
.2 lda ZPPtr2+1 Q
ldy #SYM.Q
cmp (ZPSymBufPtr),y
bne .9
2022-01-30 21:47:08 +00:00
.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
2022-01-30 21:47:08 +00:00
.99 rts
.9 lda #E.TMISMATCH
sec
rts
2022-01-30 21:47:08 +00:00
.8 jmp (J.CC.PREOPS,x)
*--------------------------------------
CC.EXP.Array ldy #SYM.Q
lda (ZPSymBufPtr),y
and #SYM.Q.AAARRAY
beq .9
2022-01-30 21:47:08 +00:00
jsr CC.EXP.PushDeref push base address
2022-01-30 21:47:08 +00:00
ldy #SYM.T.SINT
lda #0
2022-01-30 21:47:08 +00:00
jsr CC.EXP.Eval
bcs .99 int16 on stack
2022-01-30 21:47:08 +00:00
jsr CC.GetCharNB
bcs .9
cmp #']'
bne .9
2022-01-30 21:47:08 +00:00
jsr CC.GetNextCharNB skip ']'
bcs .9
jsr CC.SYM.GetSymSizeOfInAXC
pha
2022-01-30 21:47:08 +00:00
txa
jsr CODE.PUSHI
pla
jsr CODE.PUSHI sizeof on stack
2022-01-30 21:47:08 +00:00
ldx #FPU.iMUL
jsr CODE.FPUCALL sizeof*int16
2022-01-30 21:47:08 +00:00
ldx #FPU.iAdd
jsr CODE.FPUCALL add to base address
lda (ZPSymBufPtr) SYM.T
pha
2022-01-30 21:47:08 +00:00
ldy #SYM.Q
lda (ZPSymBufPtr),y
sec
sbc #SYM.Q.ARRAY
ply
2022-01-30 21:47:08 +00:00
jsr CC.SYM.GetYASizeOfInAXC
jsr CODE.PushFromPtr A = byte count
clc
rts
2022-01-30 21:47:08 +00:00
.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
*--------------------------------------
2022-01-30 21:47:08 +00:00
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