Post Reply 
FORTH for the SHARP PC-E500 (S)
10-08-2021, 01:04 PM
Post: #25
RE: FORTH for the SHARP PC-E500 (S)
(10-05-2021 01:02 PM)Klaus Overhage Wrote:  Thank you Helix for BINTOTXT.EXE. From Forth500.bin it directly generates the 71k byte text file required for the MBSharpNotepad. And with your tip in the OPEN command to replace the parameter C with L, I can now use your original BASIC program except for this small change. The runtime has surprisingly remained at 18 minutes, it is probably given by MBSharpNotepad.

A 71KB file takes some time to load, but I'm surprised it takes 18 minutes. Have you set SIO to 9600 baud? If this can't be done faster, then I'm sticking with the cassette transfer method that takes 90 seconds.

(10-05-2021 01:02 PM)Klaus Overhage Wrote:  Next I tried to load the file debugger.fth from the folder "additions".

In RUN mode: COPY "COM:" TO "E:debugger.fth",A
In Forth500: INCLUDE debugger.fth
Loading debugger...
-- after 90 second --
Loading debugger... Exception #-13

The dictionary search is not optimized in the original code. As a consequence the loading and compilation of Forth takes some time and the program you are loading is not small. The original pceForth code compares the word length and if equal compares the word's names. I've made the comparison case insensitive. This adds only a few cycles with some clever bit bashing in assembly and won't add overhead that is noticeable, because the chars compared typically differ in their lower 5 bits that are checked first:

Code:
                mv      (!el),il                ; Set the counter
lbl4:           mv      il,[x++]                ; Read next character of the current word string
                mv      a,[y++]                 ; Read next character of the searched string
                sub     a,il                    ; Compare the characters
                jrz     lbl5
; CASE-INSENSITIVE FIND-WORD (COMMENT OUT FOR CASE-SENSITIVE FIND-WORD)
                test    a,$1f                   ; If not the same 32-byte block ASCII offset, no match
                jrnz    lbl4a
                add     a,il                    ; Restore character
                or      a,$20                   ; Make it lower case
                cmp     a,'a'                   ; If less than 'a', no match
                jrc     lbl4a
                cmp     a,'{'                   ; If greater than 'z', no match
                jrnc    lbl4a
                sub     a,il                    ; Compare the characters again,
                test    a,$c0                   ; but this time with a case-insensitive match
                jrz     lbl5
; END CASE-INSENSITIVE FIND-WORD

However, the dictionary search can be optimized, like most Forth implementations. For example, the HP-71b limits searching based on the word length, thus checks dictionary entries for words of the same length only. Other implementations use trees or hashing. There are also simple and practical ways to speed up dictionary search, which I will try. For starters, comparing the length and the first character simultaneously to check a dictionary entry will speed things up.

- Rob

"I count on old friends" -- HP 71B,Prime|Ti VOY200,Nspire CXII CAS|Casio fx-CG50...|Sharp PC-G850,E500,2500,1500,14xx,13xx,12xx...
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
FORTH for the SHARP PC-E500 (S) - Helix - 09-06-2021, 11:41 PM
RE: FORTH for the SHARP PC-E500 (S) - robve - 10-08-2021 01:04 PM



User(s) browsing this thread: 1 Guest(s)