Author Topic: REAL 'oldies' might remember "Forth" !!  (Read 4224 times)

0 Members and 1 Guest are viewing this topic.

Offline GlennSpriggTopic starter

  • Super Contributor
  • ***
  • Posts: 1259
  • Country: au
  • Medically retired Tech. Old School / re-learning !
REAL 'oldies' might remember "Forth" !!
« on: December 29, 2017, 02:36:16 pm »
After the response to my question about 'dBase', I thought I would go back a few MORE years, and either
'remind' or "edumicate (haha)" the 'young-uns' about a very old 'Language' called "Forth", dating back to
1968, and designed by "Charles Moore", which UNFORTUNATELY has fallen into dis-use today !!

Sorry for my initial 'ramblings' here, but it was a Language much before it's time!  In fact in it's day, it WAS
used in the Chips of specialized hand-held Engineering/Industrial 'Calculators' etc, and for automated control
of many machines, (imagine a 'washing-machine' today!!), and should have had a lot better recognition TODAY.

It was considered the 'Fourth' generation for computer hardware, but the original 'computer' utilized could only
handle a '5-bit' filename, so "Fourth" became 'Forth'.  (Please hang on.... I'm getting there !!  :) )

This 'Language', was initially defined with what they called 'Primitives'. An original 'Subset' of 'Words/commands'
that were used to 'Create/Define' higher & higher level words, including such high level words along the way !
To that in the end, ONE 'word' could describe the operation of an entire application ! (This is hard to grasp...).
(You were effectively creating your own tailored 'language' along the way, and the original/new commands
 could be 'written' out in a meaningful 'Sentence' like structure......  For Eg.... The command 'RunNow'......
    "Open Valve 1 Till Sensor 2 High. Close Valve 1. Start Pump 3"....  etc etc...

W.T.F. ?  Yep!, that's how you would 'program' it, using these higher level 'words'.
The ENTIRE software package would take up between 20k & 40k on a PC, and something like 20k on a Commodore-64.
It's 'NUMBERING' system was definitely not for the 'Feint-Hearted' today... :)  and utilized the "RPN" system....

"RPN" stands for "Reverse-Polish-Notation", and when explained, it all makes sense !!  :)
THIS mathematical system has NO 'Parenthesis' characters in an equation, so placement it critical. Let's explain....  :)
NORMALLY, we may say something like....     2+(3*4) where obviously 3*4=12, + 2 = 14.
This is NOT the same as ... (2+3)*4  where 2+3 = 5, * 4 = 20 !!!
If we WANT the 1st scenario to be valid, using RPN, we would say.....  3,4,*,2,+  (no parenthesis)
If we WANT the 2nd scenario to be valid using RPN, we would say.....  2,3,+,4,*  (no parenthesis)........

AArgh... why would we do this !!!!!...... EVERYTHING in 'Forth' utilizes STACKS. Numbers & operands placed on
'LIFO' (Last-In-First-Out) stacks. It is the basis of the whole language  :)  When you understand STACK manipulation
you are 90% there....

You can STILL download & play with 'FORTH' from numerous sources, including versions now for the PC that include
quite good graphical control/display too.....
THIS 'LANGUAGE' SHOULD NEVER HAVE DIED'  xox
Diagonal of 1x1 square = Root-2. Ok.
Diagonal of 1x1x1 cube = Root-3 !!!  Beautiful !!
 

Offline glarsson

  • Frequent Contributor
  • **
  • Posts: 814
  • Country: se
Re: REAL 'oldies' might remember "Forth" !!
« Reply #1 on: December 29, 2017, 03:08:04 pm »
Also worth mentioning about Forth:

Both an interpreter and a compiler at the same time.

Integer division rounds towards minus infinity, not towards zero, i.e. -1/3 is -1, not 0.

The programmer can extend the compile with new behaviour, e.g.:
Imagine we need to create arrays. In Forth that would be something like
Code: [Select]
5 ARRAY FOO   ( create array FOO with five elements )
42 1 FOO !    ( store 42 in second element of FOO )
1 FOO @       ( get value from second element of FOO )
How do we add ARRAY to the interpreter/compiler?
Code: [Select]
: ARRAY   CREATE 2*  ALLOT  DOES>  SWAP 2* + ;     8)
The colon enters compiler mode, compiling the new word ARRAY. The following words until the DOES> is executed when the word ARRAY is used. The words after DOES> is the inherited code executed when words created by using ARRAY (FOO in the example above) is executed. The semicolon ends the definition of the word ARRAY.

Btw, I don't think Forth is dead. It is just hiding in embedded systems.
Also, all Sun workstations with SPARC processors and Apple computers with PowerPC processors used a Forth system for booting.

In the mid eighties I developed and sold a Forth cross compiler for use with Z80 processors. At the same time it could interpret and compile code both for the host system and the target system, i.e. words like ARRAY above could have different behavior in the host system and the target system (add info to symbol table on host system, reserve space on target system). Funny days.
 

Online chris_leyson

  • Super Contributor
  • ***
  • Posts: 1541
  • Country: wales
Re: REAL 'oldies' might remember "Forth" !!
« Reply #2 on: December 29, 2017, 03:45:00 pm »
I remember fig FORTH running on a 6502, painful. >:(
 

Offline Macbeth

  • Super Contributor
  • ***
  • Posts: 2571
  • Country: gb
Re: REAL 'oldies' might remember "Forth" !!
« Reply #3 on: December 29, 2017, 03:52:01 pm »
I dabbled with FORTH on a BBC Micro back in the day, but much preferred the inbuilt BBC Basic and its inline 6502 assembler.
 

Offline glarsson

  • Frequent Contributor
  • **
  • Posts: 814
  • Country: se
Re: REAL 'oldies' might remember "Forth" !!
« Reply #4 on: December 29, 2017, 03:52:45 pm »
I remember fig FORTH running on a 6502, painful. >:(
Yes, the limited stack, addressing modes (and that page 0 crap  :palm:) of the 6502 was not a good match to Forth.
 

Offline GlennSpriggTopic starter

  • Super Contributor
  • ***
  • Posts: 1259
  • Country: au
  • Medically retired Tech. Old School / re-learning !
Re: REAL 'oldies' might remember "Forth" !!
« Reply #5 on: December 29, 2017, 04:00:01 pm »
Dear 'Glasson' thank you for your informative reply !!!
I was trying to keep it simple, but YES it's Compiler added a LOT to what could be done !
You say that 'Forth' is not dead, (and should not be xx).......
Why do we keep trying to re-invent the wheel Chris
Diagonal of 1x1 square = Root-2. Ok.
Diagonal of 1x1x1 cube = Root-3 !!!  Beautiful !!
 

Offline Neomys Sapiens

  • Super Contributor
  • ***
  • Posts: 3268
  • Country: de
Re: REAL 'oldies' might remember "Forth" !!
« Reply #6 on: December 29, 2017, 05:01:00 pm »
Yup. I darkly remember that someone made a µP specifically tailored to this language. Somewhere here a Forth manual must be buried - I know how it looked, but not where it is. That it hasn't made its way into the central index is a sign that it hasn't benn needed for a long time.
But for notorious HP calculator users, it was pretty self explaining.
 

Offline glarsson

  • Frequent Contributor
  • **
  • Posts: 814
  • Country: se
Re: REAL 'oldies' might remember "Forth" !!
« Reply #7 on: December 29, 2017, 05:18:31 pm »
There have been many processors designed to run Forth, but the first (NC4000) was designed by Novix Inc (founded by Chuck Moore). Not only did Chuck invent Forth, but he also designed a processor to run it.  :-+

https://en.wikipedia.org/wiki/Charles_H._Moore
http://users.ece.cmu.edu/~koopman/stack_computers/sec4_4.html
 

Offline Howardlong

  • Super Contributor
  • ***
  • Posts: 5315
  • Country: gb
Re: REAL 'oldies' might remember "Forth" !!
« Reply #8 on: December 30, 2017, 10:47:15 am »
Anyone else cut their Forth chops on a Jupiter Ace?

https://en.m.wikipedia.org/wiki/Jupiter_Ace

If you were an assembly language programmer the concepts were pretty easy, and wow, did it perform compared to the BASIC machines out there at the time.

As well as learning Forth on it, I remember trying to teach Forth on it. That was not my finest hour.
 

Offline glarsson

  • Frequent Contributor
  • **
  • Posts: 814
  • Country: se
Re: REAL 'oldies' might remember "Forth" !!
« Reply #9 on: December 30, 2017, 11:17:50 am »
One place where the spirit of Forth certainly lives on is in PostScript and PDF.
 

Offline rhb

  • Super Contributor
  • ***
  • Posts: 3476
  • Country: us
Re: REAL 'oldies' might remember "Forth" !!
« Reply #10 on: December 30, 2017, 03:20:21 pm »
The demise of forth is greatly exaggerated.  Check out Matthias Koch's Mecrisp.

http://mecrisp.sourceforge.net/

There are a vast number of forth implementations available on the web as well as many forth specific mailing lists.  Now we get several new programming languages every year, most seem to be yet another variant of PL/I with its own "specialness".  I think forth has quietly continued amidst the din of "new and improved".

I loved forth on the 6502, but the implementations I had for the Vic20 and C64 were complete crap.  Very buggy and almost no documentation.   I only got as far as writing a decompiler before another round of graduate school intervened and I started playing with a MicroVAX II in a BA123 "world box".

 

Offline stj

  • Super Contributor
  • ***
  • Posts: 2153
  • Country: gb
Re: REAL 'oldies' might remember "Forth" !!
« Reply #11 on: December 30, 2017, 05:02:17 pm »
and reading this thread, i am reminded about why i learned assembly on the 6502.
under 60 commands to rule the world, less than 20 really used - and damned fast.
 

Offline rhb

  • Super Contributor
  • ***
  • Posts: 3476
  • Country: us
Re: REAL 'oldies' might remember "Forth" !!
« Reply #12 on: December 30, 2017, 06:10:43 pm »
When you compared it to an 8080 or Z80 it really was sweet.  I still like the architecture.  RISC before the term was coined.
 

Offline joeqsmith

  • Super Contributor
  • ***
  • Posts: 11630
  • Country: us
Re: REAL 'oldies' might remember "Forth" !!
« Reply #13 on: December 30, 2017, 06:15:59 pm »
I used  MMSFORTH from Miller Micro Systems for a few projects in the mid 80s.   Doing a search, it looks like they still offer it but it appears I my memory is flawed or they changed their name.  It had turtle graphics you could use to plot your data and such.  I think back then I may have been running this without a hard drive. 

http://www.millermicro.com/mmsforth.html

Offline glarsson

  • Frequent Contributor
  • **
  • Posts: 814
  • Country: se
Re: REAL 'oldies' might remember "Forth" !!
« Reply #14 on: December 30, 2017, 06:20:51 pm »
When you compared it to an 8080 or Z80 it really was sweet.
If you could live with the tiny 256 byte stack (at a fixed location!) and page zero.
 

Offline rhb

  • Super Contributor
  • ***
  • Posts: 3476
  • Country: us
Re: REAL 'oldies' might remember "Forth" !!
« Reply #15 on: December 30, 2017, 07:52:49 pm »
We are talking about forth, remember?  It needs two stacks which can easily be implemented in 256 bytes.  Rockwell made 65xx devices with forth in ROM, the R65F11 and R65F12.
 

Offline glarsson

  • Frequent Contributor
  • **
  • Posts: 814
  • Country: se
Re: REAL 'oldies' might remember "Forth" !!
« Reply #16 on: December 30, 2017, 08:00:24 pm »
It was a comment on the 6502 processor in general. It had its limitations compared to the competition.
 

Offline stj

  • Super Contributor
  • ***
  • Posts: 2153
  • Country: gb
Re: REAL 'oldies' might remember "Forth" !!
« Reply #17 on: December 30, 2017, 09:51:25 pm »
When you compared it to an 8080 or Z80 it really was sweet.
If you could live with the tiny 256 byte stack (at a fixed location!) and page zero.

page-0 was an advantage, not a problem.
you could use single-byte addressing to make stuff run even faster!
 

Offline daybyter

  • Frequent Contributor
  • **
  • Posts: 397
  • Country: de
Re: REAL 'oldies' might remember "Forth" !!
« Reply #18 on: December 30, 2017, 10:42:49 pm »
Forth is still used on the zx81 as an example? I still see new forth code there from time to time?
 

Offline glarsson

  • Frequent Contributor
  • **
  • Posts: 814
  • Country: se
Re: REAL 'oldies' might remember "Forth" !!
« Reply #19 on: December 30, 2017, 11:55:36 pm »
page-0 was an advantage, not a problem.
you could use single-byte addressing to make stuff run even faster!
Yes, it could make it faster, but when trying to implement multitasking it was a liability that page 0 and stack could not be moved. The 6502 should have had two registers that defined where page 0 and stack were.
 

Offline rrinker

  • Super Contributor
  • ***
  • Posts: 2046
  • Country: us
Re: REAL 'oldies' might remember "Forth" !!
« Reply #20 on: December 31, 2017, 12:27:35 am »
 having started with the 1802, with its 16x16 bit registers where any one could be the program counter and any one could be the stack pointer, and you could switch on the fly, and then moving to the Z80 for my second machine code programming experience, when I had to do part of my final program for the Apple II in assembly because the BASIC was too hideously slow to do motion graphics, I found the 6502 to be VERY hard, taking much more code to do the same thing I could have done on the Z80 or 1802. Tom Pittman had the same problem with Tiny BASIC. It fit in 2K on the Z80 or 808. It came in 200 bytes UNDER 2K on the 1802. But try as he might, he couldn't get it in 2K on a 6502 without cutting something out.
 

Offline rhb

  • Super Contributor
  • ***
  • Posts: 3476
  • Country: us
Re: REAL 'oldies' might remember "Forth" !!
« Reply #21 on: December 31, 2017, 01:26:14 am »
I've read the first 3 editions of "Computer Architecture: A Quantitative Approach" by Patterson and Hennessy cover to cover and the manuals for over a dozen processors.  The 6502 is *still* my favorite processor.  Very clean and simple.

For the design requirements, the 6502 was a tour de force.  Nothing else came close to that level of performance for the same price point.  There's a great interview with Wozniak in which he describes his reaction to learning about the instruction set of the 6502.  He knew what to do with it as soon as he heard about it.

As for page 0, that would have been ideal for multitasking if that was where you saved registers.  The art of programming is adapting the algorithms to the architecture.  In every edition of Patterson and Hennessy the choice of algorithms for many tasks changed completely.  On a VAX one did tests inside loops to avoid computation.  On the MIPS R2000 and early SPARC you eliminated the test to avoid the branch delay slot  penalty which was later eliminated by speculative execution.

The last time I did any performance sensitive programming was on a DEC Alpha 19 years ago.  For that I wrote a program to generate the FORTRAN code which used the only computed GOTO I have ever written.  The main loop incremented by 2 and each time calculated j and j+1. But it got me a 10-15% speed up.  I used Alphas because they were 5x the floating point speed of an x86 at the same clock rate and price.

 

Online chris_leyson

  • Super Contributor
  • ***
  • Posts: 1541
  • Country: wales
Re: REAL 'oldies' might remember "Forth" !!
« Reply #22 on: December 31, 2017, 02:04:15 am »
Hi guys, in an earlier post I said Forth on a 6502 was a pain. It wasn't a comment about the 6502 architecture but back then it was hard work no matter what processor it ran on. I had to buy an assembler listing from the Forth Inertrest Group, wait for it to arrive in the post and then type it up bit by bit and save on cassette tape. My only documentation was an assembler listing with few if any examples and then I had to get it run on a UK101, I didn't have the patience.

Today in just half an hour I had flashforth up and running on a Microchip microstick, just plug in an FTDI RS232 serial converter, open up TerraTerm and job done. Well it should have been job done but RX and TX are swapped over in the PIC24H config file so it took a bit longer to find that bug.

Anyway, after missing the obvious flashforth is now running on a PIC24HJ128GP502 on a microstick. Thanks Mikael Nordman :-+ :-+ all running through a terminal program. No compiler required just an assembler, cool.

« Last Edit: December 31, 2017, 02:14:22 am by chris_leyson »
 

Offline rhb

  • Super Contributor
  • ***
  • Posts: 3476
  • Country: us
Re: REAL 'oldies' might remember "Forth" !!
« Reply #23 on: December 31, 2017, 02:32:34 am »
Look at Mecrisp.  It really is just awesome, which is not something I say lightly!  And it runs on a bunch of ARM and MSP430 dev boards from multiple vendors.

I certainly agree about forth in the 80's.  I've got the listings from Mountain Valley Press in my library and probably the FIG publication as well. I bought everything I could find at the time.  Unfortunately, nothing matched the ROM cartridges for my Vic20 or C64.
 

Offline Maxlor

  • Frequent Contributor
  • **
  • Posts: 565
  • Country: ch
Re: REAL 'oldies' might remember "Forth" !!
« Reply #24 on: December 31, 2017, 02:49:02 am »
and designed by "Charles Moore", which UNFORTUNATELY has fallen into dis-use today !!
Surely you meant to say UNFORTHUNATELY.

Actually, some of my machines still run Forth code to this day. Part of the bootloader of FreeBSD is written in Forth. If you run FreeBSD, have a look at /boot/loader.4th or the other *.4th files there. I suspect the reason that it is so is because a Forth interpreter is easy to implement in a small amount of code, and the old BIOS bootloader only has a very small amount of RAM available.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf