PDA

View Full Version : Propeller Forth



Alex Silva
09-19-2007, 01:25 PM
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?

Peter Jakacki
09-19-2007, 06:35 PM
chotto chotto

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*

hippy
09-19-2007, 07:42 PM
Peter Jakacki said...
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.


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.

deSilva
09-19-2007, 10:13 PM
Good point, hippy!

And I think there will be a FORTH from a "third source" in a few days... Needs still some testing and documentation ...

Alex Silva
09-20-2007, 12:34 AM
I am interested in learning more about how to code my own Forths so I was kind of hoping for some example source code to learn how people tackled various implementations. I don't have any practical applications in mind other than learning how to develop Forths for various architectures. I suppose that using Forth for game projects on my custom built hardware would be my eventual goal.

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 :)

Edit> And apparently some others http://forums.parallax.com/images/smilies/tongue.gif

Fred Hawkins
09-20-2007, 02:40 AM
Alex,

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

mirror
09-20-2007, 04:41 AM
Fred Hawkins said...
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.

I've had a look at Cliff's forth. It's biggest problem is that it's statically linked, and dependent upon his own development environment (PropASM). The target system is the demoboard, but only really because it uses the LED pins and the·serial port (P30, P31) pins.

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.
·

Alex Silva
09-20-2007, 06:34 AM
Thanks for the info Fred. I'll check out those threads. I remember the Large Assembly Model discussions from when it first got started but it has been a long time since I last checked on that.

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 :)

Still the challenges this presents make it interesting so I am not giving up yet.

lnielsen
09-21-2007, 09:07 PM
This thread came at just the right time. I am planning on getting restarted on my Bioloid controller this weekend and I was researching the various options for the programming code. I hit on several possibilities:
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.

Fred Hawkins
09-23-2007, 11:47 PM
(I don't see any point to starting a new thread for this)

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.http://forums.parallax.com/images/smilies/burger.gif· 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 pop a number
(mov SCRATCH, TOP) mov TOP,NEXT rdlong NEXT,HUBSTACK sub HUBSTACK,#4

To push a number

add HUBSTACK,#4 wrlong NEXT,HUBSTACK mov NEXT,TOP mov TOP,SCRATCH

Putting into the ordinary forth of -,+ and -1 (code fragments only.):


' sub: n n - n
sub NEXT, TOP
mov TOP, NEXT
rdlong NEXT,HUBSTACK
sub HUBSTACK,#4

' add: n n - n

add NEXT, TOP
mov TOP, NEXT
rdlong NEXT,HUBSTACK
sub HUBSTACK,#4

' -1: n - n

sub TOP,#1



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.

hubstack >= hublow···· three or more items hubstack = hublow·-4····· two items hubstack = hublow -8····· one item hubstack = hublow -12··· empty stack hubstack = hublow -16··· underflowing

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

Fred Hawkins
09-24-2007, 12:15 AM
simpler for this one:

' add: n n - n

add TOP, NEXT
rdlong NEXT,HUBSTACK
sub HUBSTACK,#4

Mike Green
09-24-2007, 12:59 AM
Given that the instruction set doesn't have indexing and you'd have to do some multi-instruction sequences for direct stack access anyway, it's not much slower to put the stack in HUB memory than to keep it in the COG. It makes a huge difference to keep the top 2 or 3 stack locations in fixed COG locations as you've suggested. There are a number of computer architectures that have done something similar with the top 2 or 3 stack locations in hardware registers and the rest in memory.

Fred Hawkins
09-24-2007, 01:24 AM
Mike,
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

IAN STROME
09-25-2007, 06:01 AM
Hi All,
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

frohf
09-25-2007, 05:53 PM
Hi folks,

take a look to my beta version of a propeller forth. today i have released it on the german propeller forum. http://forums.parallax.com/images/smilies/hop.gif ttp://propellerforum.sps-welt.de/viewtopic.php?t=91&postdays=0&postorder=asc&start=45 (http://propellerforum.sps-welt.de/viewtopic.php?t=91&postdays=0&postorder=asc&start=45)·. it is a early beta version.

Happy Forthing··http://forums.parallax.com/images/smilies/cool.gif

frohf
09-25-2007, 05:58 PM
perhaps it is mentionable my forth is 3 times faster as an spin programm·

Fred Hawkins
09-25-2007, 09:49 PM
frohf said...

Hi folks,

take a look to my beta version of a propeller forth. today i have released it on the german propeller forum. http://forums.parallax.com/images/smilies/hop.gif ttp://propellerforum.sps-welt.de/viewtopic.php?t=91&postdays=0&postorder=asc&start=45 (http://propellerforum.sps-welt.de/viewtopic.php?t=91&postdays=0&postorder=asc&start=45)·. it is a early beta version.

Happy Forthing··http://forums.parallax.com/images/smilies/cool.gif


Released where? I see notes for words and so on, but no beta version.·

Oldbitcollector (Jeff)
09-26-2007, 12:00 AM
German forum is an interesting read... Babelfish does a good job with it.

Oldbitcollector

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Buttons . . . check. Dials . . . check. Switches . . . check. Little colored lights . . . check.

— Calvin, of 'Calvin and Hobbes.

deSilva
09-26-2007, 04:35 AM
Well this forum has the naughty feature that you need to log-in before you even SEE the uploads http://forums.parallax.com/images/smilies/smile.gif

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 http://forums.parallax.com/images/smilies/smile.gif http://forums.parallax.com/images/smilies/smile.gif

But we shall improve it http://forums.parallax.com/images/smilies/smile.gif http://forums.parallax.com/images/smilies/smile.gif http://forums.parallax.com/images/smilies/smile.gif


Some checks


: FAK DUP 0 = IF DROP 1 EXIT THEN DUP 1- RECURSE * ;
9 FAK . should yield 362,880

: FIB DUP 2 < IF EXIT THEN 1- DUP RECURSE SWAP 1- RECURSE + ;
27 FIB . should yield 196418 after 3.5 seconds



Implemented words:


inside the COG:

BYE DOCOL DOLIT_B DOLIT_W DOLIT_L EXECUTE LNEXT
QBRANCH BRANCH EXITZERO EXIT JNEXT CLEARD CLEARR
DUP DROP SWAP OVER SPFETCH SPSTORE RPSTORE RPFETCH
RPSP CPYRPSP SPRP COGSTORE LSTORE CSTORE STORE
COGFETCH LFETCH CFETCH FETCH ONESUB ONEADD TWOSUB
TWOADD TWO ONE ZERO ADD SUBB TESTNEG ABS INVERT
OR AND XOR DIV SETTICKS GETTICKS WAITPEQ WAITPNE
WAITVID WAITTICKS HUPOP XTRUE XFALSE MUL _DIRA
_INA _OUTA NOT DOVAR UMADD CELLADD CELLSUB QDUP


complete vocabulary:

ROT 2DROP 2DUP SUB - = < EMIT ?KEY U< MAX
MIN WITHIN +! ALIGNED MOD / CELLS BL >CHAR DEPTH
PICK COUNT HERE PAD TIB @EXECUTE CMOVE FILL
ERASE PACK$ DIGIT EXTRACT <# HOLD # #S SIGN
#> str HEX DECIMAL DIGIT? NUMBER? KEY NUF? SPACE
SPACES TYPE CR do$ $"| ."| .R U.R U. . ? parse PARSE
.( ( \ WORD TOKEN NAME> SAME? find NAME? ^H TAP
kTAP accept QUERY PRESET ABORT abort" $INTERPRET [ .OK
?STACK EVAL QUIT ' ALLOT , [COMPILE] COMPILE LITERAL
$," RECURSE FOR BEGIN NEXT UNTIL AGAIN IF AHEAD
REPEAT THEN AFT ELSE WHILE ABORT" $" ." ?UNIQUE
$,n $COMPILE OVERT ; ] : IMMEDIATE CREATE VARIABLE
_TYPE dm+ DUMP .S >NAME .ID SEE WORDS hi START
TIME MEMFREE BOOT

Post Edited (deSilva) : 9/25/2007 9:49:50 PM GMT

Fred Hawkins
09-26-2007, 06:21 AM
target system?

Sapieha
09-26-2007, 06:26 AM
I run it in Gear.

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

lnielsen
09-27-2007, 01:26 AM
I·hope to have time to·try frohf's new forth this evening. Here are some early questions and comments...

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 (http://www.wideopenwest.com/~lnielsen/BioProp/)

Alex Silva
09-27-2007, 02:08 AM
Clearly it should be called frohForth http://forums.parallax.com/images/smilies/smilewinkgrin.gif

Fred Hawkins
09-27-2007, 02:22 AM
Shoot. So much for Fred's Forth aka FF. I am now laying claim to GeezerForth.

IAN STROME
09-27-2007, 02:33 AM
Nice point Fred
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

Fred Hawkins
09-27-2007, 02:46 AM
All I know about the Albert is that there's lots of holes there. I think. Maybe I misremember that particular day in my life.

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...

Sapieha
09-27-2007, 02:58 AM
Hi Fred.

I have 57 years

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nothing is impossible, there are only different degrees of difficulty.

Sapieha

IAN STROME
09-27-2007, 04:19 AM
Sorry About That
Windoze crashed as usual
I'm 54 and bloogy grumpy

IAN STROME
09-27-2007, 04:32 AM
Before windoze crashed
The first post was much funnier
Now I'm going back to my Nurse
and my Horlickls

Best Regards All

Ian

Fred Hawkins
09-27-2007, 04:52 AM
Humph! Mere youths. (By a couple months at least. 58.5 -- things go faster now, don't they?)

IAN STROME
09-27-2007, 07:42 AM
Yes Fred
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

Fred Hawkins
09-27-2007, 07:58 AM
:) saw Tull in Berlin once -- we pushed back the second tier curtain and sat in front of it: instant private box on stage right. Best seats in my entire life. (Also in Berlin: Zappa and, no kidding, Grand Funk RR) Got pushed to 1600 asa color slides (very yellow, reciprocity failure) as proof. God knows what the music was like. The Zappa slides are still fun to look at; probably colletors items somewhere.

Graham Stabler
09-27-2007, 08:02 AM
55, I'm 29 and that's cutting edge micro indoor flying to you! ;)

Graham

p.s. its also my job

mirror
09-27-2007, 08:06 AM
Graham Stabler said...
55, I'm 29 and that's cutting edge micro indoor flying to you! ;)

Graham

p.s. its also my job
Aaaah! So your avatar is NOT something you found lurking in your code!

Fred Hawkins
09-27-2007, 08:51 AM
(uh oh. Does he remember rubber powered flight? Penny planes? Bostonians?)

No matter. There's always more dough in cutting edge anyways.

IAN STROME
09-27-2007, 10:22 AM
Like it Fred,
In Dortmund they played the Dambusters march
You can imagine how well that went down

frohf
09-27-2007, 01:08 PM
The name of the Forth System is FPForth. The version is 0.69 and it runs on the Propeller Protoboard.
You need only a terminal programm·to test it.


Inielsen said...
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?

This feature commes next week.·Saving·in eeprom also. In a couple of weeks i finished a IDE with Simulator, Debugger, Terminal and Editor.

At the momment i wrote a dokumentation and deSilva will kindly translate it.

P.S. I am 45 Years Old http://forums.parallax.com/images/smilies/smilewinkgrin.gif

Graham Stabler
09-27-2007, 04:05 PM
Fred, I made this and its rubber powered:

http://www.indoor.flyer.co.uk/chipstick.htm

My avatar is essentially what I am trying to build in my job only just a little bit larger.

Graham

Ym2413a
09-27-2007, 04:43 PM
Graham Stabler said...
Fred, I made this and its rubber powered:

http://www.indoor.flyer.co.uk/chipstick.htm

My avatar is essentially what I am trying to build in my job only just a little bit larger.

Graham

"Not to be off topic from forth but..."

Wow, those are some neat little machines you got there. :)