A2osX/BIN/FORTH.S.txt

1195 lines
26 KiB
Plaintext
Raw Normal View History

2020-11-19 15:34:02 +00:00
NEW
AUTO 3,1
.LIST OFF
.OP 65C02
.OR $2000
.TF bin/forth
2021-04-11 19:47:48 +00:00
*--------------------------------------
2021-06-05 15:48:54 +00:00
HIS.MAX .EQ 10
HISTORY.MAX .EQ 512
2020-11-19 15:34:02 +00:00
*--------------------------------------
.INB inc/macros.i
.INB inc/a2osx.i
2020-12-17 20:23:54 +00:00
.INB inc/kernel.i
2020-11-19 15:34:02 +00:00
.INB inc/mli.i
.INB inc/mli.e.i
2020-12-15 13:23:22 +00:00
.INB inc/gfx.i
2020-11-19 15:34:02 +00:00
*--------------------------------------
2020-11-23 22:05:27 +00:00
CODE.SIZE .EQ 2048
DATA.SIZE .EQ 2048
INPUT.SIZE .EQ 256
OUTPUT.SIZE .EQ 256
CL.SIZE .EQ 256
*--------------------------------------
SYM.T.CONST .EQ 0
SYM.T.VAR .EQ 64
SYM.T.CODE .EQ 128
2020-11-19 15:34:02 +00:00
*--------------------------------------
.DUMMY
.OR ZPBIN
ZS.START
2020-11-23 22:05:27 +00:00
ZPCodePtr .BS 2
ZPDataPtr .BS 2
2020-12-02 15:22:57 +00:00
ZPInputBufPtr .BS 2
ZPOutputBufPtr .BS 2
2020-11-19 15:34:02 +00:00
ZPKeyID .BS 2
2020-11-23 22:05:27 +00:00
ZPType .BS 1
.BS 1
2020-11-19 15:34:02 +00:00
ZPAddrPtr .BS 2
ZPPtr1 .BS 2
ZPPtr2 .BS 2
ZPPtr3 .BS 2
2020-11-23 22:05:27 +00:00
ZPCLBuf .BS 2
ZPCLBufPtr .BS 2
2020-11-19 15:34:02 +00:00
CL.Ptr .BS 1
CL.Len .BS 1
CL.bReady .BS 1
CL.bEscMode .BS 1
CL.MaxCnt .BS 1
2020-11-23 22:05:27 +00:00
ArgIndex .EQ *
bCompile .BS 1
RP .BS 1
2020-11-29 13:16:39 +00:00
Sign .BS 1
2020-11-19 15:34:02 +00:00
ZS.END .ED
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA #0 S.PS.F.EVENT
.DA #0
.DA CS.END-CS.START Code Size (without Constants)
.DA DS.END-DS.START Data SegmentSize
.DA #256 Stack Size
.DA #ZS.END-ZS.START Zero Page Size
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
2020-12-15 13:23:22 +00:00
L.DEV.GFX .DA DEV.GFX
2020-11-19 15:34:02 +00:00
L.MSG.GREETINGS .DA MSG.GREETINGS
2021-06-05 15:48:54 +00:00
L.MSG.HIS .DA MSG.HIS
L.MSG.HISPROMPT .DA MSG.HISPROMPT
L.MSG.HISROMPTCLR .DA MSG.HISROMPTCLR
2020-11-19 15:34:02 +00:00
L.MSG.USAGE .DA MSG.USAGE
L.MSG.ECHOCRLF .DA MSG.ECHOCRLF
L.MSG.DEBUG .DA MSG.DEBUG
2020-11-29 13:16:39 +00:00
L.MSG.TRACE .DA MSG.TRACE
2020-11-19 15:34:02 +00:00
L.MSG.PROMPT .DA MSG.PROMPT
L.MSG.PROMPTCRLF .DA MSG.PROMPTCRLF
2020-11-29 13:16:39 +00:00
L.MSG.OK .DA MSG.OK
2020-12-02 15:22:57 +00:00
L.MSG.DUMP2 .DA MSG.DUMP2
L.MSG.TYPES .DA MSG.CONST
.DA MSG.VAR
.DA MSG.CODE
2020-11-19 15:34:02 +00:00
L.FMT.Byte .DA FMT.Byte
L.FMT.int16 .DA FMT.int16
2021-04-15 14:03:04 +00:00
L.FMT.uint16 .DA FMT.uint16
2021-04-30 15:25:19 +00:00
L.FMT.int32 .DA FMT.int32
2020-11-19 15:34:02 +00:00
J.ESC .DA CL.BS left arrow
2021-04-11 19:47:48 +00:00
.DA HIS.GetNext
.DA HIS.GetPrev
.DA CL.FS right arrow
2020-11-19 15:34:02 +00:00
L.KEYWORDS .DA KEYWORDS
2021-06-05 15:48:54 +00:00
I.KEYWORDS .DA GFX.TEXT
.DA GFX.GR
.DA GFX.PLOT
2020-12-15 13:23:22 +00:00
.DA GFX.RECT
2021-04-30 15:25:19 +00:00
.DA KW.DUP
2020-11-19 15:34:02 +00:00
.DA KW.DROP
.DA KW.SWAP
2021-04-30 15:25:19 +00:00
.DA KW.OVER
2020-11-19 15:34:02 +00:00
.DA KW.ROT
2021-04-29 11:56:34 +00:00
.DA KW.qDUP
2021-04-30 15:25:19 +00:00
.DA KW.Add
2020-11-19 15:34:02 +00:00
.DA KW.DAdd
.DA KW.Sub
2021-04-29 11:56:34 +00:00
.DA KW.DSub
2020-11-19 15:34:02 +00:00
.DA KW.Mul
.DA KW.Div
.DA KW.Mod
.DA KW.DivMod
.DA KW.MulDivMod
.DA KW.MulDiv
.DA KW.MAX
.DA KW.MIN
.DA KW.ABS
.DA KW.DABS
2021-04-29 11:56:34 +00:00
.DA KW.NEGATE
.DA KW.DNEGATE
2020-11-19 15:34:02 +00:00
.DA KW.AND
.DA KW.OR
.DA KW.XOR
2021-04-30 15:25:19 +00:00
.DA KW.LWR
2020-11-19 15:34:02 +00:00
.DA KW.GTR
.DA KW.EQ
.DA KW.NEGATIVE
.DA KW.ZERO
.DA KW..
2021-04-15 14:03:04 +00:00
.DA KW.U.
2020-11-19 15:34:02 +00:00
.DA KW..R
.DA KW.D.
.DA KW.D.R
.DA KW.CR
.DA KW.SPACE
.DA KW.SPACES
.DA KW.PRINT
.DA KW.DUMP
.DA KW.TYPE
.DA KW.COUNT
.DA KW.TERMINAL
.DA KW.KEY
.DA KW.EMIT
.DA KW.EXPECT
.DA KW.WORD
.DA KW.NUMBER
.DA KW.STARTSTR
.DA KW.STRADD
.DA KW.STRDBL
.DA KW.SIGN
.DA KW.ENDSTR
.DA KW.HOLD
.DA KW.DECIMAL
.DA KW.HEX
.DA KW.OCTAL
2021-04-15 14:03:04 +00:00
.DA KW.FETCHSP
2020-11-19 15:34:02 +00:00
.DA KW.FETCHW
.DA KW.STOREW
.DA KW.FETCHB
.DA KW.STOREB
.DA KW.FETCHPRINTW
.DA KW.ADDTOW
.DA KW.CMOVE
.DA KW.FILL
.DA KW.ERASE
.DA KW.BLANKS
.DA KW.HERE
.DA KW.PAD
.DA KW.ALLOT
.DA KW.nCOMPILE
.DA KW.QUOTE
.DA KW.FORGET
.DA KW.DEFINITIONS
.DA KW.VOCABULARY
.DA KW.FORTH
.DA KW.EDITOR
.DA KW.ASSEMBLER
.DA KW.VLIST
.DA KW.VARIABLE
.DA KW.CONSTANT
2020-11-29 13:16:39 +00:00
*--------------------------------------
2020-12-02 15:22:57 +00:00
.DA KW.BCOLON
2021-04-30 15:25:19 +00:00
.DA KW.INVALID KW.ECOLON
2020-11-19 15:34:02 +00:00
.DA KW.ACODE
.DA KW.FCODE
2021-04-30 15:25:19 +00:00
KW.DO.ID .EQ *-I.KEYWORDS
.DA KW.INVALID KW.DO
.DA KW.INVALID KW.LOOP
.DA KW.INVALID KW.pLOOP
.DA KW.INVALID KW.I
.DA KW.INVALID KW.LEAVE
KW.IF.ID .EQ *-I.KEYWORDS
.DA KW.INVALID KW.IF
.DA KW.INVALID KW.ELSE
.DA KW.INVALID KW.THEN
.DA KW.INVALID KW.BEGIN
.DA KW.INVALID KW.UNTIL
.DA KW.INVALID KW.REPEAT
.DA KW.INVALID KW.WHILE
.DA KW.gR
.DA KW.Rg
.DA KW.R
2020-12-02 15:22:57 +00:00
*--------------------------------------
2021-06-05 15:48:54 +00:00
C.KEYWORDS .DA CP.JSRX GFX.TEXT
.DA CP.JSRX GFX.GR
.DA CP.JSRX GFX.PLOT
2021-04-30 15:25:19 +00:00
.DA CP.JSRX GFX.RECT
.DA CP.JSRX KW.DUP
.DA CP.JSRX KW.DROP
.DA CP.JSRX KW.SWAP
.DA CP.JSRX KW.OVER
.DA CP.JSRX KW.ROT
.DA CP.JSRX KW.qDUP
.DA CP.JSRX KW.Add
.DA CP.JSRX KW.DAdd
.DA CP.JSRX KW.Sub
.DA CP.JSRX KW.DSub
.DA CP.JSRX KW.Mul
.DA CP.JSRX KW.Div
.DA CP.JSRX KW.Mod
.DA CP.JSRX KW.DivMod
.DA CP.JSRX KW.MulDivMod
.DA CP.JSRX KW.MulDiv
.DA CP.JSRX KW.MAX
.DA CP.JSRX KW.MIN
.DA CP.JSRX KW.ABS
.DA CP.JSRX KW.DABS
.DA CP.JSRX KW.NEGATE
.DA CP.JSRX KW.DNEGATE
.DA CP.JSRX KW.AND
.DA CP.JSRX KW.OR
.DA CP.JSRX KW.XOR
.DA CP.JSRX KW.LWR
.DA CP.JSRX KW.GTR
.DA CP.JSRX KW.EQ
.DA CP.JSRX KW.NEGATIVE
.DA CP.JSRX KW.ZERO
.DA CP.JSRX KW..
.DA CP.JSRX KW.U.
.DA CP.JSRX KW..R
.DA CP.JSRX KW.D.
.DA CP.JSRX KW.D.R
.DA CP.JSRX KW.CR
.DA CP.JSRX KW.SPACE
.DA CP.JSRX KW.SPACES
.DA CP.PRINT
.DA CP.JSRX KW.DUMP
.DA CP.JSRX KW.TYPE
.DA CP.JSRX KW.COUNT
.DA CP.JSRX KW.TERMINAL
.DA CP.JSRX KW.KEY
.DA CP.JSRX KW.EMIT
.DA CP.JSRX KW.EXPECT
.DA CP.JSRX KW.WORD
.DA CP.JSRX KW.NUMBER
.DA CP.JSRX KW.STARTSTR
.DA CP.JSRX KW.STRADD
.DA CP.JSRX KW.STRDBL
.DA CP.JSRX KW.SIGN
.DA CP.JSRX KW.ENDSTR
.DA CP.JSRX KW.HOLD
.DA CP.JSRX KW.DECIMAL
.DA CP.JSRX KW.HEX
.DA CP.JSRX KW.OCTAL
.DA CP.JSRX KW.FETCHSP
.DA CP.JSRX KW.FETCHW
.DA CP.JSRX KW.STOREW
.DA CP.JSRX KW.FETCHB
.DA CP.JSRX KW.STOREB
.DA CP.JSRX KW.FETCHPRINTW
.DA CP.JSRX KW.ADDTOW
.DA CP.JSRX KW.CMOVE
.DA CP.JSRX KW.FILL
.DA CP.JSRX KW.ERASE
.DA CP.JSRX KW.BLANKS
.DA CP.JSRX KW.HERE
.DA CP.JSRX KW.PAD
.DA CP.JSRX KW.ALLOT
.DA CP.JSRX KW.nCOMPILE
.DA CP.JSRX KW.QUOTE
.DA CP.JSRX KW.FORGET
.DA CP.JSRX KW.DEFINITIONS
.DA CP.JSRX KW.VOCABULARY
.DA CP.JSRX KW.FORTH
.DA CP.JSRX KW.EDITOR
.DA CP.JSRX KW.ASSEMBLER
.DA CP.INVALID KW.VLIST
.DA CP.JSRX KW.VARIABLE
.DA CP.JSRX KW.CONSTANT
.DA CP.INVALID KW.BCOLON
.DA CP.ECOLON
.DA CP.INVALID KW.ACODE
.DA CP.INVALID KW.FCODE
2020-11-26 19:47:57 +00:00
.DA CP.DO
.DA CP.LOOP
.DA CP.pLOOP
.DA CP.I
.DA CP.LEAVE
.DA CP.IF
.DA CP.ELSE
2021-04-29 11:56:34 +00:00
.DA CP.THEN
2020-11-26 19:47:57 +00:00
.DA CP.BEGIN
.DA CP.UNTIL
.DA CP.REPEAT
.DA CP.WHILE
2021-04-30 15:25:19 +00:00
.DA CP.JSRX KW.gR
.DA CP.JSRX KW.Rg
.DA CP.JSRX KW.R
2020-11-19 15:34:02 +00:00
.DA 0
*--------------------------------------
CS.INIT clc
CS.INIT.RTS rts
*--------------------------------------
CS.RUN >PUSHW L.MSG.GREETINGS
>PUSHW A2osX.KVER
>PUSHBI 2
>SYSCALL PrintF
2020-11-29 13:16:39 +00:00
2020-11-19 15:34:02 +00:00
bcs CS.INIT.RTS
jsr CS.RUN.ARGS
bcs CS.INIT.RTS
2020-11-26 19:47:57 +00:00
2020-11-23 22:05:27 +00:00
>LDYAI CODE.SIZE
2020-11-19 15:34:02 +00:00
>SYSCALL GetMem
bcs CS.INIT.RTS
2020-11-23 22:05:27 +00:00
>STYA ZPCodePtr
>STYA.G CodeBuf
2020-11-19 15:34:02 +00:00
txa
2020-11-23 22:05:27 +00:00
>STA.G hCodeBuf
2020-11-26 19:47:57 +00:00
2020-11-23 22:05:27 +00:00
>LDYAI DATA.SIZE
2020-11-19 15:34:02 +00:00
>SYSCALL GetMem
2020-11-23 22:05:27 +00:00
.9 bcs CS.INIT.RTS
2020-11-19 15:34:02 +00:00
2020-11-23 22:05:27 +00:00
>STYA ZPDataPtr
>STYA.G DataBuf
2020-11-19 15:34:02 +00:00
txa
2020-11-23 22:05:27 +00:00
>STA.G hDataBuf
>LDYAI INPUT.SIZE
2020-11-19 15:34:02 +00:00
>SYSCALL GetMem
2020-11-23 22:05:27 +00:00
bcs .9
2020-12-02 15:22:57 +00:00
>STYA ZPInputBufPtr
2020-11-23 22:05:27 +00:00
txa
>STA.G hInputBuf
>LDYAI OUTPUT.SIZE
>SYSCALL GetMem
bcs .9
2020-11-19 15:34:02 +00:00
2020-12-02 15:22:57 +00:00
>STYA ZPOutputBufPtr
2020-11-19 15:34:02 +00:00
txa
2020-11-23 22:05:27 +00:00
>STA.G hOutputBuf
>LDYAI CL.SIZE
>SYSCALL GetMem
bcs .9
>STYA ZPCLBuf
txa
>STA.G hCLBuf
2020-11-26 19:47:57 +00:00
lda #SL..+SL._
2020-11-19 15:34:02 +00:00
>SYSCALL SListNew
2020-11-23 22:05:27 +00:00
bcs .9
2020-11-26 19:47:57 +00:00
2020-11-19 15:34:02 +00:00
>STA.G hSList
2020-11-26 19:47:57 +00:00
2021-04-11 19:47:48 +00:00
* stz bCompile
2020-11-23 22:05:27 +00:00
lda #127
sta RP
2020-12-17 20:23:54 +00:00
2021-04-11 19:47:48 +00:00
jsr HIS.Init
2020-12-15 13:23:22 +00:00
jsr GFX.Open
2020-11-29 13:16:39 +00:00
*--------------------------------------
2020-11-23 22:05:27 +00:00
CS.RUN.LOOP >SLEEP
2020-11-19 15:34:02 +00:00
>LDA.G bDebug
bpl .2
jsr PrintDebugMsg
2020-11-29 13:16:39 +00:00
.2 jsr CS.FORTH.Run
bcs .7
2020-12-17 20:23:54 +00:00
2020-11-29 13:16:39 +00:00
>LDA.G hFile
bne CS.RUN.LOOP
2020-12-17 20:23:54 +00:00
2020-11-29 13:16:39 +00:00
>PUSHW L.MSG.OK
>PUSHBI 0
>SYSCALL PrintF
bcs .99
2020-12-17 20:23:54 +00:00
2020-11-29 13:16:39 +00:00
bra CS.RUN.LOOP
2020-11-19 15:34:02 +00:00
2020-11-29 13:16:39 +00:00
.7 cmp #MLI.E.EOF
2020-11-19 15:34:02 +00:00
beq .8
2020-11-26 19:47:57 +00:00
cmp #24 Ctrl-X
beq .8
2020-11-19 15:34:02 +00:00
pha
2020-11-29 13:16:39 +00:00
>LDA.G hFile
beq .71
2020-12-17 20:23:54 +00:00
2020-11-29 13:16:39 +00:00
>LDA.G bTrace
bmi .70
jsr PrintTraceMsg
2020-12-17 20:23:54 +00:00
2020-11-29 13:16:39 +00:00
.70 pla
pha
jsr PrintErrPtr
bra .9
2020-12-17 20:23:54 +00:00
2020-11-29 13:16:39 +00:00
.71 pla
2020-11-26 19:47:57 +00:00
2020-11-19 15:34:02 +00:00
>PUSHA
>PUSHW ZPCLBuf
2021-05-04 17:31:21 +00:00
>SYSCALL GetErrMsg
2020-11-19 15:34:02 +00:00
>LDYA ZPCLBuf
>SYSCALL PutS
2020-11-29 13:16:39 +00:00
bcc CS.RUN.LOOP
2020-11-26 19:47:57 +00:00
2020-11-29 13:16:39 +00:00
pha
2020-11-19 15:34:02 +00:00
.9 pla
2020-11-29 13:16:39 +00:00
sec
.99 rts
2020-11-19 15:34:02 +00:00
.8 lda #0 Exit Code = Success
sec
rts
*--------------------------------------
2020-11-23 22:05:27 +00:00
CS.FORTH.Run jsr CL.Reset
2020-11-19 15:34:02 +00:00
2020-11-23 22:05:27 +00:00
>LDA.G hFile
bne CS.FORTH.Run.File
2020-11-19 15:34:02 +00:00
lda #80
sta CL.MaxCnt
2021-06-05 15:48:54 +00:00
jsr CL.PrintPrompt
2020-11-19 15:34:02 +00:00
bcs .9
2020-11-26 19:47:57 +00:00
2020-11-19 15:34:02 +00:00
.1 >SYSCALL GetChar
2020-11-26 19:47:57 +00:00
bcs .9 I/O error
2020-11-19 15:34:02 +00:00
.2 cmp #24 Ctrl-X
2020-11-19 15:34:02 +00:00
beq .9 CS
jsr CL.CHARIN
bcs .9
2020-11-19 15:34:02 +00:00
bit CL.bReady Something to execute ?
2020-11-26 19:47:57 +00:00
bpl .1
2020-11-19 15:34:02 +00:00
>PUSHW L.MSG.PROMPTCRLF
>PUSHBI 0
>SYSCALL PrintF
2021-04-11 19:47:48 +00:00
jsr HIS.Add
2020-11-19 15:34:02 +00:00
jmp CS.RUN.EXEC
2020-11-26 19:47:57 +00:00
.9 rts
2020-11-23 22:05:27 +00:00
*--------------------------------------
2020-11-19 15:34:02 +00:00
CS.FORTH.Run.File
2020-11-29 13:16:39 +00:00
>INCW.G LineCounter
2020-12-17 20:23:54 +00:00
2020-12-23 14:54:57 +00:00
>PUSHB.G hFile
2020-11-23 22:05:27 +00:00
>PUSHW ZPCLBuf
2020-12-23 14:54:57 +00:00
>PUSHWI 256
2020-12-15 13:23:22 +00:00
>SYSCALL FGetS
2020-11-23 22:05:27 +00:00
bcs .9
2020-11-19 15:34:02 +00:00
2020-11-29 13:16:39 +00:00
>LDA.G bTrace
bpl .1
jsr PrintTraceMsg
.1 lda (ZPCLBuf)
2020-11-23 22:05:27 +00:00
beq .8
2020-11-26 19:47:57 +00:00
cmp #'\'
beq .8
2020-11-23 22:05:27 +00:00
cmp #'#'
2020-11-29 13:16:39 +00:00
bne .2
2020-11-26 19:47:57 +00:00
2020-11-23 22:05:27 +00:00
ldy #1
lda (ZPCLBuf),y
2020-11-29 13:16:39 +00:00
beq .2
2020-11-26 19:47:57 +00:00
2020-11-23 22:05:27 +00:00
cmp #'!'
beq .8
2020-11-26 19:47:57 +00:00
2020-11-29 13:16:39 +00:00
.2 jmp CS.RUN.EXEC
2020-11-19 15:34:02 +00:00
2020-11-23 22:05:27 +00:00
.8 clc
.9 rts
2020-11-19 15:34:02 +00:00
*--------------------------------------
CS.RUN.EXEC lda (ZPCLBufPtr)
2020-11-29 13:16:39 +00:00
beq .8 EOL
jsr IsSpaceOrCR
bcc .1
2020-12-17 20:23:54 +00:00
2020-11-29 13:16:39 +00:00
jsr NextChar
bra CS.RUN.EXEC
2020-11-19 15:34:02 +00:00
.1 jsr KW.Lookup
bcs .2
2020-12-02 15:22:57 +00:00
2020-11-19 15:34:02 +00:00
jsr .7
bcc CS.RUN.EXEC
rts
2020-11-23 22:05:27 +00:00
.2 jsr CS.RUN.GetSymbol
bcs .5
2020-11-26 19:47:57 +00:00
2020-11-23 22:05:27 +00:00
bit ZPType
2020-11-29 13:16:39 +00:00
bmi .4 CODE
2020-11-26 19:47:57 +00:00
2020-12-17 20:23:54 +00:00
bit bCompile
bmi .3
2022-11-02 06:54:30 +00:00
2020-11-29 13:16:39 +00:00
>PUSHW ZPAddrPtr CONSTANT,VARIABLE
bra CS.RUN.EXEC
2020-12-17 20:23:54 +00:00
.3 lda ZPAddrPtr+1 VARIABLE : push addr, CONSTANT : push value
jsr CP.Emit.PUSHBI
lda ZPAddrPtr
jsr CP.Emit.PUSHBI
bra CS.RUN.EXEC
2022-11-02 06:54:30 +00:00
2020-11-23 22:05:27 +00:00
.4 bit bCompile
bmi .40
2020-11-26 19:47:57 +00:00
2020-11-23 22:05:27 +00:00
jsr .80
bcc CS.RUN.EXEC
2020-11-26 19:47:57 +00:00
2020-11-23 22:05:27 +00:00
rts
2020-11-26 19:47:57 +00:00
2020-11-23 22:05:27 +00:00
.40 >LDYA ZPAddrPtr
2020-12-02 15:22:57 +00:00
jsr CP.Emit.JsrYA
2020-11-23 22:05:27 +00:00
bra CS.RUN.EXEC
2020-11-26 19:47:57 +00:00
2020-11-23 22:05:27 +00:00
.5 jsr CS.RUN.GetNum
2020-11-29 13:16:39 +00:00
bcc CS.RUN.EXEC
2020-11-23 22:05:27 +00:00
2020-11-29 13:16:39 +00:00
rts
2020-11-26 19:47:57 +00:00
2020-11-23 22:05:27 +00:00
.8 clc
2021-04-30 15:25:19 +00:00
rts
2020-11-26 19:47:57 +00:00
2020-12-02 15:22:57 +00:00
.7 bit bCompile
bmi .71
2020-11-26 19:47:57 +00:00
2021-04-30 15:25:19 +00:00
.70 jmp (I.KEYWORDS,x) INTERPRET
2020-12-17 20:23:54 +00:00
2021-04-30 15:25:19 +00:00
.71 jmp (C.KEYWORDS,x) COMPILE
2020-11-23 22:05:27 +00:00
2021-04-30 15:25:19 +00:00
.80 jmp (ZPAddrPtr) RUN
2020-11-23 22:05:27 +00:00
*--------------------------------------
2020-11-29 13:16:39 +00:00
CS.RUN.ARGS inc ArgIndex
lda ArgIndex
>SYSCALL ArgV
bcs .8
>STYA ZPPtr1
lda (ZPPtr1)
cmp #'-'
bne .4
ldy #1
lda (ZPPtr1),y
ldx #OptionVars-OptionList-1
.1 cmp OptionList,x
beq .2
dex
bpl .1
bra .90
.2 ldy OptionVars,x
lda #$ff
sta (pData),y
bra CS.RUN.ARGS
.4 >LDA.G hFile
bne .90
>LDYA ZPPtr1
jsr CS.RUN.FOpen
bcs .9
>STA.G hFile
bra CS.RUN.ARGS
.8 clc
.9 rts
.90 >PUSHW L.MSG.USAGE
>PUSHBI 0
>SYSCALL PrintF
lda #E.SYN
sec QUIT Process
rts
*--------------------------------------
2020-11-23 22:05:27 +00:00
CS.RUN.FOpen >PUSHYA
>PUSHBI O.RDONLY
>PUSHBI S.FI.T.TXT
>PUSHWZ Aux type
>SYSCALL FOpen
bcs .9
>STA.G hFile
2020-11-26 19:47:57 +00:00
2021-04-30 15:25:19 +00:00
.9
CS.RUN.FOpen.RTS
rts
2020-11-23 22:05:27 +00:00
*--------------------------------------
CS.RUN.GetSymbol
>PUSHB.G hSList
2020-11-19 15:34:02 +00:00
>PUSHW ZPCLBufPtr
2022-11-02 06:54:30 +00:00
>PUSHWI 0 ScopeID
2020-11-19 15:34:02 +00:00
>SYSCALL SListLookup
2021-04-30 15:25:19 +00:00
bcs CS.RUN.FOpen.RTS
2020-11-26 19:47:57 +00:00
2020-11-19 15:34:02 +00:00
>STYA ZPKeyID
2020-11-26 19:47:57 +00:00
2020-11-23 22:05:27 +00:00
txa
jsr NextKW
2021-04-30 15:25:19 +00:00
CS.RUN.GetSymbolData
2020-11-19 15:34:02 +00:00
>PUSHB.G hSList
>PUSHW ZPKeyID
2020-11-23 22:05:27 +00:00
>PUSHWI ZPType
2020-11-19 15:34:02 +00:00
>PUSHWI 4 4 bytes
>PUSHWZ From Start
>SYSCALL SListGetData
2020-11-26 19:47:57 +00:00
2020-11-19 15:34:02 +00:00
.9 rts
2020-11-23 22:05:27 +00:00
*--------------------------------------
CS.RUN.GetNum >PUSHW ZPCLBufPtr
2020-11-19 15:34:02 +00:00
>PUSHWI ZPCLBufPtr
>PUSHBI 10
>SYSCALL StrToL
bcs .9
2020-11-26 19:47:57 +00:00
2020-12-02 15:22:57 +00:00
bit bCompile
bmi .1
2020-11-19 15:34:02 +00:00
ldy #2
lda (pStack)
sta (pStack),y
2020-11-26 19:47:57 +00:00
2020-11-19 15:34:02 +00:00
inc pStack
2020-11-26 19:47:57 +00:00
2020-11-19 15:34:02 +00:00
lda (pStack)
sta (pStack),y
2020-11-26 19:47:57 +00:00
2020-11-19 15:34:02 +00:00
inc pStack
2020-12-17 20:23:54 +00:00
2020-12-02 15:22:57 +00:00
* clc
.9 rts
2020-11-19 15:34:02 +00:00
2020-12-02 15:22:57 +00:00
.1 lda #$A9 lda #imm
jsr CP.Emit.Byte
ldy #1
lda (pStack),y
jsr CP.Emit.Byte
2020-11-19 15:34:02 +00:00
2020-12-02 15:22:57 +00:00
jsr CP.Emit.PUSHA
2020-12-17 20:23:54 +00:00
2020-12-02 15:22:57 +00:00
lda #$A9 lda #imm
jsr CP.Emit.Byte
lda (pStack)
jsr CP.Emit.Byte
2020-11-23 22:05:27 +00:00
2020-12-02 15:22:57 +00:00
jsr CP.Emit.PUSHA
2020-12-17 20:23:54 +00:00
2020-12-02 15:22:57 +00:00
>RET 4
2020-11-19 15:34:02 +00:00
*--------------------------------------
CS.DOEVENT sec
rts
*--------------------------------------
2020-12-15 13:23:22 +00:00
CS.QUIT jsr GFX.Close
2021-04-11 19:47:48 +00:00
>LDA.G HIS.hBuf
beq .10
2022-11-02 06:54:30 +00:00
2021-04-11 19:47:48 +00:00
>SYSCALL FreeStkObj
.10 >LDA.G hSList
2020-11-19 15:34:02 +00:00
beq .1
>SYSCALL SListFree
2020-11-23 22:05:27 +00:00
.1 >LDA.G hFile
beq .2
2020-11-26 19:47:57 +00:00
2020-11-23 22:05:27 +00:00
>SYSCALL FClose
.2 ldy #hCodeBuf
jsr .7
2020-11-26 19:47:57 +00:00
2020-11-23 22:05:27 +00:00
ldy #hDataBuf
2020-11-19 15:34:02 +00:00
jsr .7
2020-11-26 19:47:57 +00:00
2020-11-23 22:05:27 +00:00
ldy #hInputBuf
jsr .7
ldy #hOutputBuf
2020-11-19 15:34:02 +00:00
jsr .7
ldy #hCLBuf
.7 lda (pData),y
beq .8
2020-11-26 19:47:57 +00:00
2020-11-19 15:34:02 +00:00
>SYSCALL FreeMem
2020-11-26 19:47:57 +00:00
2020-11-19 15:34:02 +00:00
.8 clc
rts
*--------------------------------------
2021-04-15 14:03:04 +00:00
PrintDebugMsg lda pStack+1
ldy pStack
bne .1
2022-11-02 06:54:30 +00:00
2021-04-15 14:03:04 +00:00
inc
2022-11-02 06:54:30 +00:00
2021-04-15 14:03:04 +00:00
.1 pha
2022-11-02 06:54:30 +00:00
2021-04-15 14:03:04 +00:00
>PUSHW L.MSG.DEBUG
2020-11-29 13:16:39 +00:00
>PUSHW ZPCodePtr
>PUSHW ZPDataPtr
2021-04-15 14:03:04 +00:00
pla
>PUSHYA
2020-11-29 13:16:39 +00:00
>PUSHB RP
2021-04-15 14:03:04 +00:00
>PUSHBI 7
2020-11-29 13:16:39 +00:00
>SYSCALL PrintF
2020-12-17 20:23:54 +00:00
2020-11-19 15:34:02 +00:00
rts
*--------------------------------------
2020-11-29 13:16:39 +00:00
PrintTraceMsg ldy #S.PS.hStdErr
2020-11-19 15:34:02 +00:00
lda (pPS),y
2020-11-29 13:16:39 +00:00
>PUSHA
2020-11-26 19:47:57 +00:00
2020-11-29 13:16:39 +00:00
>PUSHW L.MSG.TRACE
2020-11-19 15:34:02 +00:00
2020-11-29 13:16:39 +00:00
>PUSHW.G LineCounter
>PUSHW ZPCLBuf
>PUSHBI 4
>SYSCALL FPrintF
2020-11-26 19:47:57 +00:00
2020-11-29 13:16:39 +00:00
rts
*--------------------------------------
PrintErrPtr lda ZPCLBufPtr
sec
sbc ZPCLBuf
2020-11-26 19:47:57 +00:00
2020-11-29 13:16:39 +00:00
tax
2020-12-17 20:23:54 +00:00
2020-11-29 13:16:39 +00:00
ldy #0
lda #C.SPACE
2020-12-17 20:23:54 +00:00
2020-11-29 13:16:39 +00:00
.1 sta (ZPCLBuf),y
iny
cpy #7
bne .1
2020-12-17 20:23:54 +00:00
2020-11-29 13:16:39 +00:00
txa
beq .3
2020-12-17 20:23:54 +00:00
2020-11-29 13:16:39 +00:00
lda #'-'
2020-12-17 20:23:54 +00:00
2020-11-29 13:16:39 +00:00
.2 sta (ZPCLBuf),y
iny
dex
bne .2
2020-12-17 20:23:54 +00:00
2020-11-29 13:16:39 +00:00
.3 lda #'^'
sta (ZPCLBuf),y
iny
lda #C.CR
sta (ZPCLBuf),y
iny
lda #C.LF
sta (ZPCLBuf),y
iny
2020-12-17 20:23:54 +00:00
2020-11-29 13:16:39 +00:00
txa
sta (ZPCLBuf),y
2020-12-17 20:23:54 +00:00
2020-11-19 15:34:02 +00:00
ldy #S.PS.hStdErr
lda (pPS),y
>PUSHA
2020-12-17 20:23:54 +00:00
2020-11-29 13:16:39 +00:00
>PUSHW ZPCLBuf
>SYSCALL FPutS
2020-11-19 15:34:02 +00:00
rts
*--------------------------------------
CheckLFAfterCR ldy #S.PS.hStdIn Check for any extra LF
lda (pPS),y
>SYSCALL FEOF
bcs .9
2020-11-26 19:47:57 +00:00
2020-11-19 15:34:02 +00:00
tay
bne .9
>SYSCALL GetChar
2020-11-26 19:47:57 +00:00
2020-11-19 15:34:02 +00:00
.9 rts
*--------------------------------------
IncPtr1 inc ZPPtr1
bne IncPtr1.8
inc ZPPtr1+1
IncPtr1.8 rts
*--------------------------------------
NextKW clc
adc ZPCLBufPtr
sta ZPCLBufPtr
bcc NextCharNB
inc ZPCLBufPtr+1
*--------------------------------------
NextCharNB lda (ZPCLBufPtr)
2020-11-29 13:16:39 +00:00
beq .9
2020-11-26 19:47:57 +00:00
2020-11-19 15:34:02 +00:00
jsr IsSpaceOrCR
2020-11-29 13:16:39 +00:00
bcc .8
2020-11-19 15:34:02 +00:00
2020-11-29 13:16:39 +00:00
jsr NextChar
2020-11-19 15:34:02 +00:00
bra NextCharNB
2020-11-26 19:47:57 +00:00
.8 rts
2020-11-29 13:16:39 +00:00
.9 sec
rts
*--------------------------------------
NextChar inc ZPCLBufPtr
2020-11-19 15:34:02 +00:00
bne .8
2020-11-26 19:47:57 +00:00
2020-11-19 15:34:02 +00:00
inc ZPCLBufPtr+1
2020-11-26 19:47:57 +00:00
2020-11-19 15:34:02 +00:00
.8 rts
*--------------------------------------
ToUpperCase cmp #'a'
bcc .8
cmp #'z'+1
bcs .8
eor #$20
.8 clc exit CC to allow Jmp to
rts
*--------------------------------------
2020-11-29 13:16:39 +00:00
IsSpaceOrCR cmp #C.SPACE CS=TRUE
beq .8
2020-11-19 15:34:02 +00:00
cmp #C.CR
2020-11-29 13:16:39 +00:00
beq .8
2020-11-19 15:34:02 +00:00
2020-11-29 13:16:39 +00:00
clc
2020-12-17 20:23:54 +00:00
2020-11-29 13:16:39 +00:00
.8 rts
2020-11-19 15:34:02 +00:00
*--------------------------------------
CheckStackPop4 lda pStack
2020-12-02 15:22:57 +00:00
beq .9
2020-12-17 20:23:54 +00:00
2020-12-02 15:22:57 +00:00
cmp #$FD
bcs .9
2020-11-19 15:34:02 +00:00
clc
rts
.9 lda #E.STACKERROR
sec
rts
*--------------------------------------
.INB usr/src/bin/forth.s.cl
2021-04-11 19:47:48 +00:00
.INB usr/src/bin/forth.s.his
2020-11-23 22:05:27 +00:00
.INB usr/src/bin/forth.s.cp
2020-11-19 15:34:02 +00:00
.INB usr/src/bin/forth.s.kw
2020-12-15 13:23:22 +00:00
.INB usr/src/bin/forth.s.gfx
2020-11-19 15:34:02 +00:00
*--------------------------------------
CS.END
*--------------------------------------
2020-12-15 13:23:22 +00:00
DEV.GFX .AZ "/dev/gfx"
2022-11-02 06:54:30 +00:00
MSG.GREETINGS .CZ "\e[?7h\r\nA2osX-FORTH %d.%d (FORTH-79)\r\n"
MSG.HIS .CZ "\r\n%3d : %s"
MSG.HISPROMPT .CZ "\r\n\r\n? "
MSG.HISROMPTCLR .CZ "\b \b"
MSG.USAGE .CS "Usage : FORTH <option> file\r\n"
.CS " -D : Debug Mode\r\n"
.CS " -T : Trace On"
MSG.ECHOCRLF .CZ "\r\n"
MSG.DEBUG .CZ "(CODE:%H, DATA=%H, SP=%H, RP=%h)\r\n"
MSG.TRACE .CZ "[%5D]%s\r\n"
MSG.PROMPT .CZ "\e[?7h\r\n> " Enable Line Wrap
MSG.PROMPTCRLF .CZ "\e[?7l\r\n" Disable Line Wrap
MSG.OK .CZ "OK\r\n"
MSG.DUMP2 .CZ "%s %s%D "
MSG.CONST .CZ "Const V="
MSG.VAR .CZ "Var @="
MSG.CODE .CZ "Code @="
FMT.Byte .CZ "%d "
FMT.int16 .CZ "%I "
FMT.uint16 .CZ "%D "
FMT.int32 .CZ "%L "
2020-11-19 15:34:02 +00:00
*--------------------------------------
OptionList .AS "DdTt"
OptionVars .DA #bDebug,#bDebug,#bTrace,#bTrace
*--------------------------------------
EscChars .AS 'DBAC'
EscChars.Cnt .EQ *-EscChars
EscChars.Remap .DA #C.BS,#C.VT,#C.LF,#21
2020-11-19 15:34:02 +00:00
*--------------------------------------
2021-06-05 15:48:54 +00:00
KEYWORDS .AT "TEXT"
.AT "GR"
.AT "PLOT"
2020-12-15 13:23:22 +00:00
.AT "RECT"
*--------------------------------------
.AT "DUP" ( n - n n ) Duplicate top of stack.
2020-11-19 15:34:02 +00:00
.AT "DROP" ( n - ) Discard top of stack.
.AT "SWAP" ( n1 n2 - n2 n1 ) Reverse top two stack items.
.AT "OVER" ( n1 n2 - n1 n2 n1 ) Copy second item to top.
.AT "ROT" ( n1 n2 n3 - n2 n3 n1 ) Rotate third item to top.
2021-04-29 11:56:34 +00:00
.AT "?DUP" ( n - n ? ) Duplicate only if non-zero.
2020-11-19 15:34:02 +00:00
.AT "+" ( n1 n2 - sum ) Add.
.AT "D+" ( d1 d2 - sum ) Add double-precision numbers.
.AT "-" ( n1 n2 - diff ) Subtract (n1-n2).
2021-04-29 11:56:34 +00:00
.AT "D-" ( d1 d2 - diff ) Subtract double-precision numbers.
2020-11-19 15:34:02 +00:00
.AT "*" ( n1 n2 - prod ) Multiply.
.AT "/" ( n1 n2 - quot ) Divide (n1/n2).
.AT "MOD" ( n1 n2 - rem ) Modulo (remainder from division).
.AT "/MOD" ( n1 n2 - rem quot ) Divide, giving remainder and quotient.
2020-11-29 13:16:39 +00:00
.AT "*/MOD" ( n1 n2 n3 - rem quot ) Multiply, then divide (n1*n2/n3), with double-precision intermediate.
.AT "*/" ( n1 n2 n3 - quot ) Like */MOD, but give quotient only.
2020-11-19 15:34:02 +00:00
.AT "MAX" ( n1 n2 - max ) Maximum.
.AT "MIN" ( n1 n2 - min ) Minimum.
.AT "ABS" ( n - absolute ) Absolute value.
.AT "DABS" ( d - absolute ) Absolute value of double-precision number.
2021-04-29 11:56:34 +00:00
.AT "NEGATE" ( n - -n ) Change sign.
.AT "DNEGATE" ( d - -d ) Change sign of double-precision number.
2020-11-19 15:34:02 +00:00
.AT "AND" ( n1 n2 - and ) Logical bitwise AND.
.AT "OR" ( n1 n2 - or ) Logical bitwise OR.
.AT "XOR" ( n1 n2 - xor ) Logical bitwise exclusive OR.
.AT "<" ( n1 n2 - f ) True if n1 less than n2.
.AT ">" ( n1 n2 - f ) True if n1 greater than n2.
.AT "=" ( n1 n2 - f ) True if n1 equal to n2.
.AT "0<" ( n - f ) True if top number negative.
.AT "0=" ( n - f ) True if top number zero.
*--------------------------------------
.AT "." ( n - ) Print number.
2021-04-15 14:03:04 +00:00
.AT "U." ( u - ) Print UNSIGNED number
2020-11-19 15:34:02 +00:00
.AT ".R" ( n u - ) Print number, right-justified in u column.
.AT "D." ( d - ) Print double-precision number.
.AT "D.R" ( d u - ) Print double-precision number in u column.
.AT "CR" ( - ) Do a carriage-return.
.AT "SPACE" ( - ) Type one space.
.AT "SPACES" ( u - ) Type u spaces.
.AT '."' ( - ) Print message (terminated by ").
.AT "DUMP" ( addr u - ) Dump u numbers starting at address.
.AT "TYPE" ( addr u - ) Type u characters starting at address.
.AT "COUNT" ( addr - addr+1 u ) Change length byte string to TYPE form.
.AT "?TERMINAL" ( - f ) True if terminal break request present.
.AT "KEY" ( - c ) Read key, put ASCII value on stack.
.AT "EMIT" ( c - ) Type ASCII character from stack.
.AT "EXPECT" ( addr u - ) Read u characters (or until carriage-return) from input device to address.
.AT "WORD" ( c - ) Read one word from input stream, delimited by c.
.AT "NUMBER" ( addr - d ) Convert string at address to double number.
.AT "<#" ( - ) Start output string.
.AT "#" ( d1 - d2 ) Convert one digit of double number and add character to output string.
.AT "#S" ( d - 0 0 ) Convert all significant digits of double number to output string.
.AT "SIGN" ( n d - d ) Insert sign of n to output string.
.AT "#>" ( d - addr u ) Terminate output string for TYPE.
.AT "HOLD" ( c - ) Insert ASCII character into output string.
.AT "DECIMAL" ( - ) Set decimal base.
.AT "HEX" ( - ) Set hexadecimal base.
.AT "OCTAL" ( - ) Set octal base.
*--------------------------------------
2021-04-15 14:03:04 +00:00
.AT "SP@" ( - addr ) Return the address of the top of the stack, just before SP@ was executed
2020-11-19 15:34:02 +00:00
.AT "@" ( addr - n ) Replace word address by contents.
.AT "!" ( n addr - ) Store second word at address on top.
.AT "C@" ( addr - b ) Fetch one byte only.
.AT "C!" ( b addr - ) Store one byte only.
.AT "?" ( addr - ) Print contents of address.
.AT "+!" ( n addr - ) Add second number to contents of address.
.AT "CMOVE" ( from to u - ) Move u bytes in memory.
.AT "FILL" ( addr u b - ) Fill u bytes in memory with b beginning at address.
.AT "ERASE" ( addr u - ) Fill u bytes in memory with zeros.
.AT "BLANKS" ( addr u - ) Fill u bytes in memory with blanks.
.AT "HERE" ( - addr ) Return address above dictionary.
.AT "PAD" ( - addr ) Return address of scratch area.
.AT "ALLOT" ( u - ) Leave a gap of n bytes in the dictionary.
.AT "," ( n - ) Compile number n into the dictionary.
.AT "'" ( - addr ) Find address of next string in dictionary.
.AT "FORGET" ( - ) Delete all definitions above and including the following definition.
.AT "DEFINITIONS" ( - ) Set current vocabulary to context vocabulary.
.AT "VOCABULARY" ( - ) Create new vocabulary.
.AT "FORTH" ( - ) Set context vocabulary to Forth vocabulary.
.AT "EDITOR" ( - ) Set context vocabulary to Editor vocabulary.
.AT "ASSEMBLER" ( - ) Set context vocabulary to Assembler.
.AT "VLIST" ( - ) Print names in context vocabulary.
2020-11-29 13:16:39 +00:00
.AT "VARIABLE" ( n - ) Create a variable with initial value n.
.AT "CONSTANT" ( n - ) Create a constant with value n.
2020-11-19 15:34:02 +00:00
*--------------------------------------
.AT ":" ( - ) Begin a colon definition.
.AT ";" ( - ) End of a colon definition.
.AT "CODE" ( - ) Create assembly-language definition.
.AT ";CODE" ( - ) Create a new defining word, with runtime code routine in high-level Forth.
.AT "DO" ( end+1 start - ) Set up loop, given index range.
.AT "LOOP" ( - ) Increment index, terminate loop if equal to limit.
.AT "+LOOP" ( n - ) Increment index by n. Terminate loop if outside limit.
.AT "I" ( - index ) Place loop index on stack.
.AT "LEAVE" ( - ) Terminate loop at next LOOP or +LOOP.
.AT "IF" ( f - ) If top of stack is true, execute true clause.
.AT "ELSE" ( - ) Beginning of the false clause.
2021-04-29 11:56:34 +00:00
.AT "THEN" ( - ) End of the IF-ELSE structure.
2020-11-19 15:34:02 +00:00
.AT "BEGIN" ( - ) Start an indefinite loop.
.AT "UNTIL" ( f - ) Loop back to BEGIN until f is true.
.AT "REPEAT" ( - ) Loop back to BEGIN unconditionally.
.AT "WHILE" ( f - ) Exit loop immediately if f is false.
2021-04-29 11:56:34 +00:00
.AT ">R" ( n - ) Move top item to return stack.
.AT "R>" ( - n ) Retrieve item from return stack.
.AT "R" ( - n ) Copy top of return stack onto stack.
2020-11-19 15:34:02 +00:00
*--------------------------------------
.DA #0
2020-12-02 15:22:57 +00:00
*--------------------------------------
CODE.RPDROP2 inc RP
inc RP
CODE.RPDROP2.L .EQ *-CODE.RPDROP2
*--------------------------------------
CODE.TESTTRUE >PULLA
tax
2021-05-19 12:44:47 +00:00
.1 bmi .1+5
2020-12-02 15:22:57 +00:00
CODE.TESTTRUE.L .EQ *-CODE.TESTTRUE
*--------------------------------------
CODE.TESTFALSE >PULLA
tax
2021-05-19 12:44:47 +00:00
.1 bpl .1+5
2020-12-02 15:22:57 +00:00
CODE.TESTFALSE.L .EQ *-CODE.TESTFALSE
*--------------------------------------
CODE.PULLA >PULLA
CODE.PULLA.L .EQ *-CODE.PULLA
*--------------------------------------
CODE.PUSHA >PUSHA
CODE.PUSHA.L .EQ *-CODE.PUSHA
*--------------------------------------
2020-12-17 20:23:54 +00:00
CODE.DO lda RP
sec
sbc #4
sta RP
tay
2022-11-02 06:54:30 +00:00
2020-12-17 20:23:54 +00:00
ldx #4
2022-11-02 06:54:30 +00:00
2020-12-17 20:23:54 +00:00
.1 >PULLA
iny
2020-12-23 14:54:57 +00:00
sta (pData),y
2020-12-17 20:23:54 +00:00
dex
bne .1
CODE.DO.L .EQ *-CODE.DO
*--------------------------------------
2020-12-23 14:54:57 +00:00
CODE.DOTEST ldy RP
iny
2022-11-02 06:54:30 +00:00
2020-12-23 14:54:57 +00:00
lda (pData),y I LO
iny
iny
cmp (pData),y END LO
2022-11-02 06:54:30 +00:00
2020-12-23 14:54:57 +00:00
dey
2022-11-02 06:54:30 +00:00
2020-12-23 14:54:57 +00:00
lda (pData),y I HI
iny
iny
sbc (pData),y END HI
.1 bcc .1+5 Skip JMP LOOPEND
CODE.DOTEST.L .EQ *-CODE.DOTEST
*--------------------------------------
2020-12-17 20:23:54 +00:00
CODE.LOOP >PULLA
ldy RP
2020-12-23 14:54:57 +00:00
iny
2022-11-02 06:54:30 +00:00
2020-12-17 20:23:54 +00:00
clc
adc (pData),y
sta (pData),y
2020-12-02 15:22:57 +00:00
2020-12-17 20:23:54 +00:00
>PULLA
iny
adc (pData),y
sta (pData),y
2020-12-02 15:22:57 +00:00
CODE.LOOP.L .EQ *-CODE.LOOP
*--------------------------------------
2020-12-17 20:23:54 +00:00
CODE.LOOPEND lda RP POP 4 bytes
2020-12-02 15:22:57 +00:00
clc
adc #4
2020-12-17 20:23:54 +00:00
sta RP
2020-12-02 15:22:57 +00:00
CODE.LOOPEND.L .EQ *-CODE.LOOPEND
2020-12-17 20:23:54 +00:00
*--------------------------------------
CODE.I ldy RP
2020-12-23 14:54:57 +00:00
iny
2020-12-17 20:23:54 +00:00
iny
lda (pData),y
>PUSHA
dey
lda (pData),y
>PUSHA
CODE.I.L .EQ *-CODE.I
*--------------------------------------
CODE.LEAVE ldy RP
iny
2020-12-23 14:54:57 +00:00
iny skip I
2020-12-17 20:23:54 +00:00
iny
2020-12-23 14:54:57 +00:00
lda (pData),y get end LO
2020-12-17 20:23:54 +00:00
tax
2020-12-23 14:54:57 +00:00
2020-12-17 20:23:54 +00:00
iny
2020-12-23 14:54:57 +00:00
lda (pData),y get end HI
2020-12-17 20:23:54 +00:00
dey
dey
2020-12-23 14:54:57 +00:00
sta (pData),y I HI
2020-12-17 20:23:54 +00:00
txa
dey
2020-12-23 14:54:57 +00:00
sta (pData),y I LO
2020-12-17 20:23:54 +00:00
CODE.LEAVE.L .EQ *-CODE.LEAVE
2020-11-19 15:34:02 +00:00
*--------------------------------------
.DUMMY
.OR 0
2020-11-26 19:47:57 +00:00
DS.START .BS 128 RETURN STACK
2020-11-23 22:05:27 +00:00
2020-11-19 15:34:02 +00:00
bDebug .BS 1
bTrace .BS 1
bExitOnEOF .BS 1
2020-11-23 22:05:27 +00:00
hCodeBuf .BS 1
CodeBuf .BS 2
hDataBuf .BS 1
DataBuf .BS 2
hInputBuf .BS 1
hOutputBuf .BS 1
2020-11-19 15:34:02 +00:00
hCLBuf .BS 1
2021-04-11 19:47:48 +00:00
HIS.hBuf .BS 1
HIS.Count .BS 1
HIS.Index .BS 1
2021-06-05 15:48:54 +00:00
HIS.LRU .BS 1
2021-04-11 19:47:48 +00:00
2020-11-23 22:05:27 +00:00
hFile .BS 1
2020-11-29 13:16:39 +00:00
LineCounter .BS 2
2020-11-19 15:34:02 +00:00
hSList .BS 1
2020-12-15 13:23:22 +00:00
hDevGFX .BS 1
2020-11-19 15:34:02 +00:00
DS.END .ED
*--------------------------------------
MAN
SAVE usr/src/bin/forth.s
ASM