2020-11-25 09:36:30 +00:00
|
|
|
|
NEW
|
|
|
|
|
AUTO 3,1
|
|
|
|
|
*--------------------------------------
|
2020-12-02 15:22:57 +00:00
|
|
|
|
CP.RUN cpx #KW.CONLY
|
|
|
|
|
bcs .1 >= KW.CONLY
|
|
|
|
|
|
|
|
|
|
cpx #KW.ECOLON.ID
|
|
|
|
|
beq .1 END Compilation
|
2020-11-26 19:47:57 +00:00
|
|
|
|
|
|
|
|
|
>LDYA J.KEYWORDS,x
|
2020-11-25 09:36:30 +00:00
|
|
|
|
clc
|
2020-12-02 15:22:57 +00:00
|
|
|
|
jmp CP.Emit.JsrYA
|
2020-11-26 19:47:57 +00:00
|
|
|
|
|
2020-12-02 15:22:57 +00:00
|
|
|
|
.1 jmp (J.KEYWORDS,x)
|
2020-11-26 19:47:57 +00:00
|
|
|
|
*--------------------------------------
|
2020-12-23 14:54:57 +00:00
|
|
|
|
CP.DO jsr CP.Emit.DO I,n -> RP
|
|
|
|
|
* >DEBUG
|
|
|
|
|
ldy RP
|
|
|
|
|
|
|
|
|
|
lda ZPCodePtr+1
|
|
|
|
|
sta (pData),y
|
|
|
|
|
dey
|
|
|
|
|
|
|
|
|
|
lda ZPCodePtr
|
|
|
|
|
sta (pData),y
|
|
|
|
|
dey push CodePtr=DOTEST on RP for LOOP/LEAVE
|
|
|
|
|
|
|
|
|
|
sty RP
|
|
|
|
|
|
|
|
|
|
jsr CP.Emit.DOTEST CODE: I < n ?
|
|
|
|
|
|
|
|
|
|
ldx #KW.DO.ID
|
|
|
|
|
jsr CP.Emit.JMP0000 to put jmp LOOPEND
|
|
|
|
|
|
2020-12-02 15:22:57 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
2020-11-26 19:47:57 +00:00
|
|
|
|
*--------------------------------------
|
2020-12-17 20:23:54 +00:00
|
|
|
|
CP.LOOP lda #$00
|
|
|
|
|
jsr CP.Emit.PUSHBI >PUSHBI 0
|
|
|
|
|
|
|
|
|
|
lda #$01 >PUSHBI 1
|
|
|
|
|
jsr CP.Emit.PUSHBI
|
2020-12-02 15:22:57 +00:00
|
|
|
|
*--------------------------------------
|
2020-12-23 14:54:57 +00:00
|
|
|
|
CP.pLOOP ldy RP
|
|
|
|
|
* >DEBUG
|
|
|
|
|
iny
|
|
|
|
|
bmi .9
|
|
|
|
|
|
|
|
|
|
lda (pData),y
|
|
|
|
|
cmp #KW.DO.ID
|
|
|
|
|
bne .9
|
|
|
|
|
|
|
|
|
|
phy
|
|
|
|
|
jsr CP.Emit.LOOP CODE: I=I+n
|
|
|
|
|
ply
|
|
|
|
|
|
|
|
|
|
iny POP LOOPEND@ -> Ptr1
|
|
|
|
|
lda (pData),y
|
|
|
|
|
sta ZPPtr1
|
2020-12-17 20:23:54 +00:00
|
|
|
|
|
2020-12-23 14:54:57 +00:00
|
|
|
|
iny
|
|
|
|
|
lda (pData),y
|
|
|
|
|
sta ZPPtr1+1
|
|
|
|
|
|
|
|
|
|
jsr CP.Emit.JMPBack CODE: JMP to DOTEST
|
|
|
|
|
|
|
|
|
|
sty RP discard ID DOTEST@ LOOPEND@
|
|
|
|
|
|
|
|
|
|
jsr CP.UpdatePtr1 update JMP LOOPEND@ with CodePtr
|
|
|
|
|
|
|
|
|
|
jsr CP.Emit.LOOPEND
|
2020-12-17 20:23:54 +00:00
|
|
|
|
|
2020-12-02 15:22:57 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
2020-12-23 14:54:57 +00:00
|
|
|
|
|
|
|
|
|
.9 lda #E.NODO
|
|
|
|
|
sec
|
|
|
|
|
rts
|
2020-11-26 19:47:57 +00:00
|
|
|
|
*--------------------------------------
|
2020-12-17 20:23:54 +00:00
|
|
|
|
CP.I jsr CP.Emit.I
|
2020-12-02 15:22:57 +00:00
|
|
|
|
clc
|
2020-12-17 20:23:54 +00:00
|
|
|
|
rts
|
2020-11-26 19:47:57 +00:00
|
|
|
|
*--------------------------------------
|
2020-12-23 14:54:57 +00:00
|
|
|
|
CP.LEAVE ldy RP
|
|
|
|
|
* >DEBUG
|
|
|
|
|
.1 iny
|
|
|
|
|
bmi .9
|
2020-11-26 19:47:57 +00:00
|
|
|
|
|
2020-12-23 14:54:57 +00:00
|
|
|
|
lda (pData),y
|
|
|
|
|
cmp #KW.DO.ID
|
|
|
|
|
beq .2
|
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
|
iny
|
|
|
|
|
bpl .1 skip 3 bytes on RP
|
|
|
|
|
|
|
|
|
|
.9 lda #E.NODO
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.2 phy
|
|
|
|
|
jsr CP.Emit.LEAVE set I = END on RP
|
|
|
|
|
ply
|
|
|
|
|
|
|
|
|
|
iny skip LOOPEND ptr
|
|
|
|
|
iny
|
|
|
|
|
|
|
|
|
|
jsr CP.Emit.JMPBack jmp DOTEST
|
|
|
|
|
|
2020-11-26 19:47:57 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
2020-11-25 09:36:30 +00:00
|
|
|
|
*--------------------------------------
|
2020-12-02 15:22:57 +00:00
|
|
|
|
CP.IF jsr CP.Emit.TESTTRUE
|
2020-12-23 14:54:57 +00:00
|
|
|
|
ldx #KW.IF.ID
|
2020-12-02 15:22:57 +00:00
|
|
|
|
jsr CP.Emit.JMP0000 to put jmp -> ELSE/ENDIF later
|
2020-11-26 19:47:57 +00:00
|
|
|
|
|
2020-11-27 16:37:47 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2020-12-23 14:54:57 +00:00
|
|
|
|
CP.ELSE jsr CP.PopCodePtr get previous JMP -> ptr1
|
|
|
|
|
ldx #KW.IF.ID
|
2020-12-17 20:23:54 +00:00
|
|
|
|
jsr CP.Emit.JMP0000 to put jmp -> ENDIF later
|
2020-11-29 13:16:39 +00:00
|
|
|
|
jsr CP.UpdatePtr1
|
2020-11-25 16:29:06 +00:00
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
rts
|
2020-11-25 09:36:30 +00:00
|
|
|
|
*--------------------------------------
|
2020-12-23 14:54:57 +00:00
|
|
|
|
CP.ENDIF jsr CP.PopCodePtr
|
2020-11-29 13:16:39 +00:00
|
|
|
|
jsr CP.UpdatePtr1
|
2020-11-26 19:47:57 +00:00
|
|
|
|
|
2020-11-25 16:29:06 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
2020-11-25 09:36:30 +00:00
|
|
|
|
*--------------------------------------
|
2020-12-23 14:54:57 +00:00
|
|
|
|
CP.BEGIN jsr CP.PushCodePtr X = BEGIN ID
|
2020-11-29 13:16:39 +00:00
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
rts
|
2020-11-26 19:47:57 +00:00
|
|
|
|
*--------------------------------------
|
2020-12-02 15:22:57 +00:00
|
|
|
|
CP.UNTIL jsr CP.Emit.TESTFALSE
|
2020-11-29 13:16:39 +00:00
|
|
|
|
|
2020-12-23 14:54:57 +00:00
|
|
|
|
bra CP.WHILE.1
|
2020-11-26 19:47:57 +00:00
|
|
|
|
*--------------------------------------
|
2020-12-23 14:54:57 +00:00
|
|
|
|
CP.REPEAT ldy RP
|
|
|
|
|
iny
|
|
|
|
|
bmi CP.E.NOBEGIN
|
|
|
|
|
|
|
|
|
|
jsr CP.Emit.JMPBack
|
2020-11-26 19:47:57 +00:00
|
|
|
|
|
2020-11-29 13:16:39 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
2020-11-26 19:47:57 +00:00
|
|
|
|
*--------------------------------------
|
2020-12-02 15:22:57 +00:00
|
|
|
|
CP.WHILE jsr CP.Emit.TESTTRUE
|
2020-12-23 14:54:57 +00:00
|
|
|
|
|
|
|
|
|
CP.WHILE.1 ldy RP
|
|
|
|
|
iny
|
|
|
|
|
bmi CP.E.NOBEGIN
|
|
|
|
|
|
2020-12-02 15:22:57 +00:00
|
|
|
|
jsr CP.Emit.JMPBack
|
|
|
|
|
jsr CP.Emit.RPDROP2
|
2020-11-27 16:37:47 +00:00
|
|
|
|
|
2020-12-17 20:23:54 +00:00
|
|
|
|
clc
|
2020-11-29 13:16:39 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2020-12-23 14:54:57 +00:00
|
|
|
|
CP.E.NOBEGIN lda #E.NOFOR
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2020-12-02 15:22:57 +00:00
|
|
|
|
CP.Emit.JMP0000 lda #$4C JMP
|
|
|
|
|
jsr CP.Emit.Byte
|
2020-11-27 16:37:47 +00:00
|
|
|
|
|
|
|
|
|
jsr CP.PushCodePtr
|
|
|
|
|
|
|
|
|
|
lda #0
|
2020-12-02 15:22:57 +00:00
|
|
|
|
jsr CP.Emit.Byte
|
|
|
|
|
jsr CP.Emit.Byte
|
2020-11-27 16:37:47 +00:00
|
|
|
|
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2020-12-02 15:22:57 +00:00
|
|
|
|
CP.Emit.JMPBack lda #$4C JMP
|
|
|
|
|
jsr CP.Emit.Byte
|
2020-12-23 14:54:57 +00:00
|
|
|
|
|
2020-12-02 15:22:57 +00:00
|
|
|
|
iny
|
|
|
|
|
lda (pData),y
|
|
|
|
|
jsr CP.Emit.Byte
|
2020-12-17 20:23:54 +00:00
|
|
|
|
|
2020-12-02 15:22:57 +00:00
|
|
|
|
iny
|
|
|
|
|
lda (pData),y
|
|
|
|
|
jmp CP.Emit.Byte
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CP.Emit.RPDROP2 ldx #CODE.RPDROP2.L
|
|
|
|
|
ldy #0
|
2020-11-29 13:16:39 +00:00
|
|
|
|
|
2020-12-02 15:22:57 +00:00
|
|
|
|
.1 lda CODE.RPDROP2,y
|
|
|
|
|
jsr CP.Emit.Byte
|
|
|
|
|
iny
|
|
|
|
|
dex
|
|
|
|
|
bne .1
|
2020-11-29 13:16:39 +00:00
|
|
|
|
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2020-12-02 15:22:57 +00:00
|
|
|
|
CP.Emit.TESTTRUE
|
|
|
|
|
ldx #CODE.TESTTRUE.L
|
|
|
|
|
ldy #0
|
2020-11-26 19:47:57 +00:00
|
|
|
|
|
2020-12-02 15:22:57 +00:00
|
|
|
|
.1 lda CODE.TESTTRUE,y
|
|
|
|
|
jsr CP.Emit.Byte
|
|
|
|
|
iny
|
|
|
|
|
dex
|
|
|
|
|
bne .1
|
2020-12-17 20:23:54 +00:00
|
|
|
|
|
2020-12-02 15:22:57 +00:00
|
|
|
|
rts
|
2020-11-26 19:47:57 +00:00
|
|
|
|
*--------------------------------------
|
2020-12-02 15:22:57 +00:00
|
|
|
|
CP.Emit.TESTFALSE
|
|
|
|
|
ldx #CODE.TESTFALSE.L
|
|
|
|
|
ldy #0
|
2020-11-26 19:47:57 +00:00
|
|
|
|
|
2020-12-02 15:22:57 +00:00
|
|
|
|
.1 lda CODE.TESTFALSE,y
|
|
|
|
|
jsr CP.Emit.Byte
|
|
|
|
|
iny
|
|
|
|
|
dex
|
|
|
|
|
bne .1
|
2020-12-17 20:23:54 +00:00
|
|
|
|
|
2020-12-02 15:22:57 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CP.Emit.PULLA ldx #CODE.PULLA.L
|
|
|
|
|
ldy #0
|
2020-11-26 19:47:57 +00:00
|
|
|
|
|
2020-12-02 15:22:57 +00:00
|
|
|
|
.1 lda CODE.PULLA,y
|
|
|
|
|
jsr CP.Emit.Byte
|
|
|
|
|
iny
|
|
|
|
|
dex
|
|
|
|
|
bne .1
|
2020-12-17 20:23:54 +00:00
|
|
|
|
|
2020-12-02 15:22:57 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2020-12-17 20:23:54 +00:00
|
|
|
|
CP.Emit.PUSHBI pha
|
|
|
|
|
lda #$A9 lda #imm
|
|
|
|
|
jsr CP.Emit.Byte
|
|
|
|
|
pla
|
|
|
|
|
jsr CP.Emit.Byte
|
|
|
|
|
*--------------------------------------
|
2020-12-02 15:22:57 +00:00
|
|
|
|
CP.Emit.PUSHA ldx #CODE.PUSHA.L
|
|
|
|
|
ldy #0
|
2020-11-26 19:47:57 +00:00
|
|
|
|
|
2020-12-02 15:22:57 +00:00
|
|
|
|
.1 lda CODE.PUSHA,y
|
|
|
|
|
jsr CP.Emit.Byte
|
|
|
|
|
iny
|
|
|
|
|
dex
|
|
|
|
|
bne .1
|
2020-12-17 20:23:54 +00:00
|
|
|
|
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CP.Emit.DO ldx #CODE.DO.L
|
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
|
|
.1 lda CODE.DO,y
|
|
|
|
|
jsr CP.Emit.Byte
|
|
|
|
|
iny
|
|
|
|
|
dex
|
|
|
|
|
bne .1
|
|
|
|
|
|
2020-12-02 15:22:57 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2020-12-23 14:54:57 +00:00
|
|
|
|
CP.Emit.DOTEST ldx #CODE.DOTEST.L
|
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
|
|
.1 lda CODE.DOTEST,y
|
|
|
|
|
jsr CP.Emit.Byte
|
|
|
|
|
iny
|
|
|
|
|
dex
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2020-12-02 15:22:57 +00:00
|
|
|
|
CP.Emit.LOOP ldx #CODE.LOOP.L
|
|
|
|
|
ldy #0
|
2020-11-26 19:47:57 +00:00
|
|
|
|
|
2020-12-02 15:22:57 +00:00
|
|
|
|
.1 lda CODE.LOOP,y
|
|
|
|
|
jsr CP.Emit.Byte
|
|
|
|
|
iny
|
|
|
|
|
dex
|
|
|
|
|
bne .1
|
2020-12-17 20:23:54 +00:00
|
|
|
|
|
2020-12-02 15:22:57 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CP.Emit.LOOPEND ldx #CODE.LOOPEND.L
|
|
|
|
|
ldy #0
|
2020-11-26 19:47:57 +00:00
|
|
|
|
|
2020-12-02 15:22:57 +00:00
|
|
|
|
.1 lda CODE.LOOPEND,y
|
|
|
|
|
jsr CP.Emit.Byte
|
|
|
|
|
iny
|
|
|
|
|
dex
|
|
|
|
|
bne .1
|
2020-12-17 20:23:54 +00:00
|
|
|
|
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CP.Emit.I ldx #CODE.I.L
|
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
|
|
.1 lda CODE.I,y
|
|
|
|
|
jsr CP.Emit.Byte
|
|
|
|
|
iny
|
|
|
|
|
dex
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CP.Emit.LEAVE ldx #CODE.LEAVE.L
|
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
|
|
.1 lda CODE.LEAVE,y
|
|
|
|
|
jsr CP.Emit.Byte
|
|
|
|
|
iny
|
|
|
|
|
dex
|
|
|
|
|
bne .1
|
|
|
|
|
|
2020-12-02 15:22:57 +00:00
|
|
|
|
rts
|
2020-11-26 19:47:57 +00:00
|
|
|
|
*--------------------------------------
|
2020-12-02 15:22:57 +00:00
|
|
|
|
CP.Emit.JsrYA pha
|
2020-11-26 19:47:57 +00:00
|
|
|
|
lda #$20
|
2020-12-02 15:22:57 +00:00
|
|
|
|
jsr CP.Emit.Byte
|
2020-11-26 19:47:57 +00:00
|
|
|
|
tya
|
2020-12-02 15:22:57 +00:00
|
|
|
|
jsr CP.Emit.Byte
|
2020-11-26 19:47:57 +00:00
|
|
|
|
pla
|
|
|
|
|
*--------------------------------------
|
2020-12-02 15:22:57 +00:00
|
|
|
|
CP.Emit.Byte sta (ZPCodePtr)
|
2020-11-26 19:47:57 +00:00
|
|
|
|
inc ZPCodePtr
|
|
|
|
|
bne .8
|
|
|
|
|
inc ZPCodePtr+1
|
|
|
|
|
.8 rts
|
|
|
|
|
*--------------------------------------
|
2020-12-17 20:23:54 +00:00
|
|
|
|
CP.PushCodePtr ldy RP
|
|
|
|
|
|
|
|
|
|
lda ZPCodePtr+1
|
|
|
|
|
sta (pData),y
|
|
|
|
|
dey
|
|
|
|
|
|
|
|
|
|
lda ZPCodePtr
|
|
|
|
|
sta (pData),y
|
|
|
|
|
dey
|
|
|
|
|
|
2020-12-23 14:54:57 +00:00
|
|
|
|
txa
|
|
|
|
|
sta (pData),y
|
|
|
|
|
dey
|
|
|
|
|
|
2020-12-17 20:23:54 +00:00
|
|
|
|
sty RP
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2020-12-23 14:54:57 +00:00
|
|
|
|
CP.PopCodePtr ldy RP
|
|
|
|
|
iny
|
|
|
|
|
lda (pData),y
|
|
|
|
|
cmp #KW.IF.ID
|
|
|
|
|
bne .9
|
|
|
|
|
|
2020-12-17 20:23:54 +00:00
|
|
|
|
iny
|
|
|
|
|
lda (pData),y
|
|
|
|
|
sta ZPPtr1
|
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
|
lda (pData),y
|
|
|
|
|
sta ZPPtr1+1
|
|
|
|
|
|
|
|
|
|
sty RP
|
|
|
|
|
|
2020-12-23 14:54:57 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.9 lda #E.NOIF
|
|
|
|
|
sec
|
2020-12-17 20:23:54 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CP.UpdatePtr1 lda ZPCodePtr
|
|
|
|
|
sta (ZPPtr1)
|
|
|
|
|
|
|
|
|
|
ldy #1
|
|
|
|
|
lda ZPCodePtr+1
|
|
|
|
|
sta (ZPPtr1),y
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2020-11-25 09:36:30 +00:00
|
|
|
|
MAN
|
|
|
|
|
SAVE usr/src/bin/forth.s.cp
|
|
|
|
|
LOAD usr/src/bin/forth.s
|
|
|
|
|
ASM
|