Go Down

Topic: FORTH pre-loaded UNO or NANO? (Read 14469 times) previous topic - next topic

joemac2013

Is anyone aware of a supplier of Arduino boards that are pre-loaded with FORTH?

westfw

No.  AMForth runs on Arduino hardware, but the install is a bit obscure and it's not compatible with the Arudino bootloader.

joemac2013

I have heard of e-Forth also, I will look into them.

joemcder

Wow Forth.  I used that 30+ years ago on some automation projects.  A very clever compact language.

This is like seeing some aging movie star on TV that I thought was dead for years :)

I'm curious.  On what kind of project are you using Forth?

joemc




graynomad

Quote
This is like seeing some aging movie star on TV that I thought was dead for years

Reckon :)

_____
Rob
Rob Gray aka the GRAYnomad www.robgray.com

Grumpy_Mike

I saw someone at the Mini Maker Fair in Manchester (England) last year selling an arduino like board (same processor) that ran Forth for less than £20.

pegwatcher

#6
Feb 20, 2014, 07:44 am Last Edit: Feb 20, 2014, 10:30 am by pegwatcher Reason: 1
Forth needs a big stack which means lots of SRAM.
I'm not a complete idiot. Some parts are missing.

Robin2

I was interested in Forth years ago. I think I have a book I bought (just some photocopied pages) with the source code (probably for an 8086 chip).

Would there be any advantage of using it on an Atmega328 chip compared with the Arduino C++ system?

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Paul__B


Forth needs a big stack which means lots of SRAM.


Actually, no, the program stack would be in Flash.  The return stack uses just two bytes per call which is hardly catastrophic; you are unlikely to nest more than a hundred deep, similarly with data.

FORTH would replace the bootloader since it is the bootloader.  It assembles the code into flash just like bootloading a sketch, but piecemeal.  Using Flash, the interpreter comes up to talk to you on reset, or else it executes your code directly if so instructed.


Would there be any advantage of using it on an Atmega328 chip compared with the Arduino C++ system?


You would not be using the IDE - the serial monitor does not have the necessary functionality to load and save code.  The advantage is continuous but fast interpretation - you instruct it to do something and that happens virtually instantly, you construct pieces and try them out one after the other in a continuous flow.

Robin2



You would not be using the IDE - the serial monitor does not have the necessary functionality to load and save code.  The advantage is continuous but fast interpretation - you instruct it to do something and that happens virtually instantly, you construct pieces and try them out one after the other in a continuous flow.



This is more or less what I thought. I used to think (maybe still do) that Forth was a very clever concept but I suspect that in reality it would be a lot more work to use than Arduino C++

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Paul__B


I used to think (maybe still do) that Forth was a very clever concept but I suspect that in reality it would be a lot more work to use than Arduino C++


I have an itch to do a FORTH for the Arduino platform - hardware that is.  Of course, I have lots of itches.  :D

I did work on it for a while, using the 6809 which had just the right architecture for it (twin stacks).  The limitation was using RAM - you had to run it on a system with either NVRAM (battery backed - which I actually had) or provide a disk interface which got very clumsy.  A Flash based system - such as as Arduino - should make turnkey operation work just fine.

Another advantage we now have is much greater (text, virtual) screen resolution with scrolling - this can be as effective with FORTH as with C++.

One interesting difference is that to modify a deep word in FORTH you have to remove everything on top (FORGET) and then build it again - but that said of course, with C++ you have to recompile the lot every time.  That again is the thing about FORTH - you build it piece by piece and it runs (or can) as you do so.  You write a word to flash the LED, define it as "flashled" and then say (type) the word - and it does.  Instantly.

joemcder

This discussion is too narrow.  The language is usually far less inportant than the associated library environment.  Arduino ide is basically c++ with a very extensive set of libray objects from many sources.
For example, I often use the "IRremote" and "RF24LibraryMaster"  libraries for remote control of small robots.  Duplicating these under Forth would be a lot of redundant work.

Has anyone adapted Arduino libraries to Forth? Is it possible? 

Joe

westfw

Quote
Is it possible?

In theory, sure.  most forth implementations can include arbitrary assembly code added as Forth "Words", so you can add anything.
In reality, the AVR Forth that I'm (slightly) familiar with (amForth) is written using the Atmel assembler, which doesn't permit linking with external libraries, so it would be pretty difficult.  (Just a small matter of converting to Gnu assmebler, or similar.)  Creating a Forth word that calls C functions would be pretty easy.

I've added a sort-of forth interpreter "front end" to a large non-forth program a couple of times.  It's an easy way to get symbolic access and interactive behavior if you want to fiddle with a random library, for instance.

Forth is probably one of the smallest language that gives the programmer access to the program symbol names, which gives you some interesting capabilities.  But it has always seemed to me that Forth has never quite "grown up."  Other languages and environments came along and decided that thing like data structures were important, and Forth seems stuck in this "I'm faster than interpreted BASIC and look I can do IO model based on numbered 1k screens!"

polypagan

Forth was developed in 1958 (!) back when system software was hard to come by.  It was used a lot (especially in astronomy) since the '70's.  It's a weird (and useful) mix of operating system and programming language that really makes sense on tiny machines.

I obtained an ATmega328 (non-p) DIP pre-programmed with FlashForth from the fellow whose address can be found at http://flashforth.sourceforge.net/ (U$ 10).  Mail takes a little while from Finland.

Replacing the ATmega328p in Uno results in a working Forth system.

Playing with it, I managed to mess up the dictionary (The Uno's USB processor doesn't allow xon-xoff flowcontrol to work and it's easy to overrun the compiler, getting it confused... and it's writing to flash!).

I then used Nick Gammon's fabulous (You da' man, Nick!) hex uploader to burn a new version...
http://www.gammon.com.au/forum/?id=11638

Nick's program gets a little upset that FlashForth doesn't start at its lowest address, just set the fuse for $7c00 (EFuse = $fc) and you're good to go.

I re-flashed the ATmega328 and also put FlashForth on a Pro Mini (ATmega328p, works better because USB-TTL converter allows xon-xoff).

Long story here, I run Linux, so used Crossover Linux to run the assembler from Atmel Studio (Studio doesn't work under Crossover, AVRASM does!) to build it.  With a few edits, it can be assembled using Avra under Linux (or whatever), though I haven't tested the code yet.

Stacks cannot be in Flash, must be RAM.  However Forth uses very little RAM. Variables and two stacks live in RAM.  My sense, so far, is that C and C++ make much heavier use of RAM.

I am now in the process of writing analog and digital I/O routines in FlashForth.  Glad to share with anyone who's interested. And I'd like to hear from you if you are working on Forth on AVR's.

And, yes, it does mean abandoning the Arduino IDE and all those user provided libraries.  I do very much like the idea of a tiny operating system on the microcontroller that allows assembly and compilation. (Somehow the Mini is most impressive, being about the size of a large postage stamp!)  Making it do anything non-trivial may take a great while, however.

Two other Forth variants for AVR's are pForth and AmForth.  I have the source and haven't done much with them..... yet.

Cheers!
There are 10 kinds of people in the world, those who understand binary, and those who don't.

minom

I am interested in collaborating on forth implementations on the Arduino platform.  I share your preference for a small footprint o/s for home automation.

Go Up