Re: Build your own Forth for Microchip PIC: Design thoughts
- From: byron@upstairs.(none) (Byron Jeff)
- Date: Wed, 27 Jun 2007 22:14:14 -0500
Hi folks,
I'm back for another round after thinking about it a couple of days. I'm
coming to the stark realization that I'm really a Forth novice. My lack
of Forth experience seems to have two spheres of influence:
1. A lack of understanding of how Forth words "do stuff". To really
leverage the power of Forth, one really needs to have both a grasp of
the available wordsets and an understanding of how to adapt the words in
those wordsets to one's needs.
2. The environment lends itself to developing with a Forthlike thought
process. I've grasped a bit of it by reading "Thinking Forth". But with
a firm grounding in languages like C, it takes some experience to adapt
thought processes to the new model.
In short I have a pretty good idea what I want to do, but I'm not sure
either if I'm thinking about the right way, or even if I am thinking
about it the right way, how to pull it off.
So I come hat in hand asking for some help in both thinking about the
problem and how to go about developing it. It doesn't have to be a
detailed analysis I don't think, just some guidance of where to look for
some answers.
Problem Definition: I want to develop an incremental word cross compiler
for the PIC. I hope this has been a "been there, done that." type
exercise for some of you. The idea is to develop and test the word on
the host, then cross compile the word into its PIC equivalent for
transport to the target. So for example say I develop a simple word on
the host:
: add2 2 + ;
I test it out to see that it works:
5 add2 . 7 ok
Now I'd like to put the word permanently on the pic. Say for the sake of
argument I generate a string with the name of the word then call the
word picompile which generates the equivalent word for the pic:
S" add2" picompile ok
Say for the sake of argument the code for the pic equivalent is
generated in the word add2.pic. In addition the address for the word on
the pic is stored in the dictionary under add2.picaddr. I could then
somehow download the word to the PIC:
S" add2" picload ok
where picload uses the add2.picaddr and add.pic code to transfer the
code to the pic.
End of problem definition.
Now I've probably screwed up things 6 ways from Sunday. But I'm willing
to learn some proper ways of expressing the ideas that I've come up
with.
Some of my thought process has been colored by Brad Rodriguez's article
on developing a cross assembler in Forth:
http://www.zetetics.com/bj/papers/tcjassem.txt
what he wrote made a lot of sense. But I need to adapt some ideas.
Questions:
1. Instead of taking input from the normal input buffer, I want to
fundamentally parse a dictionary definition. The way I see it is
something like running "see <word>" taking the output and parsing it.
What I'm out of the loop with is accessing dictionary definitions
directly and parsing the words in those definitions.
2. I know that create puts new words in the dictionary and allot will
allocate space. I'm unsure how to access that allotted space once I
created it or exactly how to get a pointer to the definition's alloted
area. Brad used C, to extend and write into the dictionary space for
example.
3. I used strings above due to ignorance. How could one simplify the
examples to
add2 picompile
add2 picload
for example?
4. I know that Forth parses and does dictionary lookups. What kinds of
words should I be looking for to do these activities? Can parsing be
done from an arbitrary buffer?
I'm sure I have more, but I think this is enough to motivate some
discussion on the subject. Am I thinking about the problem in terms that
are even remotely Forthlike? Or would another approach make more sense.
Thanks for any thoughts on the matter,
BAJ
.
- Follow-Ups:
- Re: Build your own Forth for Microchip PIC: Design thoughts
- From: Brad Eckert
- Re: Build your own Forth for Microchip PIC: Design thoughts
- From: Jonah Thomas
- Re: Build your own Forth for Microchip PIC: Design thoughts
- From: Frank Buss
- Re: Build your own Forth for Microchip PIC: Design thoughts
- From: Elizabeth D Rather
- Re: Build your own Forth for Microchip PIC: Design thoughts
- References:
- Prev by Date: Re: Random Distribution in Forth
- Next by Date: Re: Build your own Forth for Microchip PIC: Design thoughts
- Previous by thread: Re: Build your own Forth for Microchip PIC (Episode 837)
- Next by thread: Re: Build your own Forth for Microchip PIC: Design thoughts
- Index(es):