diff --git a/.Docs/Forth Words.md b/.Docs/Forth Words.md index 326727f6..fcb98254 100644 --- a/.Docs/Forth Words.md +++ b/.Docs/Forth Words.md @@ -147,7 +147,7 @@ The definitions are listed in ASCII alphabetical order in several groups con | EXIT | | C | | When compiled within a colon-definition, terminate execution of that definition, at that point. May not be used within a DO...LOOP. | | | EXPECT | addr n -- | | | Transfer characters from the terminal beginning at addr, upward, until a "return" or the count of n has been received. Take no action for n less than or equal to zero. One or two nulls are added at the end of text. | | | FILL | addr n byte -- | I,C | Working | Fill memory starting at addr with n copies of byte | | -| FIND | -- addr ||| Leave the compilation address of the next word name, which is accepted from the input stream. If that word cannot be found in the dictionary after a search of CONTEXT and FORTH leave zero. | | +| FIND | -- addr | | | Leave the compilation address of the next word name, which is accepted from the input stream. If that word cannot be found in the dictionary after a search of CONTEXT and FORTH leave zero. | | | FORGET | -- | | | Execute in the form:
FORGET **name**
Delete from the dictionary **name** (which is in the CURRENT vocabulary) and all words added to the dictionary after **name**, regardless of their vocabulary. Failure to find **name** in CURRENT or FORTH is an error condition. | | | FORTH | -- | I | | The name of the primary vocabulary. Execution makes FORTH the CONTEXT vocabulary. New definitions become a part of the FORTH until a differing CURRENT vocabulary is established. User vocabularies conclude by 'chaining' to FORTH, so it should be considered that FORTH is 'contained' within each user's vocabulary.y | | | HERE | -- addr | | Working | Return address of next available dictionary location.| | diff --git a/.Floppies/A2OSX.BUILD.po b/.Floppies/A2OSX.BUILD.po index 98a532b4..d3eb80d5 100644 Binary files a/.Floppies/A2OSX.BUILD.po and b/.Floppies/A2OSX.BUILD.po differ diff --git a/.Floppies/A2OSX.TEST.po b/.Floppies/A2OSX.TEST.po index 430491fc..47993a71 100644 Binary files a/.Floppies/A2OSX.TEST.po and b/.Floppies/A2OSX.TEST.po differ diff --git a/BIN/FORTH.S.CL.txt b/BIN/FORTH.S.CL.txt index aba1225b..0fbe3fd6 100644 --- a/BIN/FORTH.S.CL.txt +++ b/BIN/FORTH.S.CL.txt @@ -1,6 +1,11 @@ NEW AUTO 3,1 *-------------------------------------- +CL.PrintPrompt >PUSHW L.MSG.PROMPT + >PUSHBI 0 + >SYSCALL PrintF + rts +*-------------------------------------- CL.READN0A tax CL.READN0X >PUSHW ZPCLBuf >PUSHW L.FMT.Byte @@ -120,7 +125,12 @@ CL.CHARIN.CTRL cpx #C.CR cpx #3 Ctrl-C beq CL.CLR - cpx #26 Ctrl-Z + cpx #C.TAB + bne .1 + + jmp HIS.Select + +.1 cpx #26 Ctrl-Z bne .8 jmp CL.SUPPR @@ -156,7 +166,7 @@ CL.CLR lda (ZPCLBuf) lda (ZPCLBuf),y bne .3 - jsr CL.PrintCLBuf + jsr CL.Print *-------------------------------------- CL.Reset lda #0 sta (ZPCLBuf) @@ -249,7 +259,7 @@ CL.PrintEOL lda CL.Ptr CL.PrintEOL.8 clc rts *-------------------------------------- -CL.PrintCLBuf ldy #S.PS.hStdOut +CL.Print ldy #S.PS.hStdOut lda (pPS),y >PUSHA >PUSHW ZPCLBuf diff --git a/BIN/FORTH.S.GFX.txt b/BIN/FORTH.S.GFX.txt index 1807798d..db67f82d 100644 --- a/BIN/FORTH.S.GFX.txt +++ b/BIN/FORTH.S.GFX.txt @@ -8,17 +8,7 @@ GFX.Open >PUSHW L.DEV.GFX >STA.G hDevGFX - rts - - ldy #S.PS.hStdIn - lda (pPS),y - bit #1 - beq .9 - - >PUSHA - >PUSHBI IOCTL.CONTROL - >PUSHWI 0 - >SYSCALL IOCTL + bra GFX.TEXT .9 rts *-------------------------------------- @@ -29,6 +19,29 @@ GFX.Close >LDA.G hDevGFX .9 rts *-------------------------------------- +GFX.TEXT ldy #S.PS.hStdIn + lda (pPS),y + + bit #1 + bne GFX.IOCTL + +GFX.TEXT.RTS clc + rts +*-------------------------------------- +GFX.GR ldy #S.PS.hStdIn + lda (pPS),y + bit #1 + beq GFX.TEXT.RTS + + >LDA.G hDevGFX + beq GFX.TEXT.RTS + +GFX.IOCTL >PUSHA + >PUSHBI IOCTL.CONTROL + >PUSHWI 0 + >SYSCALL IOCTL + rts +*-------------------------------------- * (Y X C) *-------------------------------------- GFX.PLOT ldx #S.CB.CMD.SETPIXEL diff --git a/BIN/FORTH.S.HIS.txt b/BIN/FORTH.S.HIS.txt index 32f133fd..474219c3 100644 --- a/BIN/FORTH.S.HIS.txt +++ b/BIN/FORTH.S.HIS.txt @@ -2,77 +2,138 @@ NEW AUTO 3,1 .LIST OFF *-------------------------------------- -HIS.Init clc - rts +HIS.Init >LDYAI HISTORY.MAX Get a buffer for History - >LDYAI HISTORY.MAX Get a buffer for History >SYSCALL StrVNew bcs .9 - txa >STA.G HIS.hBuf - >STZ.G HIS.Count - >STA.G HIS.Index +* >STZ.G HIS.Count +* >STA.G HIS.Index +* >STA.G HIS.LRU .9 rts *-------------------------------------- HIS.Add >LDA.G HIS.hBuf beq .9 + >LDA.G HIS.Count + cmp #HIS.MAX + bcc .2 + + >LDA.G HIS.LRU + cmp #HIS.MAX + bne .1 + + lda #0 + +.1 inc + >STA.G HIS.LRU + bra .7 + +.2 inc + >STA.G HIS.Count + +.7 tax + >PUSHB.G HIS.hBuf + >PUSHBI 0 + txa >PUSHA >PUSHW ZPCLBuf >SYSCALL StrVSet - bcc .1 - - >PUSHB.G HIS.hBuf - >PUSHWZ - >SYSCALL StrVSet - >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 + >STZ.G HIS.Index Reset Index +.9 rts +*-------------------------------------- +HIS.Select >LDA.G HIS.Count + bne .10 + + clc +.99 rts + +.10 jsr CL.Reset + + >STZ.G HIS.Index + +.1 >INC.G HIS.Index + jsr HIS.GetIndex + bcs .99 + + >PUSHW L.MSG.HIS + >LDA.G HIS.Index + dec + >PUSHA + >PUSHW ZPCLBuf + >PUSHBI 3 + >SYSCALL PrintF + bcs .9 + + >LDA.G HIS.Index + >CMP.G HIS.Count + bne .1 + + >PUSHW L.MSG.HISPROMPT + >PUSHBI 0 + >SYSCALL PrintF + + >STZ.G HIS.Index + + lda #0 + sta (ZPCLBuf) + + >SYSCALL GetChar + bcs HIS.Select.RTS + + cmp #'0' + bcc .7 + + cmp #'9'+1 + bcs .7 + + and #$f + inc + + >STA.G HIS.Index + +.7 >PUSHW L.MSG.HISROMPTCLR + >PUSHBI 0 + >SYSCALL PrintF + + jsr CL.PrintPrompt + bcc HIS.GetToCL1 +.9 +HIS.Select.RTS rts +*-------------------------------------- +HIS.GetPrev >LDA.G HIS.Count + beq HIS.Select.RTS empty history,nothing to do >LDA.G HIS.Index bne .1 >LDA.G HIS.Count + bra HIS.GetToCL + .1 dec bra HIS.GetToCl *-------------------------------------- -HIS.GetNext >LDA.G HIS.hBuf - beq HIS.Add.RTS +HIS.GetNext >LDA.G HIS.Count + beq HIS.Select.RTS empty history,nothing to do - >LDA.G HIS.Count - beq HIS.Add.RTS empty history,nothing to do + >EOR.G HIS.Index + beq HIS.GetToCL >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 - >PUSHBI 0 - >PUSHB.G HIS.Index - >PUSHW ZPCLBuf +HIS.GetToCL1 >LDA.G HIS.Index + beq .9 - >SYSCALL StrVGet + jsr HIS.GetIndex + bcs .9 ldy #$ff @@ -84,7 +145,16 @@ HIS.GetToCl >STA.G HIS.Index sta CL.Ptr sta CL.Len - jmp CL.PrintCLBuf + jmp CL.Print + +.9 rts +*-------------------------------------- +HIS.GetIndex >PUSHB.G HIS.hBuf + >PUSHBI 0 + >PUSHB.G HIS.Index + >PUSHW ZPCLBuf + >SYSCALL StrVGet + rts *-------------------------------------- MAN SAVE usr/src/bin/forth.s.his diff --git a/BIN/FORTH.S.KW.txt b/BIN/FORTH.S.KW.txt index 0cb69a2e..610e8355 100644 --- a/BIN/FORTH.S.KW.txt +++ b/BIN/FORTH.S.KW.txt @@ -463,7 +463,7 @@ KW.AND jsr CheckStackPop4 sta (pStack),y inc pStack - clc +* clc .9 rts *-------------------------------------- @@ -481,7 +481,7 @@ KW.OR jsr CheckStackPop4 sta (pStack),y inc pStack - clc +* clc .9 rts *-------------------------------------- @@ -499,7 +499,7 @@ KW.XOR jsr CheckStackPop4 sta (pStack),y inc pStack - clc +* clc .9 rts *-------------------------------------- @@ -519,9 +519,11 @@ KW.LWR jsr CheckStackPop4 lda #0 ror + eor #$80 + sta (pStack) - clc +* clc .9 rts *-------------------------------------- @@ -541,10 +543,10 @@ KW.GTR jsr CheckStackPop4 lda #0 ror - eor #$80 + sta (pStack) - clc +* clc .9 rts *-------------------------------------- @@ -558,27 +560,26 @@ KW.EQ jsr CheckStackPop4 ldy #2 lda (pStack),y eor (pStack) - tax inc pStack + tax + bne .1 lda (pStack),y eor (pStack) - - inc pStack - - tay bne .1 - - txa - bne .1 - + sec -.1 inc pStack +.1 lda #0 + ror + + inc pStack + inc pStack + sta (pStack) - clc +* clc .9 rts *-------------------------------------- KW.NEGATIVE inc pStack diff --git a/BIN/FORTH.S.txt b/BIN/FORTH.S.txt index 0b84a036..69cf5207 100644 --- a/BIN/FORTH.S.txt +++ b/BIN/FORTH.S.txt @@ -5,7 +5,8 @@ NEW .OR $2000 .TF bin/forth *-------------------------------------- -HISTORY.MAX .EQ 256 +HIS.MAX .EQ 10 +HISTORY.MAX .EQ 512 *-------------------------------------- .INB inc/macros.i .INB inc/a2osx.i @@ -79,6 +80,9 @@ CS.START cld .DA CS.QUIT L.DEV.GFX .DA DEV.GFX L.MSG.GREETINGS .DA MSG.GREETINGS +L.MSG.HIS .DA MSG.HIS +L.MSG.HISPROMPT .DA MSG.HISPROMPT +L.MSG.HISROMPTCLR .DA MSG.HISROMPTCLR L.MSG.USAGE .DA MSG.USAGE L.MSG.ECHOCRLF .DA MSG.ECHOCRLF L.MSG.DEBUG .DA MSG.DEBUG @@ -99,7 +103,9 @@ J.ESC .DA CL.BS left arrow .DA HIS.GetPrev .DA CL.NAK right arrow L.KEYWORDS .DA KEYWORDS -I.KEYWORDS .DA GFX.PLOT +I.KEYWORDS .DA GFX.TEXT + .DA GFX.GR + .DA GFX.PLOT .DA GFX.RECT .DA KW.DUP .DA KW.DROP @@ -206,7 +212,9 @@ KW.IF.ID .EQ *-I.KEYWORDS .DA KW.Rg .DA KW.R *-------------------------------------- -C.KEYWORDS .DA CP.JSRX GFX.PLOT +C.KEYWORDS .DA CP.JSRX GFX.TEXT + .DA CP.JSRX GFX.GR + .DA CP.JSRX GFX.PLOT .DA CP.JSRX GFX.RECT .DA CP.JSRX KW.DUP .DA CP.JSRX KW.DROP @@ -446,7 +454,7 @@ CS.FORTH.Run jsr CL.Reset lda #80 sta CL.MaxCnt - jsr PrintPrompt + jsr CL.PrintPrompt bcs .9 .1 >SYSCALL GetChar @@ -734,11 +742,6 @@ CS.QUIT jsr GFX.Close .8 clc rts *-------------------------------------- -PrintPrompt >PUSHW L.MSG.PROMPT - >PUSHBI 0 - >SYSCALL PrintF - rts -*-------------------------------------- PrintDebugMsg lda pStack+1 ldy pStack bne .1 @@ -907,6 +910,9 @@ CS.END *-------------------------------------- DEV.GFX .AZ "/dev/gfx" MSG.GREETINGS .AZ "\e[?7h\r\nA2osX-FORTH %d.%d (FORTH-79)\r\n" +MSG.HIS .AZ "\r\n%3d : %s" +MSG.HISPROMPT .AZ "\r\n\r\n? " +MSG.HISROMPTCLR .DA #C.BS,#C.BS,#0 MSG.USAGE .AS "Usage : FORTH