====== A Threaded language for a 6809 ====== In this section of my wiki I will be documenting my efforts to create an implementation of a threaded (Forth-like) language for a 6809/63C09 processor. ===== Progress ===== March 26, 2023\\ The TIL was able to start up and spit out its initial welcome message. April 15, 2023\\ The outer interpreter is working. I am feeding it "42 ." as a test. The "42" gets parsed and pushed to the stack which means the NUMBER routine is working. When it gets to the "." it always fails to find the "." keyword. It just outputs an error but at least it returns the part of the outer interpreter loop where it waits for input. My first thought was that there is a problem with the handling of the IF and ELSE keywords. What I did realize after I spent some time stepping through the code to see what it is doing I learned that IF and ELSE were working correctly. What I did come to realize is that those keywords are expecting a 16-bit address offset but some of the secondaries that I took from Loeliger are only expecting an 8-bit offset. This is an implementation detail I need to resolve. The changes are minor but if I use 8-bit offsets then the conditional and loop keywords are limited to a range of plus or minus 255 bytes. When I first implemented the body for the conditional and loop keywords I went with 16-bit offsets to avoid that limitation. I'm now thinking of going with 8-bit offsets per Loeliger. A 255 byte offset in a secondary allows for 127 keywords on either side of the conditional/loop. A secondary with that many lines in it would be a rare case and probably one that would need to be split into multiple parts. Having thought about it a while I am going to redo the implementations of the conditional/loop keywords to use 8-bit offsets. April 22, 2023\\ I am continuing to test the basic parts of the outer interpreter. It still throws out an error message instead of executing the . (dot) keyword. I did find a problem with the part of SEARCH that obtained the code word address and the link address. I also needed to make a change to ?SEARCH as I have the vocabulary split in to two parts: the core (fixed) vocabulary in ROM, and the user created vocabulary in RAM. March 26, 2023\\ The TIL output its "Hello" message for the first time. April 13, 2023\\ I fed the TIL the string "42 ." and it spat out an error that indicated it didn't understand 42. After outputting the error it waited for more input. That is a good step. The heart of the outer interpreter is working. Just one of the flags is off that indicates that the number conversion was successful. April 14, 2023\\ I am still feeding the string "42 ." to the TIL. I found it wasn't pushing conversion flag correctly at end of NUMBER and MODE was missing #. It now accepts a number and goes back to top of outer interpreter to parse the next token. Gets lost before it calls the dot routine. It seems to be getting lost when it returns from NUMBER saying that "." is not a valid number. April 25, 2023\\ Discovered the division routines were broken. April 27, 2023\\ Fixed the 16 and 32 bit division routines. Optimized the 32 bit division routine to get a 5% reduction in its worst case run time. April 29, 2023\\ Finally finished work on the division routines. Now trying "22 DUP + ." but it failed to find DUP. Checked keyword linking and fixed some bad links. Changed FDB to FCB in keyword length for CONST and CCONST. L and T labels for CCONST were swapped. Link address for 2DROP used L2AT instead of T2AT. April 30, 2023\\ Still more fixes to the division routines. I think they may be the final changes to them. It processes a line of input but it still throws an error after all the data on the line has been processed. May 1, 2023\\ Finally fixed the last(?) of the issues in the 16 and 32 bit division routines. Identified problem with the TOKEN routine during yesterdays testing. It isn't properly detecting end of line and throws an error after it process the provided input. May 2, 2023\\ Modified TOKEN to leave a flag on the stack. If a token was found the flag will be TRUE. If no token was found the flag will be FALSE. Modified the outer interpreter to expect the flag from TOKEN. If TOKEN returned FALSE the outer interpreter will go back to looking for input. The true value of the flag is actually the length of the found token. May 22, 2023\\ Fixed an implementation error. I originally wrote the primitives handling jumps to use 16-bit offsets thinking that would give them full access to the 64k memory space. I later realized that the secondaries from Loeliger were expecting 8-bit offsets. I changed the code so that jump offsets are now using 8-bits.