NEW AUTO 3,1 .LIST OFF *-------------------------------------- * Built in Keywords *-------------------------------------- CC.KW.JMP txa >STA.G CC.CmdSave jmp (J.CC.KW,x) *-------------------------------------- CC.KW.WHILE jsr CC.PushCS push cont: for WHILE loop bcs CC.KW.IF.RTS *-------------------------------------- CC.KW.IF jsr CC.GetCharNB bcs .9 cmp #'(' bne .9 jsr CC.GetNextCharNB bcs .9 jsr CC.EXP.Eval00 Any var type bcs .99 jsr CC.KW.TestZero jsr CC.PushCS push place to set JMP false bcs .99 jsr CC.KW.ZPCCCodeAdd2 jsr CC.GetCharNB bcs .99 cmp #')' bne .9 jmp CC.KW.BEGIN .9 lda #E.CSYN sec .99 CC.KW.IF.RTS rts *-------------------------------------- CC.KW.IF.END jsr CC.PopYA bcs .9 >STYA ZPPtr1 set JMP false lda ZPCCCode sta (ZPPtr1) ldy #1 lda ZPCCCode+1 sta (ZPPtr1),y * clc .9 rts *-------------------------------------- CC.KW.ELSE clc rts *-------------------------------------- CC.KW.ELSE.END clc rts *-------------------------------------- CC.KW.WHILE.END jsr CC.PopYA Get JMP false location bcs .9 >STYA ZPPtr1 jsr CC.PopYA Get cont: address bcs .9 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 jsr CC.EXP.Eval00 get e1 bcs .29 jsr CC.KW.StackDiscard 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 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 jsr CC.Pop discard cont: location bcs .9 jsr CC.PopYA bcs .9 >STYA ZPPtr1 get JMP break: location lda ZPCCCode sta (ZPPtr1) ldy #1 lda ZPCCCode+1 sta (ZPPtr1),y clc .9 rts *-------------------------------------- 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 lda #E.CSYN sec rts *-------------------------------------- CC.KW.STRUCT >ENTER 4 jsr CC.GetCharNB bcs .99 >LDA.G CC.hTags jsr CC.SYM.NewKey bcs .99 sta (pStack) Y,A = KeyID tya ldy #1 sta (pStack),y 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 *-------------------------------------- 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 lda #';' jmp CC.Push .9 lda #E.CSYN sec .99 rts *-------------------------------------- * 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 .7 lda PCC.Test0X,y jsr CODE.EmitByte iny dex bne .7 clc rts *-------------------------------------- CC.KW.ZPCCCodeAdd2 lda ZPCCCode clc adc #2 sta ZPCCCode bcc .8 inc ZPCCCode+1 .8 rts *-------------------------------------- * Input : Value on Stack, Y,A = Type/Qual *-------------------------------------- CC.KW.StackDiscard jsr CC.TYPE.SizeOf txa beq .8 void jsr CODE.AddLocal .8 clc .9 rts *-------------------------------------- MAN SAVE usr/src/bin/cc.s.kw LOAD usr/src/bin/cc.s ASM