Date: Sat, 8 Jun 2013 12:48:54 -0400
From: mcguire at
neurotica.com
To:
Subject: Re: [cctalk] Re: FORTH fans rejoice
On 06/08/2013 11:00 AM, ben wrote:
The
NC4000 was fun to play with, still. I recall
comparing my 4MHz processor to Intels 80386 at 33mHz.
I wrote some optimized code to sort 1000 integers. The
NX4000 ran in about 19 millisconds.
I don't recall exactly what the 386 did but it was 2 or 3 times
slower.
I'd added one specialized hardware/code to my boards. I made
it so that if I wrote to 0FFFF and read it, it would swap the high
and low order 8 bits. It was relatively efficient because -1 was
a short constant instead of a full address.
I needed the 8 bits for my drivers for the floppy and hard drive.
I'd also add a couple parts so that on boot, I could load the core
to shadow RAM and then switch to full RAM. That allowed me to
do patching while experimenting with new core code. I'll trying to
recall the manufacture of the processor board( it is in storage ).
The other fun thing was that it could recompile the ROM image
from the hard disk in less than 15 seconds.
The 4000 had an interesting tradeoff in power to speed.
The ALU would calculate everything on each cycle and then
you'd pick the answer through a mux. This allowed things like
add or subtract to start working before the opcode was even
fetched, for the add or subtract. Long carries still consumed
more than two cycles on faster clock speeds. One threw a NOP
infront of the + instruction to allow it to complete.
It didn't make sense to me until John Ribble explained it to me.
Dwight
But the question, does Forth need to super fast?
That all depends on the application requirements, not the chosen
implementation language.
That said, though, Forth is, very generally, almost always very fast.
-Dave
--
Dave McGuire, AK4HZ
New Kensington, PA
One can alway write optimized C that will be faster
than code written in Forth. Still, many Forth programs
run faster than a similar large C program.
It isn't that Forth is really faster, usually it isn't because
it is usually a compute engine described on some other machines
native code. Most C code is optimized to relatively clean
native level code.
So, you ask why in a large application, Forth often beats
C?
The answer is simple. In Forth, one tends to write better thought out
and better quality code. In Forth you write with words to make
descriptive sentences. The language is not always between you
and your application. Forth is formed into your application.
It is not English or French. It is just a way
of describing to the computer what it is you want it to do.
When one gets used to doing this, one finds it is easier to write
quality, correct code.
There are a lot of things people don't like about most Forths.
It usually does no type checking ( rarely actually needed and
rarely keeps you from making serious mistakes ).
It has a lot of irritating stack words and most temporary variables
are not named ( well written Forth makes minimal use of stack
words, except at the lowest levels ).
Most free Forths did not include floating point ( rarely correct
for most applications but simpler to use ).
Dwight