I want to start using C for P1. Where do I start?
AwesomeCronk
Posts: 1,055
in Propeller 1
I have had a hard time trying to work with spin. I guess the general structure is so different that I can't stick to it. I am wanting to try C for P1, but I have no idea where to start. I remember that ersmith's IDE had access to a multi language compiler and I would like to use that compiler, but I have forgotten where to get his IDE. The other thing I would like to know is where I can find a few PropC tutorials.
Comments
I see more resources (overall) for prop c than spin.
https://learn.parallax.com/tutorials/language/propeller-c
They use simpleIDE. I also use simpleIDE for spin.
I use simpleIDE to test out prop c programs, figure out how they work, and convert them to spin.
https://learn.parallax.com/tutorials/language/propeller-c/propeller-c-set-simpleide/update-your-learn-folder
You can see all the learn folder examples online also.
https://github.com/parallaxinc/Simple-Libraries/tree/master/Learn
Also if you look at the libraries...
https://github.com/parallaxinc/Simple-Libraries/tree/master/Learn/Simple Libraries
You will see that each library folder has a HTML file for documentation, AND a SIDE file (for use with simpleIDE) so you can see an example on how to use that library.
I wish they would convert the examples and the libraries to spin versions. (especially the library and its html help files)
Not to put you off considering C or anything else, but if you can't master something as simple as Spin, how are you going to fare with C?
—▷ https://github.com/totalspectrum/flexprop
There are some examples...
—▷ https://github.com/totalspectrum/flexprop/tree/master/samples
...but I don't know of a FlexC specific tutorial. Maybe digging in the compiler's doc directory is a start?
—▷ https://github.com/totalspectrum/spin2cpp/tree/master/doc
Some FastSpin examples hide in...
—▷ https://forums.parallax.com/discussion/169141/testing-the-new-fastspin-assembly-spin-basic-and-c-for-p1/p1
...and in my signature but that messy heap of snippets hasn't been updated for a while.
Of course he should. But why do you want the lad to try flying a plane he probably knows of from the movies?
(A Catalina is in fact a PBY, a B24 on an amphib 's body and was the best answer to a difficult problem.)
Well, if we're going to be snarky then if he's serious about C he should use a C compiler that's not 30 years out of date and he should use a command line like "real" C programmers do. So PropGCC is the only serious choice for him on P1. On P2 he's got LLVM and riscvp2 to choose from as "serious" choices.
For a non-snarky answer, any of Catalina, FlexProp, and SimpleIDE will let you try out C programming on the Propeller. They all have their strengths and weaknesses, and it's worth trying all of them. Catalina is probably the easiest to use and has a debugger, but it's limited to C89 and produces slow code. SimpleIDE has good documentation from Parallax and much better performance than Catalina, but it's not really supported any more. FlexProp is somewhere in-between performance wise and has easy integration with Spin and BASIC, but it's based on a custom compiler and hence buggier than the others.
C isn't a particularly good choice for the P1 given the limited memory, but it does work very well on P2.
I do love the command line. Pray tell, does PropGCC compile spin and c or just c? (I need to be able to use the nrf24l01 object in the obex.) I’m going to take a crack at flexProp first of all.
PropGCC handles only C and C++. There is a command line tool called spin2cpp that's basically the same compiler as flexspin and can convert Spin to C It's located at https://github.com/totalspectrum/spin2cpp. But if you're mixing Spin and C then I think FlexProp will be the easiest tool for you. The command line C compiler is "flexcc" and is found in the "bin" directory of the FlexProp distribution. You can also use "flexspin", that has openspin like command line arguments rather than C style ones, but all of the FlexProp tools can handle all of the languages.
The other compilers are good, but the don't have a library function and don't have the extensive libraries that support all of the Parallax products they sell.
In SimpleIDE you just add the library that contains the product you want to interface into and use those functions to address it. You don't have to know how it does it but if you want you can look at the source code for all the libraries and build your own. Each library function is also documented to tell you what functions are available and how to use them.
In most cases I build my own library function and then just use it in my application. Can't do that with the other C compiler products.
Mike
I wasn't being snarky (but perhaps a bit cheeky!) - I was pointing out there are options. I think it is fair to say that Catalina has the most complete and comprehensive support for the unique facilities offered by the Propeller - both 1 and 2 - of any of the non-Spin options, so it really depends on what you want to achieve.
However, you do raise an interesting point, which is what happened to gcc and SimpleIDE on the Propeller 1? I was away from Propeller development for a few years, and it seems that while it started out well, it then just petered out.
Do you know why?
Catalina was named after the PBY - as the documentation says, it's a big, slow, “C”-going contraption ... powered by Propellers!
And yes it is indeed a witty description of a product.
I have seen one of them, and she's the next to the most amazing aircraft ever built during that time period. The other was her sister, the B-24.
But before we get involved in my other favorite hobby, historical aircraft and spacecraft, let's continue our discussion of C and the Prop.
---
Mascot away.
As for Spin vs C, Spin is simple and easy, except when you want to do something complex. It's lack of structures, and the way to arranges variables in memory make doing some things super cumbersome (like handling network packets that are packed). For P1, I mostly used PASM with a tiny bit of Spin glue, it's just easier in most cases for me. For P2, I haven't even used Spin2 at all beyond basic testing. I'm using C with inline PASM (as needed) and including other folks Spin2 objects when needed, and it's been great for me so far.
The fact that we didn't get structures in Spin2 is a tragic omission, several of us asked for it and forum threads covered ways to do it, Chip even seemed keen on it at one point, but then just didn't do it. At least the P2 architecture makes it less painful (unaligned reads/writes, more instructions for manipulating bits/nibbles/bytes/words, etc.), but man it would have improved Spin2 usability for complex programs a HUGE amount to have structures.
My guess is that PropGCC is the one that has been the most used.
I think it was supported by Parallax a little bit at one point.
Tom
You can say that, but that doesn't make it accurate! All of the major programming environments for the Propeller -- Spin, PropGCC, Catalina, Tachyon, FlexProp, PropBasic, etc. -- will allow you to do anything you want with the Propeller, so all of them have "complete and comprehensive" support. Each has its strengths and weaknesses. Any claim that one is "better" than the others is really just subjective, unless you narrowly focus on some particular metric like benchmark speed -- but that's such a narrow focus as to be mostly meaningless.
I think it died when P2-Hot was shown to not be viable -- that was an enormous blow, and I don't think anyone had the enthusiasm to re-do all of the P2 work for the new architecture Chip created. P1 support kind of continued for a while, but Parallax has very limited resources and GCC isn't a particularly fun platform to work on. PropGCC was "good enough" for most users, so it didn't really get developed any further and the developers (myself included) drifted off to other things.
Eh, not quite - language features aside, some of them support memory saving techniques like CMM/bytecode, XMM/Overlays, enabling more complex programs.
Also, while we're at it, what pointer widths do the C compilers use? LONG or WORD? (Obviously you could write a smart pointer in C++/PropGCC to get either width)
I agree, as I'm one of the few here working with XMM memory.
I originally started with SimpleIDE, which was great for doing that which didn't require formatted printouts and other memory intensive stuff.
Needing more memory to do such things, and seeing that PropGCC could support XMM, I attempted to migrate over to it, but could never get the repository to build under Ubuntu. Since I was going to write my own XMM driver, the rebuild was necessary, but this came to a quick halt when all attempts at rebuild failed.
I finally moved over to Catalina and had great success with it. I was able to write my own XMM driver, build the required utilities, then compile and execute my XMM C program without hassles.
Furthermore, the Catalina Multi-Memory Model support is really neat as I was able to write several functions running on different cogs using CMM, while my Primary program executed in XMM memory. The CMM and XMM programs can share variables using common memory within HubRam.
As it stands right now Catalina appears to be working fine for what I have it doing, and its extensive documentation, examples, and ability to write and incorporate my own XMM driver has been greatly appreciated.
I'm certainly open to any other C compiler that could support XMM memory while producing more efficient code than Catalina. I just don't see any other compiler that can do it.
That's not a criticism of any other compiler, just an observation that one will need to weigh what features and capabilities will be required for any particular project when selecting a compiler.
I have vaguely heard of the P2-Hot, but I don't know much about it. I seem to have missed that one entirely. Sounds like this may not have been a bad thing!
Ross.
Catalina uses LONGs in all modes, but in COMPACT mode addresses are limited to 24 bits.
forums.parallax.com/discussion/144199/propeller-ii-emulation-of-the-p2-on-fpga-boards-prop123-a7-a9-de0-nano-de2-115-etc/p1
I have been using SimpleIDE since its inception, yes, it has some short comings, but it is the best suitable C for the P1. I have tried all of the available IDEs, that would be Catalina and FlexProp. Catalina is just not for me, I tried using it on numerous occasions, it just did not do it for me.
FlexProp will be something I will be switching to, if and when I decide to start using the P2. FlexProp, IMO, is geared more for P2 than the P1, and it is still a work in progress.
The reason I suggest SimpleIDE, simple, it has CMM, if that was not available, I probably would not be using it, as much. The other big feature, is the library file(s), it covers just about all of the modules that Parallax sells, that is the module drivers. Plus, the Learn forum still has some examples as to how to use the C drivers for the different modules. Plus, it has some documentation as how to make your own lib files, if you choose to do so. Plus...
The only drawback with SimpleIDE, it has not been updated in a very long, long time. I think Parallax is giving up on it, which is a shame, I still will probably be using the P1, so I would like to see SimpleIDE, all distributions, get updated.
Ray
I'd be interested in hearing why not, and also if you have tried the new Geany-based IDE (included with the most recent Catalina releases). But in order not to derail this thread, perhaps we could take that discussion to the Catalina thread?
Seriously, let's do what @RossH wants.
Additionally the feature I was hoping to use a lot has kind of been dropped (XMM).
FastSpin (the compiler hidden in FlexProp, I prefer to use it without GUI) brings back a lot of P1 fun with all 4 languages (PASM, Spin, BASIC, C) being easily mixable. No XMM yet, but lots of fun in other areas.
You even can compile time critical stuff with FastSpin and mix it into bytecode-Spin (OpenSpin) main programs!
—▷ https://forums.parallax.com/discussion/comment/1479292/#Comment_1479292