Shop OBEX P1 Docs P2 Docs Learn Events
Should I bother learnig SPIN or should I just dive into Propeller Assembly?? — Parallax Forums

Should I bother learnig SPIN or should I just dive into Propeller Assembly??

Capt. QuirkCapt. Quirk Posts: 872
edited 2007-06-18 18:51 in Propeller 1
Pual made the comment earlier that PASM was easier to learn then SASM (SX) and assembly language is what I really want to learn the most.

I have read the manual and 3 of the 5 PE pdf's (2-4). Spin is so completly different than SX/B and Pbasic, I figure it will take·about the same amount of time to learn Spin as it would PASM. I am not a fast learner and I would spend months on either language. To me Spin represents magic, and PASM seems more logical (Spock like, lol).

Bill

Also, what·do you use GEAR for, I thought it would be more like SX-SIM?

Comments

  • mirrormirror Posts: 322
    edited 2007-06-18 09:16
    An excellent example for learning Spin and assembler is the FAT16 routines with secure digital card layer written by Thomas Rokicki. The SPI interface to the SD card is written as 4 different variations - from spin only, through to almost assembler only. They make a compelling argument for learning both!

    With Spin it's quite simple to throw in a couple of serial debug messages or hook on a TV screen as many others have done. In PASM it's quite difficult to get debug info.

    I use GEAR primarily for debugging assembler code. But, it is also useful for debugging Spin, although it can be a bit strange if you're a slow learner (because it uses it's own very special language - bytecodes).

    So in summary, learn both [noparse]:([/noparse]

    PASM is a must if you want speed, but Spin is great for glueing your project together.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    It's not all that hard to count the number of grains of sand on the beach. The hardest part is making a start - after that it just takes time.·· Mirror - 15 May 2007
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-06-18 10:04
    I have only really used spin to glue my applications together and to put graphics on the screen and deal with text from the keyboard. At that level there is not really a lot to learn at all. Loops are easy, if statements and case statements are all easy too, it won't take long to get the basics. You should at least get those.

    Assembly is very nice on the propeller at least I think so, there are a few strange concepts to learn and I have highlighted some of these in my "assembly step by step" program (see thread index sticky). You can use assembly to do simple things REALLY fast but don't dump Spin as you will need it to access all the lovely objects written by others (even if those are written in assembly).

    So my overall advice is relax, there is not as much to learn as you might imagine to get going and spin is not nearly as strange as you might imagine.

    Its not helped by how good the Parallax guys are at using spin, they tend to use a lot of clever tricks and all those funny symbols, that can make the example programs and objects hard to read, don't despair.

    Oh and be sure to get stuck in, you can't learn a foreign language by reading a dictionary and you can't learn a programming language by just reading a manual. But be sure to have it by your side, if you don't understand it say "there is no reason why I should, let's look it up"

    Graham
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-06-18 17:35
    To gain the true power of the chip, it is necessary to learn both. GEAR is definately better suited for assembly, but if you are interested in the byte code level spin it's there.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • rokickirokicki Posts: 1,000
    edited 2007-06-18 17:45
    Wow, I'm flattered. I should really document my assembly code.

    In any case, Spin is *very* easy to learn; it's just like Basic or C. There are a couple of gotchas, and a few
    small things that are "different" (like the @ operator and array indexing) but if you already know Basic or C,
    Spin will truly be a walk in the park. (You also have to realize that Spin is a *very* simple language, simply
    because the whole interpreter must fit in less than 512 assembly instructions.) Pay close attention though;
    there are some gotchas (and they are listed throughout the forums; see tips and tricks). The normal ones
    that get me are:

    <= is not less than or equals; it's an assignment operator of the result of <. Ditto for >=.
    Use =< and => respectively.

    a[noparse][[/noparse]0] is the same as a is the same as a[noparse][[/noparse]0][noparse][[/noparse]0]. This is very different than most languages.

    Use @v to take the address of variable v; use long[noparse][[/noparse]v] to assign to it (if it's a long), and so on.

    Spin "Objects" are not the same as C++ or Java objects. They are completely static and
    expanded at compile time.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-06-18 18:44
    Each language has its value and you should learn both. Complex logic and complex computations are messy at best in assembly language and are likely to be a cause of bugs. Spin (or similar high level languages) are always better than assembly language for that sort of stuff. On the other hand, very high speed and careful control of timing are difficult to impossible to do in Spin (or any high level language) even if it were to be compiled directly to assembly language. Most languages simply don't have a way of specifying timing constraints and compilers are not smart enough to figure that out.

    In addition, Spin programs can use all of main (hub) memory while assembly programs are constrained to 496 words (instructions and data) unless they're done using the "Large Memory Model" hybrid interpretive structure which is still under development. Spin programs are also more compact since they're interpretive byte codes rather than 32-bit instructions.
  • Capt. QuirkCapt. Quirk Posts: 872
    edited 2007-06-18 18:51
    Guys, Thank you for the great responses. I'll Chill for now and keep Spin.·This question was result of this thread http://forums.parallax.com/showthread.php?p=647030

    Thanks again

    Bill




    Post Edited (Capt. Quirk) : 6/18/2007 6:59:47 PM GMT
Sign In or Register to comment.