Kernel 0.94+

This commit is contained in:
Rémy GIBERT 2021-04-11 21:47:48 +02:00
parent ee7a7b07a4
commit 2e4c5e3eb6
10 changed files with 171 additions and 86 deletions

Binary file not shown.

View File

@ -194,16 +194,7 @@ CORE.Lookup >STYA ZPPtr1
.8 tya Keyword Len
clc
adc ZPInputBufPtr
sta ZPInputBufPtr
bcc .80
clc
inc ZPInputBufPtr+1
.80 rts
jmp CORE.SkipA
.3 dey
lda (ZPPtr1),y was last char in this keyword ?
@ -246,7 +237,7 @@ CORE.CreateLabel
>PUSHB.G hLabels
>PUSHW ZPSID
>PUSHWI ZPCodeBufPtr
>PUSHWI 2
>PUSHWI 2 2 bytes : ADDR
>SYSCALL SListAddData
.9 rts
*--------------------------------------
@ -258,11 +249,18 @@ CORE.CreateOrGetVar
>LDA.G hVars
jsr CORE.NewKey
bcs .9
jsr CORE.GetChar
cmp #'$'
bne .1
sta ZPTYPE
jsr CORE.GetNextChar skip $
>PUSHB.G hVars
.1 >PUSHB.G hVars
>PUSHW ZPSID
>PUSHWI ZPDataBufPtr
>PUSHWI 2
>PUSHWI 3 3 bytes : ADDR + TYPE
>SYSCALL SListAddData
bcs .9
@ -284,21 +282,12 @@ CORE.CreateOrGetVar
CORE.NewKey >PUSHA
>PUSHW ZPInputBufPtr
>SYSCALL SListNewKey
bcs .9
bcs CORE.GetAddr.RTS
>STYA ZPSID
txa
* clc
adc ZPInputBufPtr
sta ZPInputBufPtr
bcc .1
clc
inc ZPInputBufPtr+1
.1
.9 rts
jmp CORE.SkipA
*--------------------------------------
CORE.GetAddr >PUSHA
>PUSHA for SListGetData
@ -310,21 +299,17 @@ CORE.GetAddr >PUSHA
>STYA ZPSID
txa
* clc
adc ZPInputBufPtr
sta ZPInputBufPtr
bcc .1
inc ZPInputBufPtr+1
jsr CORE.SkipA
.1 >PUSHW ZPSID
>PUSHWI ZPADDR
>PUSHWI 2 2 bytes
>PUSHWI 3 3 bytes : ADDR + TYPE
>PUSHWZ From Start
>SYSCALL SListGetData
rts
.9 >PULLA
.9 >POP 1
CORE.GetAddr.RTS
rts
*--------------------------------------
CORE.ToUpperCase
@ -441,6 +426,16 @@ CORE.GetNextCharNB
CORE.GetNextCharNB.RTS
rts
*--------------------------------------
CORE.SkipA clc
adc ZPInputBufPtr
sta ZPInputBufPtr
bcc .1
clc
inc ZPInputBufPtr+1
.1 rts Exit with CC for JMP to
*--------------------------------------
CORE.SkipLine jsr CORE.GetNextChar
bcs CORE.GetNextCharNB.RTS

View File

@ -157,15 +157,10 @@ EXP.VARLookup >LDA.G hVars
>PUSHYA ZPSID
txa
* clc
adc ZPInputBufPtr
sta ZPInputBufPtr
bcc .1
inc ZPInputBufPtr+1
jsr CORE.SkipA
.1 >PUSHWI EXP.ADDR
>PUSHWI 2 2 bytes
>PUSHWI 3 3 bytes : ADDR + TYPE
>PUSHWZ From Start
>SYSCALL SListGetData
rts

View File

@ -21,10 +21,11 @@ EXP.DEPTH.MAX .EQ 16
.OR ZPBIN
ZS.START
ZPInputBuf .BS 2
ZPInputBufPtr .BS 2
ZPSID .BS 2
ZPADDR .BS 2
ZPTYPE .BS 1
.BS 1
ZPPtr1 .BS 2
ZPPtr2 .BS 2
@ -39,8 +40,9 @@ ArgIndex .BS 1
bFlag .BS 1
EXP.ADDR .BS 2
EXP.TYPE .BS 1
EXP.AOPS .BS 1
EXP.DEPTH .BS 1
*EXP.DEPTH .BS 1
ZS.END .ED
*--------------------------------------
@ -259,7 +261,6 @@ CS.RUN.ARGS inc ArgIndex
jsr CS.RUN.LoadFile
bcs .9
>STYA ZPInputBuf
>STYA ZPInputBufPtr
txa

View File

@ -511,7 +511,7 @@ MSG.HELP >PSTR "All commands:"
>PSTR " Ctrl-R : Replace next"
>PSTR " Ctrl-S : Save file..."
>PSTR " Ctrl-T : Go to top of file"
>PSTR " Ctrl-V : Past clipboard at cursor position"
>PSTR " Ctrl-V : Paste clipboard at cursor position"
>PSTR " Ctrl-W : Erase current line"
>PSTR " Ctrl-X : Cut block to clipboard"
>PSTR " Ctrl-Y : Go to end of file"

View File

@ -257,10 +257,6 @@ CL.PrintCLBuf ldy #S.PS.hStdOut
>SYSCALL FPutS
rts
*--------------------------------------
CL.DN
CL.UP clc
rts
*--------------------------------------
MAN
SAVE usr/src/bin/forth.s.cl
LOAD usr/src/bin/forth.s

View File

@ -14,7 +14,7 @@ CP.RUN cpx #KW.CONLY
.1 jmp (J.KEYWORDS,x)
*--------------------------------------
CP.DO jsr CP.Emit.DO I,n -> RP
* >DEBUG
ldy RP
lda ZPCodePtr+1
@ -42,7 +42,6 @@ CP.LOOP lda #$00
jsr CP.Emit.PUSHBI
*--------------------------------------
CP.pLOOP ldy RP
* >DEBUG
iny
bmi .9
@ -82,7 +81,7 @@ CP.I jsr CP.Emit.I
rts
*--------------------------------------
CP.LEAVE ldy RP
* >DEBUG
.1 iny
bmi .9

93
BIN/FORTH.S.HIS.txt Normal file
View File

@ -0,0 +1,93 @@
NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
HIS.Init >LDYAI HISTORY.MAX Get a buffer for History
>SYSCALL NewStkObj
bcs .9
txa
>STA.G HIS.hBuf
>PUSHA
>PUSHWI 0
>SYSCALL StrVAdd Reset Buffer
>STZ.G HIS.Count
>STA.G HIS.Index
.9 rts
*--------------------------------------
HIS.Add >LDA.G HIS.hBuf
beq .9
>PUSHA
>PUSHW ZPCLBuf
>SYSCALL StrVAdd
bcc .1
>PUSHB.G HIS.hBuf
lda #0
>PUSHA
>SYSCALL StrVShift
>DEC.G HIS.Count
bra HIS.Add
.1 >STZ.G HIS.Index Reset Index
>INC.G HIS.Count
.9
HIS.Add.RTS rts
*--------------------------------------
HIS.GetPrev >LDA.G HIS.hBuf
beq HIS.Add.RTS
>LDA.G HIS.Count
beq HIS.Add.RTS empty history,nothing to do
>LDA.G HIS.Index
bne .1
>LDA.G HIS.Count
.1 dec
bra HIS.GetToCl
*--------------------------------------
HIS.GetNext >LDA.G HIS.hBuf
beq HIS.Add.RTS
>LDA.G HIS.Count
beq HIS.Add.RTS empty history,nothing to do
>LDA.G HIS.Index
inc
>CMP.G HIS.Count
bne HIS.GetToCl
lda #0
>STA.G HIS.Index
jmp CL.CLR
*--------------------------------------
HIS.GetToCl >STA.G HIS.Index
jsr CL.CLR
>PUSHB.G HIS.hBuf
>PUSHB.G HIS.Index
>PUSHW ZPCLBuf
>SYSCALL StrVGet
ldy #$ff
.1 iny
lda (ZPCLBuf),y
bne .1
tya
>STA.G CL.Ptr
>STA.G CL.Len
jmp CL.PrintCLBuf
*--------------------------------------
MAN
SAVE usr/src/bin/forth.s.his
LOAD usr/src/bin/forth.s
ASM

View File

@ -579,11 +579,12 @@ KW.LWR jsr CheckStackPop4
sbc (pStack)
inc pStack
ror
inc pStack
lda #0
ror
sta (pStack)
ldy #1
sta (pStack),y
clc
.9 rts
@ -600,30 +601,33 @@ KW.GTR jsr CheckStackPop4
sbc (pStack)
inc pStack
inc pStack
lda #0
ror
eor #$80
sta (pStack)
ldy #1
sta (pStack),y
clc
.9 rts
*--------------------------------------
* : TL BEGIN DUP . 1 - DUP 0 = UNTIL ;
*--------------------------------------
KW.EQ jsr CheckStackPop4
bcs .9
* clc
ldy #2
lda (pStack),y
sec
sbc (pStack)
eor (pStack)
tax
inc pStack
lda (pStack),y
sbc (pStack)
eor (pStack)
inc pStack
@ -634,32 +638,20 @@ KW.EQ jsr CheckStackPop4
bne .1
sec
.HS 90 BCC
.1 clc
lda #0
sbc #0
.1 inc pStack
sta (pStack)
ldy #1
sta (pStack),y
clc
.9 rts
*--------------------------------------
KW.NEGATIVE ldy #1
lda (pStack),y
asl
lda #0
ror
sta (pStack)
sta (pStack),y
KW.NEGATIVE inc pStack
clc
rts
*--------------------------------------
KW.ZERO clc
ldy #1
lda (pStack),y
ora (pStack)
@ -669,10 +661,11 @@ KW.ZERO clc
.9 lda #0
ror
sta (pStack)
sta (pStack),y
clc
inc pStack
sta (pStack)
* clc
rts
*--------------------------------------
KW.. jsr KW.DUP

View File

@ -4,6 +4,8 @@ NEW
.OP 65C02
.OR $2000
.TF bin/forth
*--------------------------------------
HISTORY.MAX .EQ 256
*--------------------------------------
.INB inc/macros.i
.INB inc/a2osx.i
@ -91,10 +93,8 @@ L.MSG.TYPES .DA MSG.CONST
L.FMT.Byte .DA FMT.Byte
L.FMT.int16 .DA FMT.int16
J.ESC .DA CL.BS left arrow
.DA CL.DN
.DA CL.UP
* .DA HIS.GetNext
* .DA HIS.GetPrev
.DA HIS.GetNext
.DA HIS.GetPrev
.DA CL.NAK right arrow
L.KEYWORDS .DA KEYWORDS
J.KEYWORDS .DA GFX.PLOT
@ -266,10 +266,12 @@ CS.RUN >PUSHW L.MSG.GREETINGS
>STA.G hSList
stz bCompile
* stz bCompile
lda #127
sta RP
jsr HIS.Init
jsr GFX.Open
*--------------------------------------
CS.RUN.LOOP >SLEEP
@ -357,6 +359,8 @@ CS.FORTH.Run jsr CL.Reset
>PUSHBI 0
>SYSCALL PrintF
jsr HIS.Add
jmp CS.RUN.EXEC
.9 rts
@ -596,7 +600,12 @@ CS.DOEVENT sec
*--------------------------------------
CS.QUIT jsr GFX.Close
>LDA.G hSList
>LDA.G HIS.hBuf
beq .10
>SYSCALL FreeStkObj
.10 >LDA.G hSList
beq .1
>PUSHA
@ -783,6 +792,7 @@ CheckStackPop4 lda pStack
rts
*--------------------------------------
.INB usr/src/bin/forth.s.cl
.INB usr/src/bin/forth.s.his
.INB usr/src/bin/forth.s.cp
.INB usr/src/bin/forth.s.kw
.INB usr/src/bin/forth.s.gfx
@ -926,13 +936,11 @@ CODE.RPDROP2 inc RP
CODE.RPDROP2.L .EQ *-CODE.RPDROP2
*--------------------------------------
CODE.TESTTRUE >PULLA
>PULLA
tax
.1 bpl .1+5
CODE.TESTTRUE.L .EQ *-CODE.TESTTRUE
*--------------------------------------
CODE.TESTFALSE >PULLA
>PULLA
tax
.1 bmi .1+5
CODE.TESTFALSE.L .EQ *-CODE.TESTFALSE
@ -1047,6 +1055,11 @@ hInputBuf .BS 1
hOutputBuf .BS 1
hCLBuf .BS 1
HIS.hBuf .BS 1
HIS.Count .BS 1
HIS.Index .BS 1
hFile .BS 1
LineCounter .BS 2
hSList .BS 1