Propeller Forth
Alex Silva
Posts: 10
I have done lots of searches but can't seem to find any recent updates on Propeller Forth. Does anyone know if Cliff ever released an update or the source?
Has anyone else done a Forth for the prop?
Has anyone else done a Forth for the prop?
Comments
mmm, I have been doing a rather ambitious version called CogForth but it's been pushed aside due to other pressures. The aim is to make it totally compilable from the Propeller IDE so that other Spin objects can be added to it so that you can roll-your-own kernel. That's where I've had a few moments where I have meditated on the wisdom and practicality of this course. What the Propeller IDE needs is something more like a macro-assembler to make my job a bit easier but I am not pushing for features as the Parallax boys are providing the compiler free and uncrippled (something that's rare these days) and it shouldn't become a cause for complaint or nagging.
For all you Forth heads who are looking for a real Propeller Forth to make your heads "spin" it would probably help me if you provided some feedback as to practical features and requirements. This may help me indirectly as well as make a Forth to suit the community in general. Free of course.
*Peter*
I personally don't see why not. If it's something needed to make a coding task possible or reduces developer time, and most other serious IDE's offer such a thing ( and it shouldn't be that hard to do ), then I think it's reasonable to both complain about lacking features and ask for them.
I appreciate the Propeller Tool is not core business, is not a direct revenue generator, that there are limited resources, but 'a few hours' spent adding a feature can save many thousands of hours of Propeller developer time long term.
It's always hard to quantify intangible costs and returns but if a commonly available feature elsewhere has delayed your time to release of your Forth that may have led to others wanting Forth not taking up the Propeller and having not put it on their buying list.
It would be best if features could be built into the Propeller Tool, but hooks to allow third-party add-ons to pre-process source code during the compilation cycle would be a good half-way house, minimising in-house work and off-loading the hard work to eager, ready and willing third-party developers. It would also open the door to 'who knows what' without any further effort in Propeller Tool development.
And I think there will be a FORTH from a "third source" in a few days... Needs still some testing and documentation ...
Honestly I am not too interested in ANS Forths or really flexible Forths that would port from architecture to architecture. I am sort of the school that Forth is easy enough to write what you need for each situation.
I understand that Cliff ran into some interesting issues in the Forth he did for the Prop but the source repository he set up is still empty.
I would be interested to see how you are doing your Forth, especially if you coded from the ground up.
I am reminded of this statement:
"What Forth desperately needs is more application-oriented libraries, but it seems that all programmers with time to spare want to do is implement yet another Forth." -Elizabeth Rather, who chaired the ANS Forth Technical Committee, in comp.lang.forth on 10/01/1998
I guess that is me [noparse]:)[/noparse]
Edit> And apparently some others
Forth on the prop immediately bogs down on the cog registers and the hub memory. It seems that you have to always build some sort of system that transparently moves assembly code words to the cog memory and to use stacks that are stuck in the slow hub. Putting all the code words and all of the stacks into the cog memory space is practically impossible. You might be able to, but if you add the assembly dictionary you find yourself building the moving system.
There was a lot of ground covered here about how to pull that off. Look for the Large Assembly Model and "Propeller Object Assembly Function Engine Demo (A method for Hybrid Spin-Assembly programming)" threads and such-like.
The cog memory is particularly irksome -- you have 496 longs, period. You can't address them any finer. There's no auto-increment or auto-decrement (djnz aside). Self-modifying code is the norm. Under the hood, Forth here won't look like or work like other Forths.
Lately I have been muddling through (thinking about) a Forth that builds direct code sequences in the cog, like a macro assembler. I am also looking at Moore's ColorForth for pointers on doing away with things. But no matter how you come at it, you are dragging a lot stuff across the rdlong/wrlong and through their 7..22 cycle peephole.
You can load Cliff's binary into the IDE and look at it with the hex dump. Others (Peter?) have gotten far enough to add word dump to it. But I don't think there is a single person who uses it. Cliff never even specified what his target system was; I suppose it was the demoboard but that's clutching at straws.
Fred
Even if you have the source code, it's not practically useable because of the static linking - which is probably the reason why Cliff never released it.
·
colorForth is one of the things I have been looking to for guidance so it hurts to hear that. I was planning on going through the parallel Forth resources too, to see if they had any useful insights.
mirror thanks for pointing that out. I have a Hydra so that wouldn't be too good [noparse]:)[/noparse]
Still the challenges this presents make it interesting so I am not giving up yet.
FemtoBasic - Source available and provides examples on extending for robotics (BeoBotBasic)
TinyBasic - Source is on the HYDRA CD
PropellerForth - As mentioned earlier, source code is missing but probably better than Basic for what I want to do
PropellerOS - Not a language but very relevant to what I want to do.
Am I missing any? I haven't used Forth in years and it would be fun to show my son that there are languages other than C++ and Java. I want a simple, extendable language that I can use interactively on the Propeller to experiment with various control behaviors.
Here is what I am planning:
One cog to do master Bioloid communications (all servos and sensors are on a 1Mbps half-duplex serial packet bus)
One cog to create an ADXL202 accelerometer sensor (communicating via the same serial bus as a slave)
One cog to run a "terminal" program for receiving commands, displaying status, and running behavior scripts
One cog to run the USB-based virtual keyboard/monitor for programming/debugging
One cog for Logitech wireless PS2 game pad
Three more cogs for future growth or behavior processing?
My current robot platform is the 18-servo humanoid and my proof of concept is to get him to follow guidance provided by a person holding its hand (like the old blindfolded trust game we all had to do).
If I every get all of this working I want to start on a second Propeller for robotic vision.
Data Stack Design
Consider a data stack that is implemented solely in the hub memory. To ADD two numbers, each must be RDLONG, summed and the results is WRLONG -- three hub accesses for a binary operand. An unary operation, like +1, would require a RDLONG and a WRLONG.
Consider a data stack that resides solely in Cog memory.· At 496 registers and a runaway loop, or merely a deeply nested sequence, it seems likely that a stack could easily consume the Cog.· The obvious solution is a limited Cog stack feeding a Hubstack.· A cog stack that is beyond trivial will require a cog stack base address, a cog stack maximum address, a current stack pointer, a hubstack base address and code to manage all of these pointers. Each push onto the stack requires a WRLONG and thrashing of every element in the Cog stack. Every pop requires RDLONG and a similar thrashing.
Much simpler and in my opinion, optimum, is a two element cog stack and a hubstack for the third through nth items. A binary operation would subsume the top two into a single·TOP item, popping a RDLONG to the second stack place (NEXT). A unary operation would merely change the TOP item.
So, register details:
TOP·············· register with the topmost number
NEXT············· register with the 2nd number
SCRATCH········your working register
HUBSTACK······FIFO pointer to the 3rd number in hub memory
HUBLOW········ the starting HUB location for the stack's 3rd item.
Rather than worry about empty stacks and to have special handling of the five cases (3 or more items, 2 items, 1·item, empty stack and underflow),
it is far simpler to assume that the stack's initial state has 3 items. And assuming that the Programmer does not screw up (or has debugged his work), the stack will work correctly all of the time without special cases:
To push a number
Putting into the ordinary forth of -,+ and -1 (code fragments only.):
If you want to worry about whether you have an underflowing stack, as does the . (dot) keyword, then you have five general cases that you can figure from the hubstack pointer and the hublow constant.
So really you only care about the 4th and 5th cases, which generalize as far as . is concerned to hubstack <= hublow-12.
EDITS: fixed push
About that underflowing stack aspects. Since this example loads up the stack with 3 don't care values -- WHICH SHOULD NEVER FALL OFF -- the actual (useful)·underflow case is when hubstack < hublow. In other words, you recover from an underflow by setting hubstack to hublow.
Post Edited (Fred Hawkins) : 9/23/2007 5:25:11 PM GMT
' add: n n - n
add TOP, NEXT
rdlong NEXT,HUBSTACK
sub HUBSTACK,#4
I couldn't see any clear way to do more than two without adding unnecessary complication. I don't think there's any opcodes that except maybe JMPRET that is aware of three registers. As I see it, this pair speeds up using the stack with our opcodes and limits the hub accesses to one per pop/push. That's about as good as the prop can get.
That said, maybe a dynamic cog stack can do better, but that's a different morning's musings.
A bigger cog stack would be useful for line drawing routines or 3d anything.
Fred
As a Forth user,( and writer ),it looks like you're constrained by the memory
model,and the lack of indexed addressing.
I'm investigating an umbilical Forth as in several models for the PIC and AVR
with limited memory,Maybe this is the way to go, instead of Forth being in
the core!!!
Will post when I have something working
Regards Ian
take a look to my beta version of a propeller forth. today i have released it on the german propeller forum. ttp://propellerforum.sps-welt.de/viewtopic.php?t=91&postdays=0&postorder=asc&start=45·. it is a early beta version.
Happy Forthing··
Oldbitcollector
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Buttons . . . check. Dials . . . check. Switches . . . check. Little colored lights . . . check.
— Calvin, of 'Calvin and Hobbes.
I think I shall do frohf no unjustice when I upload it here.
And don't care for the German... There is not even a German documention at all at the moment
But we shall improve it
Some checks
Implemented words:
Post Edited (deSilva) : 9/25/2007 9:49:50 PM GMT
And this seem be HyperTerminal + SD Pin(0-3)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nothing is impossible, there are only different degrees of difficulty.
Sapieha
Post Edited (Sapieha) : 9/26/2007 10:30:33 AM GMT
Interactive via terminal emulation over the USB(?), 3x faster than Spin, SD file support, ... Great effort and contribution!!!
Is there a name for this version? We already have·Cliff's PropellerForth and hopefully Peter's CogForth. It needs a name so there is no confusion about which implementation we are discussing.
How do I get this Forth to interact with other objects? Reading the German forum it sounds like there is a communication area defined for each forth cog, is there a way to launch code on other Cogs or do I need to recompile the source to do this?
Would it make sense to start a new thread focused on this one implementation to share our findings?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
BioProp: Robotics - Powered by Bioloids and controlled by the Propeller
Are you implying you're an old bastard like me, but not quite brain
dead yet.???
Shows my age watching D.Gilmour live @ the Albert
It is a toss-up however who's older you, me, Mike Green or Sapieha. (Judging by claim, white beard, photo and photo.) I think I've more white than Mike, but maybe not as much as Sapieha. Sapieha has way longer hair, so I am thinking he's also way younger.
Also Oldbitcollector, I seem to recall, has also claimed Geezer-hood or deserves to. It is hard to gauge Graham's age, he may be just polite to fools like me. He does like indoor flight so I am thinking about 55...
I have 57 years
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nothing is impossible, there are only different degrees of difficulty.
Sapieha
Windoze crashed as usual
I'm 54 and bloogy grumpy
The first post was much funnier
Now I'm going back to my Nurse
and my Horlickls
Best Regards All
Ian
Been to Blackburn as well ( it we're shut )
Best concert ever, Heads Up DeSilva
Jethro Tull @ WestFalen Halle in Dortmund
Regards To Alles
Ian