What are the limits of in COG with C or BASIC?
davidsaunders
Posts: 1,559
Ok I did not get as far on the spin as I hoped today, though:
I am looking at C as a possible. What are the limits in using GCC for code that is in cog only? That is other than the obvious size limit.
Is there a simpler C compiler for the Propeller, a integer C with no libs, that only compiles COG code??
I am asking as it seems that everyone wants C, and I would like to see my 3D printer design and firmware at least get half a chance.
I have thought about using PropBASIC as an alternative. Though I do not know the limits of PropBASIC either. I have been looking at the manual, though it seems incomplete, and does not give a good indication of the relation of BASIC statements to PASM code.
Are there any other BASIC Compilers for the Propeller that do as well as PropBASIC or better than PropBASIC, at producing COG code?
Though I do not know where to share it other than here. I got kicked off of the 3D printing forum today for talking about programming, and the limits of G-Code. It seems that they are a bit up about such things (they seem to prefer the commercial stuff over DIY, and do every thing they can to suppress DIY). They did not even tell me that they were going to do so, my username and password just became invalid.
I am looking at C as a possible. What are the limits in using GCC for code that is in cog only? That is other than the obvious size limit.
Is there a simpler C compiler for the Propeller, a integer C with no libs, that only compiles COG code??
I am asking as it seems that everyone wants C, and I would like to see my 3D printer design and firmware at least get half a chance.
I have thought about using PropBASIC as an alternative. Though I do not know the limits of PropBASIC either. I have been looking at the manual, though it seems incomplete, and does not give a good indication of the relation of BASIC statements to PASM code.
Are there any other BASIC Compilers for the Propeller that do as well as PropBASIC or better than PropBASIC, at producing COG code?
Though I do not know where to share it other than here. I got kicked off of the 3D printing forum today for talking about programming, and the limits of G-Code. It seems that they are a bit up about such things (they seem to prefer the commercial stuff over DIY, and do every thing they can to suppress DIY). They did not even tell me that they were going to do so, my username and password just became invalid.
Comments
I asked about a simple compiler that ONLY SUPPORTS Integer math, and does not have any of the libraries available.
And who uses printf() or scanf()? There are much better ways in the standard library for that (getc(), gets(), putc(), puts(), etc).
You want compact code, use only one type.
David was a little brief in #2, and you may have missed that PropGCC has multiple code generation choices.
The COG mode mentioned, ,means the PropGCC creates PASM that runs native in a COG. (maybe that should be renamed PASM mode ? )
Clearly, that is very fast but has limits on just what code it can swallow, to still fit in a COG.
If I understand this right, you can have have 7 COGS running any 7 small/fast blocks of C COG-Mode Code, and one COG can run C in the larger CMM mode, that is slower (much slower than PASM, & slower even than Spin IIRC) , but avoids the hard ceiling of COG memory.
That is where you code the non-time critical stuff.
For your project, I'd suggest re-code PASM in PropGCC-COG-Mode, and maybe also some of the 'faster' Spin, and the 'slower' spin code can code in PropGCC-CMM mode, in a spare COG.
Is there a simple table the OP can use, of lib functions and their sizes in COG mode and CMM mode ?
eg 16 x 16, 16 / 16, and maybe 32 divmod 16
& in CMM for float Mul and Div and int<->Float conversions ?
Then, later, if you choose to convert the assembly to C/C++ as cogc/cogcpp, you can do so.
Just use GCC to compile code to COG native. Don't use any types in that code except int. Don't call any library functions.
But if you have working PASM drivers just leave them as PASM.
There is a good example of PropBASIC here
http://forums.parallax.com/showthread.php/123170
and the PASM PropBASIC creates can go into any COG, and does not care if other COGs are running Spin. PropGCC-COG-Mode or Prop-GCC-CMM, or PASM.
Thank you for the link to PropBASIC examples. I also ask are there any other BASIC Compilers for the Propeller I should look at?
I just spent a little time looking at some of the PropGCC examples, and I think I will stick with PASM and SPIN. I was hoping there was a more straight forward C compiler for the Prop though I guess that to much to ask.
A limited compiler such as what you're talking about could help you enforce some nice standards, but I think you can achieve the same thing with PropGCC or Catalina. For instance, here's a flag that tells GCC not to link with libc.
None of us are trying to belittle your inquiry, but we're very curious as to what other features you're trying to access.
https://code.google.com/p/propgcc/wiki/COGModeExperiences
http://propgcc.googlecode.com/hg/doc/Library.html#RunningNative
There are also three examples of using COGC in SimpleIDE.
Learn/Simple Libraries/Convert/libadcACpropab
Propeller GCC Demos/C-VGA
Propeller GCC Demos/toggle/cog_c_toggle
Once I get everything done in SPIN, PASM, and PropBASIC I will take more time to look at GCC. It is something I want to know, so it will be worth my time. At the moment I am more focused on finishing the first usable version for others. And making that comment are understandable to others takes 4 times as long as writing the code.
I do thank you for the input. though it takes 30 seconds on what machine?? On a 486DX 33MHz with 128MB RAM?
On an 8051 simulating x86 running VirtualBox with Windows (Vista)
It was a 2.5 GHz 8-core Intel-based Linux cloud server and 8 GB RAM. Since I ran it single threaded, I would assume similar performance on any 2.5 GHz single-core x86 Linux machine with a little bit of RAM.
Does Propeller C support code that resides above 32K of an EEPROM?
In other words, can there be code blocks in the upper area an EEPROM that can be loaded if needed?
I would imagine this would use 1 Cog but would allow the Propeller to run a larger program, especially if a function is only used occasionally.
So code runs from EEPROM or are just variables stored there?
Ewwwww, EEPROM is S L O W !
Ha! yep! But, other options, like SPI flash chips, are available if you have the hardware.
Are those topics up to date ?
Having to manually dis-asm to visually check Stack spawnings sounds a little clunky ?
Does the -mcog not have more complete control ?
Here is a (very) good PropBasic example
http://forums.parallax.com/showthread.php/123170
- a clone of that, in -mcog mode would be worth 1000 words...
That's good to hear because the BS2 is super slow because everything is read from EEPROM.
The Propeller Memory Card has a 128KB SPI SRAM on it - Nice!
What CLK speeds does that use ?
I see 1MHz is widespread, and 3.4MHz is mentioned on some parts (eg Cypress FM24V10) not cheap, but could test 3.4MHz code.
1MHz parts can likely be over-clocked with tuning of pullup ressitors and code.