C# Use With THe Propeller Chip
Sadao
Posts: 1
I was wondering if it would be possible to program the Propeller Chip in C#?· Is there any sorta of special software I would need?
Comments
If you mean write programs in C# that communicate with a Spin/PASM program running on Propeller, this is possible.
New SIG [noparse]:)[/noparse]
Constantly out of short answers.
Post Edited (jazzed) : 3/9/2010 8:57:51 PM GMT
As both Mike and jazzed say, running C# on the Prop is not currently possible.
However, if you are interested in doing some original development there is an opportunity here. I once looked at creating a CLI (a CIL interpreter) for the Propeller because I discovered there was is a CIL backend for the LCC compiler, and I thought it would be a quick way of getting C running on the Propeller. However, I quickly discovered that CIL is a large and heavy intermediate language (as you might expect - C# is Microsoft's alternative to Java, so a CLI instruction is essentially the same as a Java byte code). Even though LCC only used a small subset of the CLI, in the end it proved much easier to just write a native PASM code back-end to LCC. The resulting programs also execute much faster than CLI would.
However, it would certainly be possible to build a CLI for the Propeller - it would be about the same level of difficultly as ZoCog or ZOG. Once you have that you could then compile C# programs on any platform and then run the result on the Prop.
Of course, WHY you would want to do so is another question. C# is specifically designed for .NET, and it is very unlikely you would ever be able to fit even the smallest .NET program on the Propeller. Also, be warned - the performance would definiitely be slower than SPIN (in fact it would probably be MUCH slower!)
If I were you I'd stick to SPIN. If you want a slightly higher level language, or want to write faster or larger programs that is possible with SPIN then try C.
Ross.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina
An interesting statement considering that the Zog ZPU interpreter took me two or three days to get working whereas the ZiCog Z80 is provingto be a pain in the butt and is still not perfect after two years [noparse]:)[/noparse]
Didn't someone here have a project to create a Java run time for the Prop? Sounds more comparable. I never followed that story to the end.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
Ok - perhaps I should have said "somewhere between the level of difficulty of ZOG and ZiCog" - that leaves me a lot of room for error!
Ross.
P.S. I don't think anyone ever actually started work on a JVM. It was talked about, but I believe it also falls into the "Now who'd be crazy enough to do that?" category. Interested?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina
Peter did a full rewrite of our research as Spin code. I wrote the fully functional Virtual Peripheral PASM code.
The JVM shows how slowly Spin runs. It's funny how it begrudgingly spits out "H.e.l.l.o. .W.o.r.l.d" ... [noparse]:)[/noparse]
I have a 3 COG PASM JVM version that prints "Hello World" quickly, but I'm still debugging some issues.
The project has been an off and on spring revival thing for me the last two years and has been on again for 2 weeks.
I thought GCJ was a part of the ZOG GNU sources .... wouldn't that "compile" a subset of Java to native ZOG instructions?
C# and Java are very similar, but there are Visual Basic and C++ things sprinkled in C# that do not exist in Java.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Short answers? Not available at this time since I think you deserve more information than you requested.
I rest my case
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina
As for GCJ and the ZPU (ZOG) GNU sources, I'm not sure what works there and what does not yet.
That ZPU compiler is an old GCC version now. I forget exactly which. I did manage to rebuild it with support for C++ and FORTRAN. It is possible to compile C++ with it but things go wonky when you want any standard C++ lib stuff like "string". The supplied libraries are very minimalist and intended for small embedded systems in C.
A FORTRAN "Hello world" program did compile.
Something was wrong with the Java stuff, I forget what and soon gave up pursuing it. But I guess it needs a lot of support libs etc as well.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
Is spin imbedded into the prop chip ? Or is spin compiled to "interact with with some kind of code in the prop chip. So then can another compiler be made to produce code that can be understood by the prop chip ?
>> "My first question is how do compilers get written...."
That is one huge question. There are many books written on compiler design and construction along with design of the language you want to compile in the first place. People have been researching and developing this topic for decades.
Personally I don't understand any of that, those books soon get very theoretical . My understanding of compilers is limited to the wonderful series of articles by Jack Crenshaw. compilers.iecc.com/crenshaw/. If you know anything about programming you can follow his explanation. He defines a very simple language in the style of Pascal and then shows various compiler design techniques and crucially examples of the actual code you have to write to do it. His trick is that the language design and the compiler design are done step by step together always choosing the sloution that makes the compiler simple.
Others here can tell you how to apply all that to a Spin compiler but first you have to intimately understand Spin and Pasm and the Spin interpreter built into the Prop.
That answers you last question. The output of the Spin compiler is not directly executable by the Prop. Rather it s a sequence of byte sized operation codes (byte codes) that is loaded into the Prop. The Prop has a program built into its ROM that can read those byte codes and perform the required operations. The Spin interpreter.
The other answer is that compilers get written by having people like BradC who sit down at a computer and type them in[noparse]:)[/noparse].
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
Yes and no. The prop can only directly execute its PASM instructions. It can only execute PASM from the 512 LONGs space in each COG. So yes you can compile a high level language to native PASM but there is not much incentive to do so as the working space is so small. That is why the Prop comes with a built in interpreter that can is written in PASM and runs in COG where it reads and executes byte codes from the bigger HUB memory.
However there is now a compiler for BASIC which does produce PASM for the COGs.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
A small benefit is that a C programmer does not have to learn something new. But in my oppinion this is not really a benefit - learning is good!
I think writing a C to SPIN-bytecode compiler would not be a big efford. C only has a very limited number instructions and operators. It's the translation of the standard libraries which will take a lot of time.
"Because it's there" why yes. You may have noticed that there are countless thousands of computer programming languages. Surely the world does not need all of them or even most of them.
I'm busy getting the Prop to run C code compiled by GCC for the ZPU architecture. Why, because it's there, because it's simple enough that I can but hard enough to be a little challenge, just for fun. I make the excuse of course that it's great to be able to use the existing GNU C compiler for the Prop or that it will allow easier running of big C programs from external memory on the Prop or whatever. That's all delusional[noparse]:)[/noparse]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
http://forums.parallax.com/showthread.php?p=867134
When I started writing a compiler, I didn't know all the technical stuff either. I just jumped right in. The compiler actually started out as BAS2PIC which was for the PIC controllers. Then I found the SX was much faster and I modified it greatly to produce SX/B. Then that was modified to produce PropBASIC. All are written in Delphi.
I would encourage ANYONE to start writing a compiler. It really does force you to learn a lot about the controller you are writing it for.
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134
March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
·
I googled PASM and it resulted in "Porsche Active Suspension Management"
Note that this is for a variant of Basic similar to PBasic for the Stamps. It has no floating point or string variables, but has a variety of special purpose statements for the Propeller.
There's also the FemtoBasic interpreter (in the Propeller Object Exchange) which uses another variant of Basic that provides only integer arithmetic and also has a variety of special purpose statements for the Propeller. It directly interprets the Basic source code rather than compiling it and is itself written in Spin.
PropBASIC thread
http://forums.parallax.com/forums/de...1&m=412552
http://forums.parallax.com/forums/de...5&m=412552
http://forums.parallax.com/showthread.php?t=118611
http://www1.idc.ac.il/tecs
http://books.google.com/books?id=THie6tt-2z8C&dq=The+elements+of+Computing+systems&printsec=frontcover&source=bn&hl=en&ei=OMOCTK_qMIG8lQeSqpkg&sa=X&oi=book_result&ct=result&resnum=4&ved=0CCcQ6AEwAw#v=onepage&q&f=false
I would jst like to know HOW Languages work
My all time favourite introduction to compiler's is the series "Let's Build A Compiler" by Jack Creshaw:
http://compilers.iecc.com/crenshaw/
It's pretty non-technical, if you know a bit of programming in any high level language, C, Pascal, Spin you can follow this. He skips all the impenetrable stuff you find in compiler design text books and you actually build a little working compiler if you follow along with practical experiments.
Mike.
Seriously, if I can do it, anyone can.