Shop OBEX P1 Docs P2 Docs Learn Events
Spin or ASM — Parallax Forums

Spin or ASM

CelticCeltic Posts: 9
edited 2010-11-20 18:25 in Propeller 1
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.

Comments

  • kwinnkwinn Posts: 8,697
    edited 2010-11-20 07:13
    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.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-11-20 07:19
    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.
  • max72max72 Posts: 1,155
    edited 2010-11-20 07:25
    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..
    http://forums.parallax.com/showthread.php?t=116566

    Massimo
  • prof_brainoprof_braino Posts: 4,313
    edited 2010-11-20 08:24
    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
  • CelticCeltic Posts: 9
    edited 2010-11-20 12:49
    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
    if required.

    Thanks for the reply.
  • max72max72 Posts: 1,155
    edited 2010-11-20 13:03
    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....

    Massimo
  • lanternfishlanternfish Posts: 366
    edited 2010-11-20 18:25
    Hi Celtic

    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.

    Cheers
Sign In or Register to comment.