PDA

View Full Version : Assembly or spin?



p00ndawg
05-25-2010, 08:34 AM
which would be better an intermediate to advanced programmer?

What kind of functionality do you lose if you write code in spin or assembly?

Peter Jakacki
05-25-2010, 08:41 AM
No matter whether you are a beginner, intermediate, or advanced programmer it is always advisable with the Propeller to start with Spin. All assembly is launched from within Spin so you need to know Spin enough just to do that anyway. Plus Spin is I think ultra simple, very easy to learn, notwithstanding that I still have to refer to the manual but that is normal with any language, even the English language.

Assembler is limited to 496 words max per cog but it's all about speed, not so much functionality, isn't it(?). For instance, you can write a serial communications driver in Spin that will work up to 19.2K baud but if you do it in assembler then it can run a whole lot faster. Of course these comments are just general, you could get specific, but they cover you questions.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*

p00ndawg
05-25-2010, 08:49 AM
thank you peter.

Also, it is possible to write code that combines spin and properly assembly correct?

Zap-o
05-25-2010, 09:18 AM
You can write code that has Assembly and spin but there are limits.

HollyMinkowski
05-25-2010, 09:18 AM
You can't run spin and asm in the same cog.
Spin uses up the whole cog just to run the spin language.
It gets spin instructions from the hub ram and executes them.

You run spin in one cog and use it to launch an asm program
in another cog.

The propeller chip can have asm and spin running at the same time of course.
It's just that they need to be in their own cogs. They can easily communicate
by passing data using the hub memory.

This is one difference between the propeller and other controllers.
Another is that there are no interrupts, you can simulate them if
you want to, it's easy.

Ale
05-25-2010, 05:30 PM
You can't go wrong with assembly :). But for user interface and high-latency apps... Spin is a lot of help :)

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit some of my articles at Propeller Wiki:
MATH on the propeller propeller.wikispaces.com/MATH (http://propeller.wikispaces.com/MATH)
pPropQL: propeller.wikispaces.com/pPropQL (http://propeller.wikispaces.com/pPropQL)
pPropQL020: propeller.wikispaces.com/pPropQL020 (http://propeller.wikispaces.com/pPropQL020)
OMU for the pPropQL/020 propeller.wikispaces.com/OMU (http://propeller.wikispaces.com/OMU)
pPropellerSim - A propeller simulator for ASM development sourceforge.net/projects/ppropellersim (http://sourceforge.net/projects/ppropellersim)

p00ndawg
05-25-2010, 09:12 PM
thank you for these very informative posts.

JonnyMac
05-25-2010, 11:57 PM
I created the attached template for building Spin/PASM apps that use a command interface. The Spin code provides a command and parameters to the PASM cog which does the work and sets the command value to zero; this serves as a flag that the command has finished. This may help you.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA

Ken Peterson
05-26-2010, 04:29 AM
It's not a question of spin OR assembly. Assembly has the advantage of being really fast. So, if you need speed, use assembly. However, if you are writing a complex program where structured code is important, then spin is better. You can divide your problem up into a mix of spin and assembly, and take advantage of both where appropriate.

Another thing to note, spin uses more efficient use of your hub RAM than assembly because it's tokenized. Every assembly instruction takes 4 bytes no matter what it does. So you may be able to do the same thing in spin with less memory.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A government big enough to give you everything you want, is big enough to take away everything you have. "
- Thomas Jefferson