Hi pdragon,
I'm happy you were able to get things working.
Your setup sounds pretty neat. If you have a repository or web page that explains your setup, I'd be happy to include a link to that in the docs/ch_installing.adoc file and you are welcome to make a Pull Request for that.
Can you dump and reload compiled words? It's Forth, so the answer is "of course you can" - the real question is how difficult it is. Tali has no in-built facilities to do this itself, so you will have to write it yourself, and some of the things you will need to touch are currently not exposed to Forth. You might write it entirely in assembly and then you'd create Forth words for performing the dump or restore, or you could create some Forth words to allow access to the data structures used under the hood in Tali and then you can do it all in higher level Forth.
--------------- BEGIN Long-winded description of what might be involved
There are "user variables" in both zero page and in regular RAM. You'll need to touch both. A few have Forth words to give you their address, but many are just defined as an offset from the beginning of the set. By default, the zero page user variables start at address 0 and go up from there (unless you moved the label "user0" in your platform file). You can see their offsets in
definitions.asm. You are going to be interested in
cp (the Compiler Pointer),
dp (the Dictionary Pointer), and
up (User Pointer - holds the address of the user variables in RAM) in zero page.
You'll also need to access some in-ram user variables. These use the address in
up (which you can get using the word
USERADDR in Forth) as a base address and then the offsets are listed further down in
definitions.asm. You might be interested in
current_offset (determines which wordlist is being compiled into - be careful as this is a single byte and is an index into the list of wordlists),
num_wordlists_offset (also a single byte - it's the number of wordlists that currently exist - default is 4 (FORTH, ASSEMBLER, EDITOR, and ROOT),
wordlists_offset (an array of 16-bit addresses to the name token (address of a dictionary entry) for the latest word in each wordlist - there are the base 4 plus 8 more slots the user can use),
num_order_offset (single byte - number of wordlists in the search order), and finally
search_order_offset (an array of 9 bytes with each holding an index into the wordlists_table to indicate the order the wordlists should be searched during dictionary lookup).
If you aren't familiar with wordlists, I recommend reading
https://forth-standard.org/standard/search - it's a bit obtuse, as it's trying hard not to specify
how a Forth might implement these things. This is one of the more complicated pieces of Tali Forth, and I can see why people like the older VOCABULARY method of dealing with multiple dictionaries.
By default, when you first start Tali, all new words are compiled into the FORTH wordlist. In order to "save" your compiled words, you'll want to dump the memory between where CP was BEFORE you started (you can use the Forth word
HERE to get that) and where it points to after you have compiled your application. Assuming you don't want to create a separate wordlist and just use the Forth wordlist, you'd just need to save and restore that block or memory along with the pointers in CP (in zero page), DP (in zero page), and the address in the FORTH wordlist (which is wordlist #0) in main memory. Note that this will restore the dictionary AND the compiled words, as Tali currently compiles the dictionary entry and body of the words together. If you want to be able to remove the names of the words, you could modify Tali to compile the names somewhere else.
If you are going to create your own wordlists, you really need to save/restore all of the wordlist items.
--------------- END Long-winded description of what might be involved
I agree that evaluate does not handle \ comments properly when they are embedded in strings - that's because ACCEPT gets one line at a time and does not include the line ending, so Tali simply jumps to the end of the input buffer when it sees \. On the other hand,
( and
) type comments should work. If you want to try fixing this (or want me to fix it), you are welcome to open an issue, but I will warn you that it should probably fix the behavior in BLOCKs as well, which have no line endings and simply have lines at fixed offsets.
In terms of a development cycle, what you describe for loading source into memory and then EVALUATE-ing in the simulator is the "hard way". Most people just edit the source on their PC and then copy/paste into the window running the simulator. I do that for developing on my real hardware as well, but it's a terminal window instead of a simulator window. It lets you use your fancy editor on your PC while seeing (almost instantly) the results from Forth. It's also super handy to copy/paste line by line when you are trying to debug something. I'm on Linux, so it's just highlight with regular mouse button and then middle click in the terminal to paste. On windows you can use the usual copy/paste commands. Once I have working code that I will want to use later, I copy it to compact flash or SD card, for which I have only implemented read-only support.
I like to work with what I call "reproducible state". I start with a cold booted Tali (you can always use the word
COLD to get back to the cold boot state) and paste in my code to get to a particular state. If I'm troubleshooting, it will be the point just before the bad things happen. If I'm writing new words, it will be just after the new words have been defined so I can poke and prod them. Then I'll type manually at the Forth prompt to explore. I might paste in some problem code line by line or create a test word to try small pieces of it. If things break again, I can always "rewind" by resetting my board or simulator and pasting up to just before that point.