Shop OBEX P1 Docs P2 Docs Learn Events
New Product (almost) - Forth to Spin compiler — Parallax Forums

New Product (almost) - Forth to Spin compiler

Carl JacobsCarl Jacobs Posts: 41
edited 2008-07-26 11:19 in Propeller 1
Hello,

My name is Carl Jacobs. I've been using the Parallax Propeller for about 18 months, and have enjoyed my time using it. Late last year I developed the hardware for a new product - a data aquisition device - but got a bit stuck with the firmware. Spin code was the right size but too slow, and PASM was fast but difficult to get all the functionality required. And I had no more·cogs left!

The rest of this posting is a shameless add!!

In January of this year I started work on a Forth compiler. It has been a long slow process, and I almost gave up the development when ImageCraft released their C compiler. However, I couldn't bring myself to losing access to Spin and the resourceful Object Exchange.

The product is now very close to being ready for an initial release. I would have waited a little longer before sharing this information except that I got a really great result during testing! It is with great pride (the same sort of pride as that of the father of a new born baby) that I announce the results of my Fibonacci test. I had been doing my testing using GEAR but have started using·real hardware.

GEAR has very·optimistic timing for spin opcodes, with the result being that my Forth interpreter was·FIVE TIMES faster than expected! I've attched FibTest.spin and FibDemo.spin for all those who want to run the test for themselves, but the short summary is as follows:
1) A Spin version·of Fib(28) : 28.69 seconds
2) A pure Forth variation of Fib(28) : 6.48 seconds
3) A Forth + kernel helper word variation of Fib(28) : 2.78 seconds
4) A pure kernel variation of FIb(28) : 0.86 seconds

Full details of the Fibonacci test, and a teaser for·JDForth can be found at:
http://www.jacobsdesign.com.au/software/jdforth/jdforth.php

Special features of JDForth:
1) This is not a Forth interpreter. It is a Forth compiler.
2) The output of the compiler is a spin object file, just like any other spin object file. It uses 1 cog per object, but that cog may be stopped if the object is not required.
3) Because the output is a spin object file, it may be instantiated multiple times - like any other spin object file.
4) Multiple different Forth kernels may be run on a single Propeller at the same time!

Spin is still in control - but JDForth might be the best helper you can find.


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Carl Jacobs




Post Edited (Carl Jacobs) : 7/17/2008 3:38:10 AM GMT

Comments

  • JoannaKJoannaK Posts: 44
    edited 2008-07-17 09:45
    Sounds interesting..
  • PraxisPraxis Posts: 333
    edited 2008-07-17 10:53
    Hi Carl,

    Nice work, keep it up.

    Cheers
  • hippyhippy Posts: 1,981
    edited 2008-07-17 13:03
    Looks very good and prices seem okay; 90AUD is approx, 88USD, 55EUR, 44GBP.

    Will there be a 'try before you buy' or free, restricted demo version ? This could be just what it needs to get people tempted to try Forth, rather than just shudder and think it's not for them.
  • Carl JacobsCarl Jacobs Posts: 41
    edited 2008-07-20 21:46
    Hello hippy,

    Thanks for the price translation...

    I'll definitely think about a "try before you buy" option to the standard version of the tool.

    I'm also planning a "light" version of the tool which is aimed directly at those who want to get a feel for the product and forth without spending too many dollars/pounds/euros.

    I have a small mountain of work to do before the initial release, so I best get on with it! I'll put up another post once the product is released.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Carl Jacobs


    ·
  • jazzedjazzed Posts: 11,803
    edited 2008-07-20 22:03
    If I cared to try learning forth, is there a free simulator available somewhere?
    Obviously forth was not my fourth computer language [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • Mike GreenMike Green Posts: 23,101
    edited 2008-07-20 22:46
    There are many free implementations available. One that's available for Windows and the MacOS as well as Linux is pForth (portable Forth) www.softsynth.com/pforth/.

    This website has links to the source archive (it's written in ANS C) which includes a Windows executable. For the MacOS, you can get it via Fink. It can also be compiled for Linux.
  • Carl JacobsCarl Jacobs Posts: 41
    edited 2008-07-21 22:55
    Thanks for those pointers Mike! When I get some time I'll put a links page on my web site to some Forth resources. I don't have the resources or the special skill that Leo Brodie has to teach Forth, but I will be assisting with the quirks of JDForth once it's released.

    I've decided to attach another teaser - this one will be useful even if you never use JDForth.

    The attched code adds three routines - written in JDForth - that can be used just like any other spin object:

    1) 32 bit x 32 bit with a full 64 bit result. (All signed integers)
    2) 32 bit x 32 bit divided by 32 bit with a 32 bit result. (All signed integers) The intermediate result after·the multiplication is a·64 bit value.
    3) Same as 2 but returning the 32 bit modulus of the result as well.

    I've included the JDForth source file, the generated spin file, as well as a test harness file to show you how to use these functions.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Carl Jacobs
  • Carl JacobsCarl Jacobs Posts: 41
    edited 2008-07-26 11:19
    It's getting real close to the release of JDForth now.

    I'm down to just 3 jobs on the joblist:
    1. Finish the help file! But seriously, I'm not going to let this one stop the product from being released - othwerwise it will never see the light of day!
    2. Do the installer stuff.
    3. Show a sensible result when there's an error in the inline assembly language.
    Number 3 is a bit tricky, and could have been made MUCH simpler if the Propellent DLL had a slightly different error structure for CompileSource.
    What it currently returns on error
    PChar SourceFile
    LongWord SrcStart
    LongWord SrcCount
    PChar ErrorString

    What would have been easier to use
    PChar SourceFile
    LongWord LineNumber
    LongWord ColumnStart
    LongWord ColumnEnd····· - I could even live without this one!
    PChar ErrorString

    If that was done, then the Propellent documentation wouldn't need a huge disclaimer about ANSI encoding,· UTF encoding and end-of-lines. At the moment it's·making my head hurt!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Carl Jacobs


    ·
Sign In or Register to comment.