Shop OBEX P1 Docs P2 Docs Learn Events
Catalina: From C to shining C ... - Page 2 — Parallax Forums

Catalina: From C to shining C ...

2»

Comments

  • RossHRossH Posts: 5,519
    edited 2010-06-21 23:55
    @jazzed,

    Compatibility with gcc is not the same as C99 compliance - gcc is not itself C99 compliant (there are in fact very few compilers that are - en.wikipedia.org/wiki/C99 mentions only one).

    Catalina could be made C99 compliant if required (I understand this has already been done for some of the other compilers based on LCC). However, this would not help with compiling Arduino code if that code depends on any of the non-standard extensions to ANSI C implemented by gcc.

    Catalina already includes some C99 libraries (stdint.h, stdtype.h), and others could be added if required. However, the cost of adding full C99 compliance to LCC (there are some subtle internal language changes) would be high, and the benefits would be minimal.

    Ross.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Catalina - a FREE C compiler for the Propeller - see Catalina
  • jazzedjazzed Posts: 11,803
    edited 2010-06-22 00:28
    RossH said...
    Compatibility with gcc is not the same as C99 compliance - gcc is not itself C99 compliant (there are in fact very few compilers that are - en.wikipedia.org/wiki/C99 mentions only one).
    Sure Ross. It may as well be the same though, but I know there's not much point in discussing it. Still, it is worth bringing up for the uneducated to know about the issue. I believe Catalina has a place in the Propeller universe and on other micros as there are many who insist only on pure C89. There are also many who insist on the GNU tool-chain for the vast ocean of code where C89 simply fails to compile.

    Cheers.
    --Steve

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Pages: Propeller JVM
  • RossHRossH Posts: 5,519
    edited 2010-06-22 04:19
    @Dave,

    Thanks for the sugestions - serveral of them I already have plans to do, the others I'll take on board. However I have some comments on your last suggestion:
    Dave Hein said...

    - I would like to see a "cog" target. I.e., code that runs entirely within a cog with register variables and hub ram access.
    This has been suggested several times - while I can see the attraction of it (e.g. for writing drivers in C) it's not really practical with Catalina, for the following reasons:
    • The cost is very high (a completely new LCC code generator, which is not a trivial task) and so are the limitations you would need to impose on the code (e.g. no library calls, no debugger support, no plugin support, etc, etc).
    • Also, you would have no floating point, no integer multiply or divide - in fact, I'm not even sure you could implement function calls (no stack!). All these things are currently implemented (at least partially) using various "primitives" (i.e. PASM subroutines) within the LMM kernel.
    • If you needed all the current kernel primitives (which after all are only there to support various things required to execute C code which are not implemented as simple PASM instuctions) you end up with only around a hundred longs for your compiled code.
    • Also, consider the extraordinary lengths you would have to go to to support structures, arrays and pointers (e.g. how do you deal with a char pointer when a cog only has long addressing?).
    In the end, I think you would find you went to all this effort to be able to execute no more than a page or so of very limited C code.

    I'm not saying this is not doable - but I am saying that if I wanted to do this, I would not start with Catalina (or even LCC) - I would instead start with something like the "Tiny C" compiler (bellard.org/tcc/) and target only a small subset of the C language that could generate useful results within 496 instructions (i.e. no floating point, no structures, only long arrays etc). You could then use this program to generate binaries that can be loaded in a cog from either a SPIN programs or Catalina programs.

    Any volunteers?

    Ross.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Catalina - a FREE C compiler for the Propeller - see Catalina

    Post Edited (RossH) : 6/22/2010 4:25:35 AM GMT
  • Bill HenningBill Henning Posts: 6,445
    edited 2010-06-22 13:21
    I totally agree with Ross - a code generator for standard PASM is not worth the bother, at least not with the current levels of market penetration.

    One of the biggest advantages of the Prop over other architectures is the 20MIPS (except for hub ops etc) deterministic architecture, and a compiler removes much of that determinism.

    With the limited size of cog memory, anyone who wants to write high-performance code should use PASM.

    Having said that, a full macro assembler would definitely be a major asset; I can't tell you guys how tired I am of manually unrolling loops! Using macros for enhanced pseudo-instructions would also be useful. Unfortunately I have not yet had time to finish the macro features of LAS.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.mikronauts.com E-mail: mikronauts _at_ gmail _dot_ com
    My products: Morpheus / Mem+ / PropCade / FlexMem / VMCOG / Propteus / Proteus / SerPlug
    and 6.250MHz Crystals to run Propellers at 100MHz & 5.0" OEM TFT VGA LCD modules
    Las - Large model assembler Largos - upcoming nano operating system
  • Dave HeinDave Hein Posts: 6,347
    edited 2010-06-22 13:25
    Ross,

    My main interest for a cog target would be to write drivers in a high level language.· I have written a few drivers, but they had to be written in PASM, which is very tedious and difficult to maintain.· It seems like the next-best choice for writing high-level drivers would be PropBasic, but I would prefer to use C.· I'll look into Tiny C, that might be a good alternative.

    Thanks,
    Dave

    Edit:· I looked at Tiny C, and it doesn't look very tiny to me.· If fact, it looks like a very full-featured C compiler.· I also looked into PropBasic.· This is probably the closest thing available to what I want at this point.· It's not a super high level language, but at least it's higher than PASM.· I agree with Bill.· It would be nice to have a real macro assembler.

    Post Edited (Dave Hein) : 6/22/2010 7:25:39 PM GMT
  • RossHRossH Posts: 5,519
    edited 2010-06-23 01:06
    Hi Dave,

    You are looking at the current "Tiny C" compiler, which is full-blown C.

    I meant to use the original "Tiny C" compiler, which compiles only a small subset of C, but is only 632 lines long (attached). This compiler is so small it could probably run in a cog itself!

    Ross.

    EDIT: I should point out I have not actually compiled or run this code!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Catalina - a FREE C compiler for the Propeller - see Catalina
  • RossHRossH Posts: 5,519
    edited 2010-06-24 00:49
    @All,

    It seems there is insufficient interest in these forums to justify a professional version of Catalina at present, so after some further thought (and some offline discussions and various requests) I have decided that there WILL be a release 2.6 of Catalina. This release will contain the multi-cog C capability demonstrated in this thread.

    I have decided to do do this for two reasons - first, because it was requested by a few of the people who have supported Catalina in the past (with contributions of hardware or software) and second, because there have been a few recent changes to the code generator and the kernel that will be required to support some of the functionality which I have already partially implemented, but which I have decided will NOT be included in release 2.6 - such as:
    • A code optimizer (currently reduces code size and increases performance by between 10% and 20%, but I expect to do better than this before it is finished)
    • debugger support for C running on multiple cogs (the free version will only be able to debug the cog running the C main function)
    • cog safe versions of the standard C libraries (the free version will require that you use locks around some library calls - such as malloc - which are not reentrant)
    The reason for excluding the above functionality from release 2.6 is that I have also changed my mind about having both a "free" and a "professional" version of Catalina. Instead of charging for a separate version, or charging for support and ad-hoc feature requests of the free version (as suggested by Bill), I have decided that Catalina itself will remain entirely free, but I will charge for all future enhancements - which will appear as and when I get time to finish them. This will include:
    • The code optimizer and enhanced debugger support mentioned above
    • A Catalina-specific Code::Blocks plugin
    • New device drivers and plugins
    • New libraries, or enhanced versions of the existing libraries (e.g. reentrant or "cog safe" versions)
    • Any new non-trivial targets (particularly those requiring XMM support)
    Of course, others are also free to develop such things (and charge for them or not as they see fit). I think you will agree that this is a better approach given the kind of cooperative development fostered so successfully by Parallax in these forums.

    Ross.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Catalina - a FREE C compiler for the Propeller - see Catalina

    Post Edited (RossH) : 6/24/2010 2:37:55 AM GMT
  • RossHRossH Posts: 5,519
    edited 2010-07-01 13:17
    @All,

    Catalina 2.6 (containing the multicog C capability discussed in this thread) has now been released - see the main Catalina thread here for details.

    Ross.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Catalina - a FREE C compiler for the Propeller - see Catalina
  • Cluso99Cluso99 Posts: 18,069
    edited 2010-07-02 01:11
    RossH: Nice work. I do hope you can recover something towards your work.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
    · Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
    · Prop Tools under Development or Completed (Index)
    · Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)·
    · Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
    My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz
Sign In or Register to comment.