Shop OBEX P1 Docs P2 Docs Learn Events
Assembly or spin? — Parallax Forums

Assembly or spin?

p00ndawgp00ndawg Posts: 70
edited 2010-05-25 21:29 in Propeller 1
which would be better an intermediate to advanced programmer?

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

Comments

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-05-25 01:41
    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*
  • p00ndawgp00ndawg Posts: 70
    edited 2010-05-25 01:49
    thank you peter.

    Also, it is possible to write code that combines spin and properly assembly correct?
  • Zap-oZap-o Posts: 452
    edited 2010-05-25 02:18
    You can write code that has Assembly and spin but there are limits.
  • HollyMinkowskiHollyMinkowski Posts: 1,398
    edited 2010-05-25 02:18
    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.
  • AleAle Posts: 2,363
    edited 2010-05-25 10:30
    You can't go wrong with assembly [noparse]:)[/noparse]. But for user interface and high-latency apps... Spin is a lot of help [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Visit some of my articles at Propeller Wiki:
    MATH on the propeller propeller.wikispaces.com/MATH
    pPropQL: propeller.wikispaces.com/pPropQL
    pPropQL020: propeller.wikispaces.com/pPropQL020
    OMU for the pPropQL/020 propeller.wikispaces.com/OMU
    pPropellerSim - A propeller simulator for ASM development sourceforge.net/projects/ppropellersim
  • p00ndawgp00ndawg Posts: 70
    edited 2010-05-25 14:12
    thank you for these very informative posts.
  • JonnyMacJonnyMac Posts: 9,208
    edited 2010-05-25 16:57
    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 PetersonKen Peterson Posts: 806
    edited 2010-05-25 21:29
    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
Sign In or Register to comment.