Shop OBEX P1 Docs P2 Docs Learn Events
Propeller Forth — Parallax Forums

Propeller Forth

Alex SilvaAlex Silva Posts: 10
edited 2007-09-27 09:43 in Propeller 1
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?
«1

Comments

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2007-09-19 11:35
    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*
  • hippyhippy Posts: 1,981
    edited 2007-09-19 12:42
    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.
  • deSilvadeSilva Posts: 2,967
    edited 2007-09-19 15:13
    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 SilvaAlex Silva Posts: 10
    edited 2007-09-19 17:34
    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 [noparse]:)[/noparse]

    Edit> And apparently some others tongue.gif
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2007-09-19 19:40
    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
  • mirrormirror Posts: 322
    edited 2007-09-19 21:41
    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 SilvaAlex Silva Posts: 10
    edited 2007-09-19 23:34
    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 [noparse]:)[/noparse]

    Still the challenges this presents make it interesting so I am not giving up yet.
  • lnielsenlnielsen Posts: 72
    edited 2007-09-21 14:07
    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 HawkinsFred Hawkins Posts: 997
    edited 2007-09-23 16:47
    (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.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
    1. (mov SCRATCH, TOP)
    2. mov TOP,NEXT
    3. rdlong NEXT,HUBSTACK
    4. sub HUBSTACK,#4

    To push a number
    1. add HUBSTACK,#4
    2. wrlong NEXT,HUBSTACK
    3. mov NEXT,TOP
    4. 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.
    1. hubstack >= hublow···· three or more items
    2. hubstack = hublow·-4····· two items
    3. hubstack = hublow -8····· one item
    4. hubstack = hublow -12··· empty stack
    5. 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 HawkinsFred Hawkins Posts: 997
    edited 2007-09-23 17:15
    simpler for this one:

    ' add: n n - n

    add TOP, NEXT
    rdlong NEXT,HUBSTACK
    sub HUBSTACK,#4
  • Mike GreenMike Green Posts: 23,101
    edited 2007-09-23 17:59
    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 HawkinsFred Hawkins Posts: 997
    edited 2007-09-23 18:24
    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 STROMEIAN STROME Posts: 49
    edited 2007-09-24 23:01
    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
  • frohffrohf Posts: 3
    edited 2007-09-25 10:53
    Hi folks,

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

    Happy Forthing··cool.gif
  • frohffrohf Posts: 3
    edited 2007-09-25 10:58
    perhaps it is mentionable my forth is 3 times faster as an spin programm·
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2007-09-25 14:49
    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. hop.gifttp://propellerforum.sps-welt.de/viewtopic.php?t=91&postdays=0&postorder=asc&start=45·. it is a early beta version.

    Happy Forthing··cool.gif

    Released where? I see notes for words and so on, but no beta version.·
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2007-09-25 17:00
    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.
  • deSilvadeSilva Posts: 2,967
    edited 2007-09-25 21:35
    Well this forum has the naughty feature that you need to log-in before you even SEE the uploads 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 smile.gifsmile.gif

    But we shall improve it smile.gifsmile.gifsmile.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  [noparse][[/noparse]  .OK
    ?STACK  EVAL  QUIT  '  ALLOT  ,  [noparse][[/noparse]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 HawkinsFred Hawkins Posts: 997
    edited 2007-09-25 23:21
    target system?
  • SapiehaSapieha Posts: 2,964
    edited 2007-09-25 23:26
    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
  • lnielsenlnielsen Posts: 72
    edited 2007-09-26 18:26
    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
  • Alex SilvaAlex Silva Posts: 10
    edited 2007-09-26 19:08
    Clearly it should be called frohForth smilewinkgrin.gif
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2007-09-26 19:22
    Shoot. So much for Fred's Forth aka FF. I am now laying claim to GeezerForth.
  • IAN STROMEIAN STROME Posts: 49
    edited 2007-09-26 19:33
    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 HawkinsFred Hawkins Posts: 997
    edited 2007-09-26 19:46
    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...
  • SapiehaSapieha Posts: 2,964
    edited 2007-09-26 19:58
    Hi Fred.

    I have 57 years

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

    Sapieha
  • IAN STROMEIAN STROME Posts: 49
    edited 2007-09-26 21:19
    Sorry About That
    Windoze crashed as usual
    I'm 54 and bloogy grumpy
  • IAN STROMEIAN STROME Posts: 49
    edited 2007-09-26 21:32
    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 HawkinsFred Hawkins Posts: 997
    edited 2007-09-26 21:52
    Humph! Mere youths. (By a couple months at least. 58.5 -- things go faster now, don't they?)
  • IAN STROMEIAN STROME Posts: 49
    edited 2007-09-27 00:42
    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
Sign In or Register to comment.