Rooster wrote:
Hello,
I have Fig-FORTH running and booting from a serial EEPROM on my own circuit board.
I write code in Notepad and then 'send' it from TeraTerm (thanks to a tip on this forum).
As I write more and more words the load time is getting to be longer, and this unproductive time is killing me.
I would like to be able to save/restore the current state of the system so I don't have to do a complete reload of my code after each reboot.
My FORTH system setup is pretty standard for Fig I believe:
ORIG $400
MEM $7800
UAREA = MEM - $80
I wrote some code to copy the memory block $400-HERE to a serial EEPROM.
Before writing to the EEPROM, I copy $7780-$7796 to $40C-$422. This appears to be for bootup literals.
I am able to boot from this saved image, but the new words I defined do not show up with VLIST.
I manually stuffed a calculated value into CONTEXT and then the new words show up in VLIST.
I can't figure out how/where CONTEXT gets initialized.
Vocabularies, CONTEXT, CURRENT etc. are rather confusing for me at this point.
Am I on the right track or is there a better way?
Any advice would be appreciated.
Thanks
I have yet to come across a really good explanation of Vocabularies, Definitions, Context, Current: and it was a struggle to follow the code through and through.
But I finally came to to the realization that it basically acts the very same as a directory structure of an Operating System but with a continuation link to the parent directory's file names. In the root directory header you can create directories. These directories are known as the Context directories as their contents are linked to its parent directory, which presently is the CURRENT directory (or root directory). The last word in this current Directory (Vocabulary, which is currently the root) is pointed at with the definition of Latest (which is CURRENT @ @).
Now if we were to enter a directory (or one of the Context Vocabularies) by doing the command DIRECTORY DEFINITIONS, this makes the Directory now the current directory and we can see all of the contents of the this directory as well as its parent directory, but not the contents of one of the other directories. This is done by swapping the CONTEXT links with the previous CURRENT links (which was the root directory). And now the CURRENT directory (Vocabulary) is the one we just entered. And now we can see its dictionary of words, starting at CURRENT @ @, plus the words that are in its parent directory.
Then basically we can relate some of the words with OS commands.
VOCABULARIES is the same as CREATE, as in create directories.
DEFINITIONS is the same as Change Directory (CD) and enters the named Vocabulary.
CURRENT is a pointer to the header of the Current Directory which points to the last word in the CURRENT vocabulary. Thus we have to do CURRENT @ @ to get the last word in the Current Directory (Vocabulary)
CONTEXT is a pointer to its parent vocabulary when a new Vocabulary is created, but have not yet entered the new Vocabulary.
This is only way I can make reasonable sense of it all, and is probably why it is so tough to explain in words.
To answer your question:
CONTEXT is initialized when you create a Vocabulary with the word VOCABULARY.
CURRENT is initialized during the launch of the Forth System from a previously saved table of some User Variables.