SVFig part 3
- To: MISC
- Subject: SVFig part 3
- From: theFox@xxxxxxxxxxxxxxxxxxx (Jeff Fox)
- Date: Wed, 30 Jun 1999 20:44:02 -0500 (CDT)
I have transcribed and posted section 3 and 4 and added them to
http://www.UltraTechnology.com/cm52299.htm
here is section 3:
(part 3) Charles Moore
All right here are two other Forths.
I like to argue that they are not the same.
I don't intend Color Forth to be Machine Forth
although in a sense it kind of is.
MACHINE FORTH <FONT COLOR=GREEN>
ADDRESS REG
@+ !+
SDRAM </FONT> <FONT COLOR=BLACK>
COLOR FORTH </FONT> <FONT COLOR=GREEN>
F1-F5
EDITOR!
ICE
4X3 STACK
JUMP TABLE </FONT> <FONT COLOR=BLACK> </FONT>
.BMP
One of the questions about Machine Forth had to do
with the address register. So I though I would explain why there
is an address register.
And yes it is not very Forth-like.
It goes back to Novix days.
I don't know if you remember the Novix. I got an email question
about it recently and I didn't remember the Novix either.
But when you did a fetch
the problem was that the address was on the top of the stack
where the data had to go.
so the address was driving the address lines and data comes in on the
data lines and where do you put it?
Well what the Novix did was it put it under the top of the stack
and then it threw away the address on top of the stack.
Optionally if you were doing and incremented fetch it put in on top
of the stack and incremented the address that was on the top of the
stack
and everybody was happy. But implementing that in silicon was a mess
You have address lines going to the wrong place, the second element on
the stack. You have data lines going the wrong way.
You have address lines coming to the top of the stack which is equally
inconvenient.
You need a second cycle to fix up the stack after the operation is
completed.
To eliminate that it makes sense to move the address out of the way
to a special place out of the way and then you clear up the
stack to receive the data. Now this really wasn't my idea.
It was Russell Fisch's idea in ShBoom. I had lots of quarrels with
Russell but
he did have some good ideas and I appreciate them.
So given that the address register was kind of the least inconveniently
way
of handling addresses I kept it for P21.
It does let you do fetch plus (@+) and store plus (!+).
It makes it easy to do, almost free.
I would like to recommend that you use those words in your Forth.
It is easy to define a fetch plus.
If you do you will find it has a significant effect on your
programming style. Your keeping and address off stack. It offers
the most efficient addressing mechanism that I know of for
sequential addresses.
The alternative is something like DO LOOP with I fetch inside
which is a very expensive sequence of words.
That is a hard way to something equivalent to incrementing an
address. This is much more efficient.
I would like to see it moved into the standard. To superseded
some of these old fashion slow ways of doing things.
The standard is documenting Forth as it was 20 years ago.
Let's move a little faster than that.
In SDRAM this kind of fetch plus becomes even more important
as an efficient way of getting at memory. Everyone knows SDRAM
I imagine. You can get up to 256 sequential accesses
at 10ns intervals.
If you break that sequence of fetches it will cost
20-30ns hit, so sequential accesses are cheap.
In the case of F21 you could do @+ @+ @+ @+ in one word streaming
your fetches onto the stack. No interference from instruction
fetches elsewhere.
SDRAM also has two blocks of DRAM so you could Ping-Pong
back and forth without having to read a page each time.
It is still a hit, but it isn't as big of a hit. So you can
have a data page and an instruction page.
My new interface will optimize that but
if you don't know it is happening you can't take advantage of it.
Now Color Forth. Most of the work I have done on Color Forth is
on the PC because
I have never gotten any nice software on the i21.
I am too busy getting the hardware to work to worry about software.
It is as if I have a threshold, a container of interest. And when
I fill up my container for i21 with hardware and there is no
where for the software to go except to the PC.
Nothing that I am doing will have any difficulty in porting to the i21.
The fact that i21 is 20 bits wide and modern computers are 32 bits
wide is totally irrelevant, is it a non-problem.
In the case of the software that iTV has developed
I think only one or two places in TCP/IP where inherent 32bitness
of TCP/IP data was a factor. a 20 bit chip is capable of doing almost
anything
that a 32 bit chip can do.
You can even pack two ten bit characters into a twenty bit word. Three
six bit bytes.
How do I Edit in Color Forth? Yes I do have a custom editor for doing
this.
I think everyone should have a custom editor for editing their program
files.
I don't believe in universal editors.
An editor is so easy too write that why not?
A browser is very easy to write too, and
I know people don't like to believe me but
I will give you some examples in the course of the next year.
How do I edit color? I assign function keys. I've got six
space bars.
I hit the right space bar and I get the right color.
I will label the function keys will color dots as soon I find my
box of color dots.
Meanwhile it's green, red, and blue is one, two, and four.
The keyboard entry, the command line the same thing. you hit
the color space that you want to.
Why is the space before the word? I would make sense that you
accept the word and then terminating character is a postfix command
telling
you want to do with that word.
I thought long and hard about making it work that way.
The alternative is to have the space in front of the word which makes
it much easier for the editor or to format the word correctly.
And it turns out that I was right.
Because not only is the space
but the space after the word also. SO this way I have two spaces,
in fact there are three spaces.
There is the current color, the color for the current word,
the next work, and the previous word.
I require all three of those in order to do the right thing in the
interpreter.
So it finally came to me that what I've got is a 4x3 stack, I've got a
3 entry stack of 4 bits to describe each of these states.
So I have a little push down loop in which I multiply the previous
value
by 16 and add in the next value. And I've got the three in one variable
in the order that I need them
and I can peel of the one I want by shifting.
This is much better than having named variables for each one
or a little array in memory of individual words storing 4 bit values.
So I am pleased about the invention of the four bit stack.
Given what I have determined what I am going to do with a word
I go through a jump table to actually do it. I know the preceding space,
I know the word.
I go through a jump table to determine whether I am going to
convert that word to a number or whether I am going to
look it up in a dictionary or whether I am going to throw it away
or whatever. And one of these destinations in the jump table takes
me to another jump table where I take the next word, the next color,
and go through another jump table to decide what to do with this
first word that I've got. I'll show you some examples.
It's a very efficient process, much more complicated than
the old fashion state variable compile or execute.
Jeff Fox
www.UltraTechnology.com