A2osX/BIN/CC.S.KW.txt

391 lines
6.1 KiB
Plaintext
Raw Normal View History

NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
* Built in Keywords
*--------------------------------------
CC.KW.JMP txa
>STA.G CC.CmdSave
jmp (J.CC.KW,x)
*--------------------------------------
2022-01-30 21:47:08 +00:00
CC.KW.WHILE jsr CC.PushCS push cont: for WHILE loop
bcs CC.KW.IF.RTS
*--------------------------------------
2022-01-30 21:47:08 +00:00
CC.KW.IF jsr CC.GetCharNB
bcs .9
cmp #'('
bne .9
jsr CC.GetNextCharNB
bcs .9
2022-01-30 21:47:08 +00:00
jsr CC.EXP.Eval00 Any var type
bcs .99
jsr CC.KW.TestZero
jsr CC.PushCS push place to set JMP false
bcs .99
2022-01-30 21:47:08 +00:00
jsr CC.KW.ZPCCCodeAdd2
jsr CC.GetCharNB
bcs .99
cmp #')'
bne .9
2022-01-30 21:47:08 +00:00
jmp CC.KW.BEGIN
.9 lda #E.CSYN
sec
2022-01-30 21:47:08 +00:00
.99
CC.KW.IF.RTS rts
*--------------------------------------
2022-01-30 21:47:08 +00:00
CC.KW.IF.END jsr CC.PopYA
bcs .9
2022-01-30 21:47:08 +00:00
>STYA ZPPtr1 set JMP false
lda ZPCCCode
sta (ZPPtr1)
2022-01-30 21:47:08 +00:00
ldy #1
lda ZPCCCode+1
sta (ZPPtr1),y
* clc
.9 rts
*--------------------------------------
2022-01-30 21:47:08 +00:00
CC.KW.ELSE
clc
rts
*--------------------------------------
CC.KW.ELSE.END
clc
rts
*--------------------------------------
2022-01-30 21:47:08 +00:00
CC.KW.WHILE.END jsr CC.PopYA Get JMP false location
bcs .9
2022-01-30 21:47:08 +00:00
>STYA ZPPtr1
jsr CC.PopYA Get cont: address
bcs .9
2022-01-30 21:47:08 +00:00
phy
tay HI byte
plx
lda #$4C JMP cont:
jsr CODE.TOABSYX
lda ZPCCCode
sta (ZPPtr1)
ldy #1
lda ZPCCCode+1
sta (ZPPtr1),y
clc
.9 rts
*--------------------------------------
CC.KW.DO
lda #E.CSYN
sec
rts
*--------------------------------------
CC.KW.DO.END
clc
rts
*--------------------------------------
* for (e1;e2;e3) s;
*
* e1;
* while (e2)
* {
* s;
* cont:
* e3;
* }
* break:
*--------------------------------------
CC.KW.FOR jsr CC.GetCharNB
bcs .19
cmp #'('
bne .19
jsr CC.GetNextCharNB
bcs .19
2022-01-30 21:47:08 +00:00
jsr CC.EXP.Eval00 get e1
bcs .29
jsr CC.KW.StackDiscard
2022-01-30 21:47:08 +00:00
jsr CC.GetCharNB
bcs .19
cmp #';'
bne .19
jsr CC.GetNextCharNB skip ';'
.19 bcs .9
*--------------------------------------
>LDYA ZPCCCode
>STYA ZPPtr2 save LOOP address
jsr CC.EXP.Eval00 get e2
.29 bcs .99
jsr CC.KW.TestZero
jsr CC.PushCS push place to set JMP break:
bcs .99
jsr CC.KW.ZPCCCodeAdd2
lda #$20 emit JSR s;
jsr CODE.EmitByte
>LDYA ZPCCCode
>STYA ZPPtr3 save place to set JSR s
jsr CC.KW.ZPCCCodeAdd2 space for 2-bytes address
jsr CC.GetCharNB
bcs .9
2022-01-30 21:47:08 +00:00
cmp #';'
bne .9
jsr CC.GetNextCharNB skip ';'
bcs .9
*--------------------------------------
jsr CC.PushCS push cont: address
jsr CC.EXP.Eval00 get e3
bcs .99
jsr CC.KW.StackDiscard
jsr CC.GetCharNB
bcs .9
cmp #')'
bne .9
lda #$4C
ldx ZPPtr2
ldy ZPPtr2+1
jsr CODE.TOABSYX JMP e2
lda ZPCCCode setup JSR s;
sta (ZPPtr3)
lda ZPCCCode+1
ldy #1
sta (ZPPtr3),y
jmp CC.KW.BEGIN
.9 lda #E.CSYN
sec
.99 rts
*--------------------------------------
CC.KW.FOR.END lda #$60
jsr CODE.EmitByte set RTS for JSR s;
jsr CC.Pop
bcs .9
2022-01-30 21:47:08 +00:00
jsr CC.Pop discard cont: location
bcs .9
jsr CC.PopYA
bcs .9
>STYA ZPPtr1 get JMP break: location
lda ZPCCCode
sta (ZPPtr1)
2022-01-30 21:47:08 +00:00
ldy #1
lda ZPCCCode+1
sta (ZPPtr1),y
clc
.9 rts
*--------------------------------------
2022-01-30 21:47:08 +00:00
CC.KW.SWITCH
CC.KW.CASE
CC.KW.BREAK
CC.KW.CONTINUE
lda #E.CSYN
sec
rts
*--------------------------------------
CC.KW.RETURN ldy CStackPtr
beq .9
.1 iny skip ; or }
beq .9
lda (ZPCCStack),y
bmi .7 f()
tya
clc
adc #3 skip CPStmt (4 bytes)
tay
bcc .1
.9 lda #E.STACKERROR
sec
.99 rts
.7 iny skip bState
iny skip Locals
iny get SYM.T
lda (ZPCCStack),y
pha
iny get SYM.Q
lda (ZPCCStack),y
ply
jsr CC.EXP.Eval
bcs .99
jsr CC.SYM.GetYASizeOfInAXC Y,A=T/Q
tax X = sizeof
jsr CODE.SetRetValue
jsr CODE.Leave
clc
rts
*--------------------------------------
CC.KW.SIZEOF
2022-02-04 14:57:17 +00:00
lda #E.CSYN
sec
rts
*--------------------------------------
2022-01-30 21:47:08 +00:00
CC.KW.STRUCT >ENTER 4
jsr CC.GetCharNB
bcs .99
>LDA.G CC.hTags
2022-01-30 21:47:08 +00:00
jsr CC.SYM.NewKey
bcs .99
sta (pStack) Y,A = KeyID
tya
ldy #1
sta (pStack),y
2022-02-04 14:57:17 +00:00
jsr CC.SkipX
jsr CC.GetNextCharNB
bcs .99
cmp #'{'
bne .99
.1 jsr CC.GetNextCharNB
bcs .99
cmp #'}'
bne .1
jsr CC.GetNextCharNB skip }
clc
.99 >LEAVE
rts
*--------------------------------------
2022-01-30 21:47:08 +00:00
CC.KW.BEGIN jsr CC.GetNextCharNB
bcs .9
cmp #'{'
bne .7
>LDA.G CC.CmdSave
tax
jmp CC.STMT.CPStmt
.7 >LDA.G CC.CmdSave
jsr CC.Push
bcs .99
2022-01-30 21:47:08 +00:00
lda #';'
jmp CC.Push
2022-01-30 21:47:08 +00:00
.9 lda #E.CSYN
sec
.99 rts
*--------------------------------------
2022-01-30 21:47:08 +00:00
* Input : Value on Stack, Y,A = Type/Qual
* Output : CC = true, CS = false
*--------------------------------------
CC.KW.TestZero jsr CC.SYM.GetYASizeOfInAXC
tax
.6 lda #$A2 LDX #imm
jsr CODE.EmitByte
txa
jsr CODE.EmitByte
ldx #PCC.Test0X.L
ldy #0
2022-01-30 21:47:08 +00:00
.7 lda PCC.Test0X,y
jsr CODE.EmitByte
iny
dex
bne .7
clc
rts
*--------------------------------------
2022-01-30 21:47:08 +00:00
CC.KW.ZPCCCodeAdd2
lda ZPCCCode
clc
adc #2
sta ZPCCCode
bcc .8
2022-01-30 21:47:08 +00:00
inc ZPCCCode+1
2022-01-30 21:47:08 +00:00
.8 rts
*--------------------------------------
2022-01-30 21:47:08 +00:00
* Input : Value on Stack, Y,A = Type/Qual
*--------------------------------------
2022-01-30 21:47:08 +00:00
CC.KW.StackDiscard
2022-01-30 21:47:08 +00:00
jsr CC.TYPE.SizeOf
txa
beq .8 void
2022-01-30 21:47:08 +00:00
jsr CODE.AddLocal
.8 clc
2022-01-30 21:47:08 +00:00
.9 rts
*--------------------------------------
MAN
SAVE usr/src/bin/cc.s.kw
LOAD usr/src/bin/cc.s
ASM