View Full Version : Spin or ASM
11-20-2010, 02:40 PM
I recently own a Prop demo board and downloaded
drivers, tools etc. so fully equipped, running some
demo's etc everything fine.
To get the most out of it, is SPIN or ASM recommended?
In SPIN lots of libraries are available but how slow are these
compare to writing such in ASM from scratch like for
instance a VGA driver.
11-20-2010, 03:13 PM
Celtic, a lot of those objects in the library use a combination of spin and PASM (Propeller ASM). The VGA driver and serial drivers are just 2 such drivers. I would suggest learning spin first and then tackling PASM.
11-20-2010, 03:19 PM
It depends on what you want to do. Spin is fast enough to do "bit banged" half duplex serial I/O at 19.2KBps.
A combination of Spin and assembly is often ideal. Most programs spend most of their time in a small portion of their code. Those small portions can be optimized to get much better overall execution speed. The execution speed of the rest of the program doesn't matter much in terms of overall performance. One way of optimizing is to rewrite those portions using assembly.
11-20-2010, 03:25 PM
ASM is way faster than spin, while spin is more compact.
Speed ratio could be up to 1/90, Check the forum for more info.
Many object start (with spin) a separate cog running ASM.
For instance video driver, servo control, float math, serial ports and so on use ASM to do the task.
You'll find a lot of serial ports objects (spin only, mixed, ASM), but for sure the object handling 4 serial ports in a single COG is ASM. Same applies to 32 servo control, all the video stuff...
Don't understimate the power offered from an object. While they are great learning tools they could also offer a cutting edge code optimisation, available to the masses...
VGA driver is all around, in the obex and in the forum. All of them use ASM, and the quality is impressive. Consider a forum member made a Wolf 3D demo last year..
11-20-2010, 04:24 PM
Usually spin is faster to code,
and assembler is faster to execute.
Often it happens that most of an application is not time critical,
and can be in any language with no major affect.
The time critical part tends to be something that might be written as a small segment inside the main loop,
something that needs to be processed many times per second,
or within a certain time window.
If you can factor the code such that it the time critical part can be written in assembler, and leave the rest in spin (or any other form)
you get the best of both worlds.
So the answer is
Spin AND Assembler
11-20-2010, 08:49 PM
I guess it is recommendable to start with SPIN then
but didn't know SPIN and ASM could be in the same
source what seems to be good news using SPIN for
convienience and optimize for speed with ASM
Thanks for the reply.
11-20-2010, 09:03 PM
Check the stickyes, you'll find a lot of stuff.
Moreover the obex is an impressive vault of inspiring code.
You'll find cutting edge objects, but also examples for starters.
The Propeller is unusual, COG, HUB, and intra COG operations require a little bit of time to get used to, and working examples are a nice start.
Moreover using the objects you can do impressive stuff with little coding....
11-21-2010, 02:25 AM
Like you I am starting out with the Propeller. I find writing my code in Spin is a great way to get working code (albeit a little slower in Spin) before writing a PASM version.