C Compiler Sourceforge project
bassmaster
Posts: 181
because of all the requests flying around in a million threads here, I created a project to get this ball rolling:
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 (or post here) your snippets, design idea's or anything you want to be made public for this GNU project.
Post Edited (bassmaster) : 2/4/2007 4:03:28 PM GMT
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 (or post here) your snippets, design idea's or anything you want to be made public for this GNU project.
Post Edited (bassmaster) : 2/4/2007 4:03:28 PM GMT
Comments
It's not that C is as good as it could possibly be, it's just that C does what it does and does it well.
Do you plan to use the large memory model scheme that has been posted in these forums previously, or will each C module have to fit in 512 longs in a cog?
Can you call Spin objects or assembly code inside a Spin object, from a Propeller C program? Can you call C code from inside a Spin program? I think this will be an important point. If I have all these objects already written in Spin, or a combination of Spin and Propeller assembly, I'm only going to use C if I can still use my Spin objects too. When starting a new language, you have a bootstrapping problem - people will only write in it if there are libraries available, but people only make libraries if they write in it. Making the language interoperable with existing software is a great way to get the ball rolling. It's why C++ became popular - you had a lot of people using C, and they found they could use C++ and it worked with all their existing C code too.
I think having a C compiler available will make developers and/or companies that are too "set in their ways" to learn Spin more willing to consider the Propeller. The second question I get asked by people after, "Why does it have a video shift register on every cog?" (Ans: the cogs are all identical) is, "Where's the C compiler?"
I also will offer some of my time for construction.
Anyone that wants to·post a rought draft proposal together for review and post it that would be great.
Lets also agree on formats:
no word/WP
Keep the UML/sequence diagrams·in·bmp's or pdf for now??
etc.
You·have a good question, I think we should start off with a good design discussion before partitioning the project into procedures to be assigned to developers.
If anyone wants to stop this now, or continue to work on our own, its fine, I have found·in my many years in the industry of software development, that combinig resources and having some process will create a much more usefull product, as well as having one that is freely available for all is a plus. If we do not get the ball rolling soon, I suspect someone will write a good one, and charge 200 bucks for a 1 user license, etc, like·a unnamed c compiler for the pic that is for sale at a very high price.
Sean
Post Edited (bassmaster) : 2/4/2007 6:38:44 PM GMT
I don't know how much I could do with the actual compiler, but if this gets off the ground, I'd be willing to help with the documentation.
One other thing. My suggestion would be to use some form of BSD or similar license. There seems to be a lot of controversy with IP & the GPL, and if there is a compiler available, people will want to use it commercially without open sourcing their code. Just make it easy for them to do so.
However, that would probably rule out GCC.
Post Edited (Kevin Wood) : 2/4/2007 8:39:10 PM GMT
However, if building one is the goal, and open source is the target, then QT is also a possibility for the GUI. It is available for Windows, Linux, OS-X, and Solaris x86.
I think you are right, lets focus on the compiler now.
Pat
But.
I came up with the large model in order to be able to write large, fast programs - and to make the propeller targetable by C compilers.
Unfortunately I don't have the bandwidth to do porting right now (way too busy until April), however I'd be willing to provide advice (I often take a peek at the forums between builds), some help, and I am going to maintain the "official" large model kernels.
It would be EXTREMELY interesting to do a C compiler that targeted Spin byte codes; frankly thats probably a better first target than large model.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.mikronauts.com - a new blog about microcontrollers
Learning lots about compilers and parallel cpus, prop is MIMD, and there are C compilers as this is the most common type.
496 long code space is going to be interesting restriction but it could mean small C, which should be easier to port.
Eclipse and GCC port would be multiplatform but that looks at first glance a major job.
I have used Eclipse and it is good when it works, bit of a mess when it does not.
Anyone interested could try the TI MSP430 free 8k compiler to see what it looks and feels like.
The prop is feeling very much like a small DOS box not a single use microcontroller.
More of a general purpose do anything little box that you can run little programs on at the same time.
Mike's OS, Rokicki's SD card, Bill's large memory model and a nice way to drop and drag objects.
This is not a microcontroller this is a single chip computer with Bios in 32k EEPOM.
Gavin
It would not be a "real" compiler, but it would allow batch , and allow Kdeveloper scripts to develop in....
Good idea to start....
Post Edited (bassmaster) : 2/5/2007 2:30:47 PM GMT
e.g. to convert this simple a blinkoneled.c to blinkoneled.spin·...
//CON
#define _clkmode {"xtal1 + pll16x")
#define ·_xinfreq· 500000
#define·High 1
#define·Low 0
#define·Out 1
//VAR
char Pin;
public void Start(void)· // Do we need a main() ???
{
··· BlinkingLED();
}
private void BlinkingLED()
{
·····int DirA[noparse][[/noparse]5];· //typedef in a propc header file??
···· int OutA[noparse][[/noparse]5];· //typedef in a propc header file??
···· int i;
···· memset(DirA,0,5);
···· Pin = 7·;
····for(i=0;i<5;i++)
·· {
········ OutA[noparse][[/noparse]Pin] = High;··········//LED ON
········ Pause(500);················ //ONE-HALF SECOND WAIT
········ OutA[noparse][[/noparse]Pin] = Low;········· //LED OFF
········ Pause(500);
··· }
}
CON
· _clkmode = xtal1 + pll16x
· _xinfreq = 5_000_000············
· High = 1························ 'A CONstant used to set an output port to about 3 volts
· Low· = 0························ 'A CONstant used to set an output port to about 0 volts
· Out = %1························ 'A CONstant used to set a port's direction to Out
VAR
· Byte Pin························ 'Declares Pin to be a global VARiable of a type Byte
PUB Start
· BlinkingLED
···························································································································
PRI BlinkingLED
· Pin := 7
· DirA[noparse][[/noparse]Pin] := Out
· Repeat 5
········ OutA[noparse][[/noparse]Pin] := High········ 'LED ON·····································
········ WaitCnt(40_000_000 + Cnt) 'ONE-HALF SECOND WAIT
········ OutA[noparse][[/noparse]Pin] := Low········· 'LED OFF
········ WaitCnt(40_000_000 + Cnt) 'ONE-HALF SECOND WAIT
1: We need a parseDefs(xxx)·i.e. xxx = VAR·, It will look through the whole C·file for·definitions then convert to·write to the·spin·output·file pointer for later write.
······· These three CON, VAR, DAT, and are easy!
2. We need a parseMethods() and int getnextmethodPtr(filename) parseMethod(routinename);
···
········ It will look through the whole file for·methods (PUB , PRI) ·then convert to·the spin·output·file pointer for later write. e.g
ParseMethods()
·····
······· int i;
······· i = getnextmethodPtr(filename);
········do while ( i) != -1 // e.g. here i = ptr to (void Start(void) { blinkingled(); }
PUB Start
· BlinkingLED
········ This one is more complex, but not so bad. It will require it to be broken down into subroutines:
··························· 1. convertFor()·· (makes a repeat) Uses ConvertIf()
····························2. convertWhile() Uses ConvertIf() (Simple)
··························· 3. convertCaseSwitch() Uses ConvertIf() (Simple)
··························· 4. convertIf()·· (Simple)
··························· 5. convertSyntax()·i.e· = to := and 5000000 to 5_000_000 ??? (maybeP)
····························8. convertPause()· ·makes Pause(500); = ·(WaitCnt(40_000_000 + Cnt) (I think waitcnt(clkfreq/500+cnt) is better)
··························· 9. convertCalls() e.g blinkingled(): gets converted to 0x12 "blinkingled" 0x13 and writen to the next line.
···························
·Anyway this is a quick idea, I am sure there are better idea's and a few typo's.·······
Post Edited (bassmaster) : 2/5/2007 4:38:04 PM GMT
This little bit of spin would be the "main"
Replacing curly brackets with indenting should not be too hard.
Looks fairly simple but then I know next to nothing about parsing[noparse]:)[/noparse]
The registers would be macro defines and won't change.
From my limited experience Spin looks better than C anyway, mainly because it is so close to the asembly syntax.
I still don't know enough about this beast, wonder if I could find someone to pay me to learn it[noparse]:)[/noparse]
Gavin
Rich
meanwhile, I need developers to start writing the simple routines listed above (names may be modified) ·that we will add to CVS when the project is approved:
If you want to contribute, assign yourself one and post that you are working on it and your expected due date. so we do not have more than one developer working on the same thing.
I expect a UML use case· / Sequence diagrams for each method. Unit test it also.
And we will need some volenteer Guineu (SP) pigs for QA. and eventually QC.
Sean
Post Edited (bassmaster) : 2/7/2007 1:06:37 PM GMT
www.sourceforge.net/projects/propc
Z
Pat
I do this so I can develop and debug under linux.
On the other hand, the code I have is impossibly ugly and I highly recommend people stay away from it.
If you are curious however, you can look at:
http://tomas.rokicki.com/fat16work/fsrw.c --- the C language version of the FAT16 support
http://tomas.rokicki.com/fat16work/fsrw.spin --- the Spin version, automatically generated from the above
http://tomas.rokicki.com/fat16work/ctospin.pl --- the Perl script that does the translation.
I must emphasize: this code is *specific* to this project, not at all general, and not intended to be.
It's also not intended to be generic, or documented, or anything else. So examine at your own risk.
It's possible to get it to work, but it would be very unreadable and unwieldy.
Better to do it "right" with a real lexer and parser.