Re: Newbie Question: dictionary organization?
- From: Coos Haak <chforth@xxxxxxxxx>
- Date: Wed, 12 Jul 2006 00:18:10 +0200
Op 11 Jul 2006 14:09:18 -0700 schreef Jean-François Michaud:
Paul Smith wrote:
Especially for microcontroller, I liked to use this header structure:
dw len+flags (misc flags, like precedence, if applicable, and name length)
dw name (aligned word name string)
dw body (pointing first address of word "body", may be cfa)
headers and bodies are separated. headers sit in consecutive address, therefore no link
to next header. getting to the next header is done by adding aligned name length to address
of current word. a new header is added before the last word, for searching through headers
in the order last-to-first. as result, headers are added from higher to lower addresses.
This is quite the interresting idea. I had never thought of that, but
it makes alot of sense. I might reimplement my Forth to take advantage
of this feature. Shave off a few Ks of code ;-) and gain some
flexibility.
bodies do not link back to headers. there is no need to, and this facilitates moving headers
around, and/or using a different organization, for faster searching for example. in the few cases
that i need to find header from body, i simply search for the header with matching body address.
This is relatively slow, but hardly ever used - if so, mostly interactively, for debugging and such.
Being able to get rid of NFA and LFA is more than worth this minor slowdown, IMHO. Consider that
headers are relocatable, without requiring any relinking, or offset calculation. Just move them
around, and update contents of LAST or the like.
I never do assume specific header- or body structure for translating between header/body addresses.
In combination with a deferred FIND, this allows me do change the header layout or organization on
the fly, runtime. or, to get rid of headers completely, freeing the space in EEPROM or Flash, if
desired. Not seperating headers from bodies will make this an awkward operation, if possible at all
(or wasting lots of space by the gaps the headers leave you).
Thanks much for the idea.
Regards
Jean-Francois Michaud
You might have a look how eforth is implemented.
The dictionary (bodies) are allocate upwards (of course)
but the headers downwards from the end of memory.
--
Coos
CHForth, 16 bit DOS applications
http://home.hccnet.nl/j.j.haak/forth.html
.
- References:
- Newbie Question: dictionary organization?
- From: Charles Turner
- Re: Newbie Question: dictionary organization?
- From: Paul Smith
- Re: Newbie Question: dictionary organization?
- From: Jean-François Michaud
- Newbie Question: dictionary organization?
- Prev by Date: Re: Newbie Question: dictionary organization?
- Next by Date: Re: using MISC (post 1987 Forth hardware) opcodes
- Previous by thread: Re: Newbie Question: dictionary organization?
- Next by thread: Re: Newbie Question: dictionary organization?
- Index(es):
Relevant Pages
|