What next - assembly or C for propeller
Bits
Posts: 414
Prop users,
I am going to learn to write in C or assembly (machine code) for the propeller. Which do you recommend? Also what is GCC mean, I just downloaded the IDE software.
I am going to learn to write in C or assembly (machine code) for the propeller. Which do you recommend? Also what is GCC mean, I just downloaded the IDE software.
Comments
http://en.wikipedia.org/wiki/Portable_C_Compiler
http://en.wikipedia.org/wiki/GNU_Compiler_Collection
Regarding C versus Assembler - it depends what you want to go deeply into.
Assembler will have you pondering what exactly the hardware expects.
C will have you writing code with a eye toward platform portable software.
But since any given COG on the Propeller uses something less than 496 lines of Assembly code, why C?
Well others would go ballistic at this because the Propeller can add on RAM and do some nifty things to make it much more of a powerful computer model. For those that want to, C is very appealing. It seems to be all about seeing how far one can take the Propeller toward being a study in miniature of a larger computer.
It ends up being all about what kind of projects appeal to you and what you see as 'need to know' in your future.
In college we learned assembly but only scratched the surface. My concern is there seems to be lacking material for assembly with the propeller.
"The Unix Programming Environment" by Kernighan and Pike, 1984
"The C Programming Language, 2nd ed." by Kernighan and Richie, 1988
For the Linux user, they really are liberating. For others, they seem to be unavoidable at sometime in their careers.
There are full software engineering curricula offered at universities that will focus on C/C++ as the primary language. Often C/C++ is not the first language used; Java, C#, or VisualBasic is usually the first.
As to messiness, GCC is a power-user tool that has been going for a very long time. Power-user tools tend to be structured for flexibility rather than for compactness or neatness. GCC provides C and C++ compilers based on the GNU tool-set. There are many variations of GCC and many processors supported. There is no one program that defines GCC, however the "propeller-elf-gcc" C compiler program for Propeller will include programs as necessary to build your C program. The tool-set is designed for great flexibility without requiring knowledge of a given CPU or MCU; it is one industry standard used all in large company professional settings.
I've tried very hard to simplify GCC for regular folks with the SimpleIDE tool concept. It uses the tool-set in just one of many ways.
Where do you see the holes in documentation, Bits? I think Parallax has done a good job of characterizing the instruction set, but I may know just where to look. Perhaps I could point you in the right direction, or even patch up our documentation to make it easier for people to find/learn?
IMHO, C on the Propeller makes the chip much more accessible to the masses. However, if you are just learning C, I would highly recommend learning on a full blown PC, not an embedded computer like the Propeller. This is because there are some funky constraints you have to look out for on an embedded computer. C/C++ on a PC is much more forgiving. On the other hand, with an embedded processor, you get to see the results of your code in the real world (toggling pins, reading inputs, etc).
Learning assembly will be time and energy consuming, but it will give you an extremely firm understanding of the processor, and even improve your programming skills. Assembly is very manual and verbose - you have complete control over the machine, so to do it right, you have to know the ins and outs of the architecture. Assembly is not for everyone, but if you can wade your way through it, you will have an incredibly deep understanding of how high level languages, like C or C++, get compiled down to architecture specific code. This will put you far ahead of the normal pack.
*penny penny*
One of the things I wrestle with is the question "Why try to make a MCU look like a PC?" when it is clearly not. If I want a high powered HMI I use a PC.
However, if I want a fast, easy to implement embedded controller then I go for the Propeller
Another issue seems to be the Keep up with Arduino mindset ( I look at the Arduino IDE and wonder why Atmel Studio 6, which is also free, isn't widely used).
Perhaps an improvement in the power of the Propeller Tool would be greatly appreciated by us Prop fans (no double entendre intended).
sm
Well I mean lack of documentation as in "no complete manual for assembly".
A book is something I enjoy having. I can read it under a tree or on the toilet, not that I would do that . I do own the manual for the propeller yet the machine code section seems to vague to me. Is there something else besides forums?
-Phil
Any language that offers the PASM equivalents also provides determinism. The time granularity of determinism is the only differentiating factor. PASM and COG C offer the best granularity while Spin's is pretty horrible for because it is slow; LMM C and PropBasic offer a middle ground.
That's more than a slip. It's a middle finger typo
Actually the Propeller Manual is a complete manual for assembly. But you kind of have to know what you're doing before hand (which I didn't).
I've listed some tutorials on Spin and PASM in my index (I think post #3).
JonnyMac's Spin Zone articles helped me a lot.
Edit: I noticed I didn't specify which links were for Spin and which for PASM in my FAQ (post #3 of my index). Besides The Spin Zone articles, you'll want to take a look at DeSilva's and PototatoHead's PASM tutorials.
Operating rooms are quite popular and can be very sloppy places... But, that's where really interesting and life-saving work takes place!
In order to provide a rich infrastructure of support for many operating systems, CPU architectures and infinite number of possible uses, gcc (gnu C compiler) is made up of many, many code modules and data files. We're very fortunate that the open source community has provided all of this "patched up software" in an effort to give developers, an environment of compilers and utilities to create operating systems, applications and drivers for every possible function that we can think of...
gcc is not just a C compiler, as spin is just a byte-code interpreter and PASM is an assembler for just the propeller chip., it provides support for many architectures and systems. Along with all its utilities it includes several C variant compilers, such as C, C++, Objective C (on Mac OS X, which uses gcc for its development), C# (I believe). It includes assemblers for a vast number of architectures (Intel, ARM, Atmel, PowerPC and many more). It provides supporting libraries and frameworks for development of all variants of Linux, Unix (the under-pinnings of Mac OS X) and even Windows. It provides support for drivers, command-line programs, user interfaces, etc...
I don't mean this as a flame, but it appears that you are looking at the whole world of software development through a microscope of your own experience. I know that large-scale software development looks like a "giant sausage factory" to most folks. There are many development environments that sit on top of gcc and its utilities that provide a much simpler interface to the sausage factory and work is being done to provide them for the prop. It's just that gcc for the Propeller chip is just becoming available, thanks to the intrepid work of a few individuals and the open source community. SimpleIDE is the first IDE for gcc on the propeller and it really will make life simpler for you if you try developing from within its environment (yes, I know it's not the only C development environment for the prop.)
I've recently been reviewing other microcontroller development environments (for MicroChip, ARM, Atmel, etc.) and am finding that many now depend on gcc as well! So, there will be lots of code-sausage around for us developers to ponder. Large-scale software development is complex and looks sloppy until you've spent some time with it. gcc is designed to scale up from small-scale to large-scale development and can appear vast and ungainly if viewed as a whole. Just use what you need initially and scale-up over time. Start with SimpleIDE which includes the needed propgcc bits as a unit. Over time, you may delve into gcc on the command line, but keep it simple to begin.
BTW: gcc has provided compilation for much of the source code that 'is' changing the world! Your byline may change after you've used gcc :-)
dgately
FYI: I've been in the "software business" for over 35 years, of which gcc has been the go-to compiler choice for the last 15 of those years. The most progress I've witnessed in software development has occurred in those last 15 years, with gcc. That includes development of OS X and its iOS sibling, on a first-hand basis. Just retired from 23+ years @ that little fruit distributor down in Cupertino.
Totally in agreement with Dan here...
One thing to note is that even with its obscure syntax, C is easier to read than assembly code for "most" developers. I admit that there are far more human-readable programming languages, but C gets very close to the hardware, while providing a relief from in-depth assembly opcode knowledge. You can always review the "assembly" code that the C compiler creates from your sources as a starting point for learning assembly coding. It may not be as optimized as you'll eventually need but that comes with learning.
dgately
There are PASM tutorials all over the place and the examples are sparse but the forum members are nice and willing to help.
Do you have this link
http://www.parallaxsemiconductor.com/docs#downloads
and these documents
http://www.parallaxsemiconductor.com/sites/default/files/parallax/Propeller-P8X32A-Datasheet-v1.4.0_1.pdf
http://www.parallaxsemiconductor.com/sites/default/files/parallax/Web-PropellerManual-v1.2_0.pdf
The second pdf has a section titled "Chapter 3 : Assembly Language Reference"
The next step is probably to take some PASM that works, and edit it to improve it.
Example frameworks are always faster to launch from, than a blank sheet of paper.
Why not both
C is a "close to the metal" language - you can manipulate things at the bits level and so has much in common with assembly. The nice thing about assembly is there are not many instructions to learn, and even then you only use a small number. Toggle a bit on, toggle a bit off, conditional jumps, logical operations. You can do a lot with less than 10 instructions. And with C, start simple.
One general comment - with Spin, if you can't find something in the Obex, you probably have to write it yourself. But with C, there is a fairly good chance someone has already written it. So writing in C can sometimes be more a matter of searching for code on Google rather than writing code.
I do not plan to learn or use C for Propeller programming. I simply do not need it to be a good Propeller programmer and consider its use a hindrance to productivity.
-Phil
http://forums.parallaxinc.com/forums/default.aspx?f=25&p=1&m=187621
http://forums.parallaxinc.com/forums/attach.aspx?a=28716
I don't know if there are more current materials but I think these give some good examples, and might be a good place to start.
Cameronm
Both are very valuable experiences and both are widely applicable. Learning PASM takes you right to the hardware, with there being nothing really between you and the Prop. You are programming it directly and that will force some understanding of both how the Prop really does things, and the hardware you end up programming for.
If you then go and program in C, you will seriously appreciate the merits of that language. For systems / lower level type programming, C sets a high bar and understanding it opens the doors for a whole lot of other things.
Going the reverse works too, but I think it's harder to understand some of the things C does as well as the various options the compiler authors have incorporated to take advantage of the Propeller.
Regarding PASM, CPU designs vary, meaning their assembly language varies. If you get through one, the core learning about ASM and how to apply it gets done. Learning another one is much easier.
Even if one were to prefer becoming a M$ or Apply programmer, UNIX has created the backbone of our computer infrastructure and is much easier to study via Linux and no cost or next to no cost for software and literature.
Assembler has to be reacquired every time to change to a new chip. IT is just that close to the hardware.
Simple put, that is a rather tall order.
Admittedly there are a lot of PIC and AVR users out there that are quite used to moving data in and out of registers and having the hardware perform a UART or I2C interface. Could it be that they think they have mastered Assembler, but really just know how to feed registers and tweak flags?
In other words, there is a sweat equity in really mastering machine code and the mnemonics of an assembler language such as PASM. Parallax has provided a complete set of information. It is just not in the usual form and the expected fashion that others are doing it.
I suppose a graded discussion of PASM examples via the existing objects might fill the gap. Right now that doesn't exist, but it could.
Wow you're really trolling.
No those people who code assembly on AVR's, PIC's and just about every other processor in the world are doing assembly, albeit they don't generally have to bit bang simple peripherals. And BTW bit banging peripherals is a old technique and predates the Prop. So don't think makes your assembly special.
Fair enough. But the point is that people may not be looking at the Objects for further study. Bit banging is both required and a very useful skill.
-Phil