hi Matthias,
> Did you have a good time on the Taiwan FIG meeting ?
Ans: 12 Forthers came from different area of the island to attend the discussion. We spend 6 hours for the seminar. One instructor presented his Raspberry Pi gadget with the possibility controlled by Forth.
The figTaiwan leader showed his Arduino eForth which is developped by Dr. C. H. Ting. The group members help to improve it to be able to enter Chinese command. One new forther presented his first step into forth by way of ASYST -- an old but sophisticated scientific software written in Forth. I'm the
obligation to offer my tricky Forth (tF) development sysytem to show all the assembler+disassemble+
decompiler+xcompiler. One other guy discussed the way to control the microcontroller through internet
and celler phone. Lots of interesting things around. We here now encourage forthers to use stm32F4xx
as the vehicle to develop Forth program. One company donated 50 pieces of this board for helping the
promotion. We also get a big amount of donation from other enterprise to support the running of figTaiwan. We also discussed the big annual activity to be held next month. By the time we have to provide the paper or some sort of articles concerning Forth to fullfill the big event. I am cordinally invite you to summit a script to raise the quality of this upcoming conference. In exechange I'll pass some good stuffs to you for helping the promotion of Forth to the world. We really did have a good time while gathering together with Forthers.
> I am a bit puzzled - have you choosen a new name ? Is Albert=Holi ?
While I were in the discussion classroom of the university, I've no wifi to transfer my files to you and the others, I borrowed the computer belongs to Albert to send the files. That's it. So me is holi.
holi === high output low input. ( becoming poor ) <--- my name
hilo === high input low output ( becoming rich ) <-- a company's name
Hi Holi, Hi Albert !
Thank you for the notes from the FIG-Taiwan meeting. I am glad that I have choosen the STM32F407 as one of the initial example targets for Mecrisp-Stellaris - if you write peripheral Forth examples for it or a port to another chip, as Albert has done before, I would like to include this into the main release.
You have been using Mecrisp for MSP430, too ? Surely you are familiar with constant folding and small optimisations, but one thing new in Mecrisp both for MSP430 and Cortex M is Flash memory handling. I would love to know if this enriches your conference. Feel free to translate in your native language.
The classical dictionary structure that links from the newest one back to the oldest one has the drawback that the pointer to the newest definition has to be stored in a secure place.
Flash in Mecrisp is linked backwards, with the oldest dictionary entry pointing to the newer one and with the link field of the current definition left blank to be filled in by next invocation of create.
I will do an example to show how it works: Take care on "Address" and "Link" :-)
This is dictionary in Ram. It has standard "forward" linking, with its oldest entry pointing to Flash-Core.
Address: 3A8 Flags: 0 Link: 380 Code: 3B0 Name: ende
Address: 380 Flags: 0 Link: 34A Code: 38A Name: anfang
Address: 34A Flags: 0 Link: 334 Code: 35A Name: ausgehendes
Address: 334 Flags: 0 Link: DAD2 Code: 344 Name: einkommendes
If you don't want to use Ram-Definitions or to make this invisible, FIND just starts in the Core.
Core parts, that will never be changed:
Address: DAD2 Flags: 0 Link: DAEC Code: DADA Name: ?key
Address: DAEC Flags: 0 Link: DB08 Code: DAF4 Name: key
Address: DB08 Flags: 0 Link: DB1E Code: DB10 Name: emit
[much more...]
Address: FD9E Flags: 81 Link: FDC0 Code: FDAE Name: irq-watchdog
Address: FDC0 Flags: 81 Link: FDE2 Code: FDD0 Name: irq-timerb1
Address: FDE2 Flags: 81 Link: 8000 Code: FDF2 Name: irq-timerb0
Link of last Core definition is always start of changeable flash dictionary space.
There is located either $FFFF with freshly erased flash or the header of the first added definition.
Address: 8000 Flags: 10 Link: 8016 Code: 8006 Name: (
Address: 8016 Flags: 10 Link: 802C Code: 801C Name: {
Address: 802C Flags: 10 Link: 8040 Code: 8032 Name: \
They link to the newer one...
Address: 877E Flags: 42 Link: 8876 Code: 8788 Name: cordic
Address: 8876 Flags: 42 Link: 888A Code: 887E Name: sine
Address: 888A Flags: 42 Link: 88A2 Code: 8894 Name: cosine
Address: 88A2 Flags: 40 Link: FFFF Code: 88A8 Name: pi
Link of current definition is unset, to be filled in later.
FIND starts serching in RAM and halts for the firts hit,
and if unsuccessfull, it continues to search in Flash.
In Flash (which is sensed by adress ranges), FIND always searches the whole Dictionary until it finds a $FFFF-Link or $FFFF on the place a link points to. Then it gives back the last hit found. So redefinitions are ok with backlinking.
On Reset, the current/latest definition can be found by going through the links. Free space for HERE is found by looking through flash memory back from the end until something different from $FFFF is found. This has one small quirk: You must ensure that definitions do not terminate with $FFFF - which would be recognized as free space on next Reset and overwritten.
In CREATE one has to take care where to insert the link - but you see clearly now :-) ?!
In my opinion, it would be interesting to see how this idea could fit into a traditional implementation - would you like to try it out while working on CamelForth ? You would have to change the initialisation of pointers, FIND, CREATE and take care of the header macro that builds the core. I hope this would fit Flash memory better, but it has to prove in more traditional environment, too. I came to this idea for myself - do you know of someone else who did this before ? I haven't found one, altough this problem is common for Flash-MCU based implementations.
The next corner to cut will be ram management - the pointer catching routine simply has one "variable pointer" that starts on the end of ram. Words like variable and 2variable are marked as "need ... words of ram". The pointer catching just has to subtract these memory needs from the pointer on startup. New variable definitions in flash decrement the variable pointer accordingly and hardcode the address it points to afterwards. As this gives the same results every run, you don't need to save this pointer, too. It is even possible to carefully erase some definitions from the end of dictionary and simply reset.
Mecrisp also offers initialised variables by letting the pointer catching copy the data after the first ret instruction of the definition marked as "needs ram" to the allocated ram locations - this feature almost comes for free.
Pointer catching needs some cycles - Mecrisp sets its clock to 8 MHz AFTER that to give slowly rising power rails a change. Then, find is invoked to search for occurences of init in dictionary...
Best wishes,
Matthias