Shop OBEX P1 Docs P2 Docs Learn Events
C Compiler for the Propeller .. is there one out there ?? — Parallax Forums

C Compiler for the Propeller .. is there one out there ??

OzStampOzStamp Posts: 377
edited 2007-02-04 15:27 in Propeller 1
Hi All

A common question we get from our customer base here in Australia.

Is there a C Compiler for the Propeller ?
Is somebody working on one ?
I have not seen any posts re this issue..

Ronald Nollet
Australia
·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-02-04 06:38
    I read most posts on the Propeller forum and, although I've seen the same question asked several times, I've not heard of any available nor am I aware of anyone working on one although it would be relatively easy to translate C to Spin. I think a C compiler for the native instruction set would be very hard given the limited memory space in the cogs. One of the reasons Bill Henning developed a large memory model for assembly code was to make such a compiler practical with assembly code essentially running out of Hub memory (with a little speed penalty). No one seems to have had the time to take this further. Cliff Biffle has been working on a Forth system, but I'm not sure where he is on this.
  • Bill HenningBill Henning Posts: 6,445
    edited 2007-02-04 07:59
    Mike is correct; a C compiler would be difficult for the normal Cog programming model - and thus I cooked up the "large model" approach.

    Fortunately(?) I've been too busy with consulting to work much with the propeller; I sneak a few hours in here and there... but until the consulting gig I've got right now in addition to my regular job is done, my time is very limited. I'm in the "building the tools to build the tools to build the software" stage right now. Once·my infrastructure·hits "critical mass" watch out!

    A C compiler would have the following difficulties targeting a Cog:

    - no return stack

    - Cog memory is not byte addressable

    - no indexed addressing

    - VERY limited ammount of memory in a Cog

    My large model fixes all of those issues, and given sufficient time, I'd love to port a C compiler to it - however there are a number of intervening steps:

    - Chip kindly modified the IDE to add 'ORGX' to help with writing large model assembly code; and while it helped, it only whetted my appetite

    - I've started writing a 'large model' macro assembler, I'd say its about 80% complete; it can actually assemble all the Cog instructions now, I do have to verify the bit patterns [noparse]:)[/noparse] add the macro capability, write a linker etc

    - the assembler will support three models: small (standard Cog code - needed to support video drivers etc),·my large model, and·the large model with multi-threading·in each cog - which places further restrictions on the code.

    Ofcourse, as I was writing this it became obvious that I'd need to write some system libraries; I've already designed the memory manager, and it· accomodates up to 256k of HUB memory (for future propellers)

    Then I realized that for best effect, Spin should not manage the memory allocation... so the initial eeprom image is a basically a null Spin program that loads (high) the system library and turns over control to a large model multi-threaded "supervisor" cog that will provide a VERY minimal set of system services: malloc/free, spawn, kill,·two I/O handles per process (stdin, stdout) and a shared stderr (all threads share ONE stderr to save memory), putchar, getchar and ioctl, and a·VERY simple messaging api (send & recv)·(you may note a certain Unix flavour in this paragraph... I may even support fork() to spawn threads within a cog)

    Also, like several others, I've been looking into making a memory expander... with a very slight additional performance hit I can make a large model kernel that would support position independent code... and even swapping; and given the number of pins involved, that led me to look into I/O expanders - thus I've been gearing up on SX's.

    Basically I opened up Pandora's Box when I came up with the large model.

    To top it off, I REALLY want to figure out how to run Spin processes under this scheme!

    Now as Mike mentions, it would be quite feasible to target a C compiler to generate Spin byte codes; frankly I'd love to see such a compiler!

    Mike's OS with fetmobasic is already a cool incredibly cheap computer for introducing people to programming; with its SD support if it had a C compiler that generated spin code... the possibilities!!!

    It should also be quite possible to target Cliff's Forth engine with a C compiler.
    Mike Green said...
    I read most posts on the Propeller forum and, although I've seen the same question asked several times, I've not heard of any available nor am I aware of anyone working on one although it would be relatively easy to translate C to Spin. I think a C compiler for the native instruction set would be very hard given the limited memory space in the cogs. One of the reasons Bill Henning developed a large memory model for assembly code was to make such a compiler practical with assembly code essentially running out of Hub memory (with a little speed penalty). No one seems to have had the time to take this further. Cliff Biffle has been working on a Forth system, but I'm not sure where he is on this.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.mikronauts.com - a new blog about microcontrollers

    Post Edited (Bill Henning) : 2/4/2007 8:10:12 AM GMT
  • JoannaKJoannaK Posts: 44
    edited 2007-02-04 08:40
    Way I see it ... Propeller ain't intented to use C-code so it will be quite difficult to make it native cog running and this 'large memory model' reminds me too mush about Segments, Extended/expenaded memories and other uglies.

    IMHO it might be smart to make C-to-Spin source level translator first.. It should work with decent speed (not much slower than similar code in spin) and be a lot easier to debug and test than these other alternatives.. After that, it migh be feasible to bypass spin compiler and write directly to Spin.bytecode.
  • GavinGavin Posts: 134
    edited 2007-02-04 09:50
    Did a quick google on C compilers for parallel CPUs
    IBM and Intel have them, use Pragmas for Multiprocessing
    GCC has something http://www.intrepid.com/upc.html
    Not about to get a full C compler for the Prop?
    But again each cog is a simple 32 bit risc micro so maybe it would be easy to do?
    Well easy for Compiler experts[noparse]:)[/noparse]
    Guess I should sit down and spend some real time on GCC.
    Just downloaded it and had a quick look, guess I need to look at Prop assembly to see which micro it is closest too.
    Anyone got any links on how to port GCC?

    Gavin
  • inserviinservi Posts: 113
    edited 2007-02-04 10:38
    Hello,

    I'm also waiting for a C compiler for the Propeller. Or at least some enhancement for the SPIN language.

    Some enhancement as (by order preferences) :

    - macro (so easy to implementing)
    - type definition
    - bit type
    - pre-processor
    - multi-dimensional array
    - structure
    - record
    - ...

    And also a more 'standard' syntaxe as for example: '>=' at the place of '=>'

    For the rest, SPIN is a very good language easy to learn and with a lot of quality !!!


    Best regards,
    dro

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    in medio virtus

    Post Edited (inservi) : 2/4/2007 10:45:07 AM GMT
  • bassmasterbassmaster Posts: 181
    edited 2007-02-04 14:12
    I find that spin is just as easy as C and the IDE is very good for its young age, If you know C or any language, Spin is a walk in the park, why reinvent the wheel? If its for cross/platform e.g. unix or BSD, then use wine and the downloader python that is here. If you want simplicity, then spin is great.

    I was the first guy to write a linux pbasic compiler/downloader for linux on 03/2003 using the parallax library, soon after it was released.

    www.sourceforge.net/projects/linstamp/


    My advice is that when you want something that does not exist, challenge yourself to make it like I did. Later other people made better linux apps, but mine worked for me.

    The cool thing about Sourceforge is that you can create a project that other developers can work together. You can administer it, break the project into managable portions, and soon it will be complete.

    I will be happy to be assigned some of the work if someone wants to start the project. I have 10 years of C experience and C could be used to make a nice C to prop spin/assembler.
  • bassmasterbassmaster Posts: 181
    edited 2007-02-04 14:38
    here:
    attachment.php?attachmentid=73722
    www.sourceforge.net/projects/propc


    Its awaiting approval from sourceforge staff... should take a few days to a few weeks. then Ill create the CVS repository for it. Meanwhile I'll administer the project and email me your spippets, design idea's or anything you want to be made public for this GNU project.

    attachment.php?attachmentid=73723

    Post Edited (bassmaster) : 2/4/2007 2:45:04 PM GMT
    674 x 77 - 5K
    780 x 331 - 17K
  • bassmasterbassmaster Posts: 181
    edited 2007-02-04 14:59
    I moved the·C Compiler Sorceforge project to new thread:

    http://forums.parallax.com/showthread.php?p=629928


    Post Edited (bassmaster) : 2/4/2007 3:37:14 PM GMT
  • scottascotta Posts: 168
    edited 2007-02-04 15:27
    I would like C-like macros for assembler.

    What if the IDE used plug-ins, this could allow all kinds of useful tools.
Sign In or Register to comment.