Shop OBEX P1 Docs P2 Docs Learn Events
Learning Assembly — Parallax Forums

Learning Assembly

DynamoBenDynamoBen Posts: 366
edited 2008-02-08 19:57 in Propeller 1
While the Prop manual has some really good lessons on spin, the assembly information seems to be a little thin. Because I'm a high level guy I'm looking for some good tutorials for learning assembly. I noticed that the SX uses assembly exclusively. So my thought was that the SX tutorials might be a good starting point. Is this a good/bad idea? Are there better resources?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-02-06 19:27
    Look in the "sticky" forum thread list at the top of the list.· You'll find one that starts out "Propeller Programming Tutorials".· In there are links for several tutorials on Propeller assembly language.
  • DynamoBenDynamoBen Posts: 366
    edited 2008-02-06 20:01
    I actually have read through those, however most of the examples assume that you have dealt with assembly before. My background has been entirely in Basic (both PBasic, and PICBasic) so I am starting from scratch.
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-06 20:14
    I have encountered that problem a few times during the last months (not in THIS forum). It turned out that I could not find anything suiting for the requesters...

    Explaining Propeller machine language to an expert HLL programmer is possible, though takes much time. I also have the suspicion there is no expert programmer who does not well know at least one kind of machine code....

    For a very keen person I should recommend Donald Knuth's "Art of Computer Programming", where a quite useful machine language is described and applied in the first volume.

    After doing that you should have no difficulty to follow deSiva's "Tutorial"...

    Post Edited (deSilva) : 2/7/2008 6:24:42 AM GMT
  • Mike HuseltonMike Huselton Posts: 746
    edited 2008-02-07 03:45
    I have many fond memories of the MIX machine language from my college days. Donald Knuth is an excellent suggestion, deSilva.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    JMH
  • Brian_BBrian_B Posts: 842
    edited 2008-02-07 04:10
    When I wanted to learn Asm, I read the book " how computers do math" , there is a link to my favorite website below.

    http://www.diycalculator.com/index.shtml


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thank's Brian



    ·"Imagination is more important than knowledge..." ·· Albert Einstein

    http://www.diycalculator.com/subroutines.shtml· My favorite website
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-07 06:20

    Looks like fun to read from the outside! I have got the impression it COULD be something like Donald Knuth's book for "the rest of us" smile.gif

    The main issue with most other good books about learning a machine laguage is that they (have to) concentrate on another very specific computer most unmatching the Propeller....
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2008-02-07 09:47
    Ben,

    Assembly is easier than you think especially on the propeller

    mov cheese,#10 'moves the number 10 into a register called cheese
    add cheese, ham ' adds ham to cheese, result is in cheese

    mov outa, cheese 'loads the sandwich into the output register

    Please check out my mini 4 part tutorial, do it with the manual beside you, no real prior knowledge needed:

    http://forums.parallax.com/showthread.php?p=647408

    Unfortunately my tutorial is not deemed good enough to go along side the others but you would have found it in my index thread buried in one of the other stickies making it rather un-index like [noparse];)[/noparse]

    Graham
  • OzStampOzStamp Posts: 377
    edited 2008-02-07 10:51
    I agree with Graham..

    Get stuff happening in Spin first.. translate to asm if speed needed.
    It is not rocket science... it is a matter of understanding exactly what is required..
    And understanding what the instructions do exactly is another issue..
    To see stuff in asm execute at really high speed is awesome..

    And to have 2 or 3 cogs doing stuff totally simultaneously is cool ..(don't you love that word.. cool)


    cheers ron mel oz..
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2008-02-07 11:06
    simultaneously, concurrently, contemporaneously, it's all good [noparse]:)[/noparse]
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-07 20:55
    How you people should love FPGA design smile.gif
  • Langco2008Langco2008 Posts: 4
    edited 2008-02-08 04:05
    rdlong  SaveClkFreq,#def#clkfreqVal
    shr     i2cCount,#16                              ' Save clock frequency and mode
    and     i2cBufAdr,i2cWordMask               ' HUB RAM address of buffer
    rdbyte  SaveClkMode,#def#clksetVal  
    
    



    This code is a section from BoeBotBasic object.
    Please help explain #def#clksetVal since I could not find the answer in the Propeller Manual.

    Thank you.

    Lang Co
  • DynamoBenDynamoBen Posts: 366
    edited 2008-02-08 05:18
    Graham I look through your examples/tutorial and that helped. I have narrowed down the spin code I want to convert to ASM and will see how far I get. I want everyone to keep compiling info about learning ASM for not only my benefit but also for other newbies.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-02-08 05:53
    Langco2008,
    "#def#clksetVal" is made up of 3 pieces. The first "#" indicates that the following operand is an immediate value. It causes the "i" bit to be set in the instruction. The "def#" indicates that the following identifier is expected to be defined in the object "def" declared in this object. The actual identifier (which is defined in another object) is "clksetVal".
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-08 07:35
    @Langco: You might also wonder what the funny SHR and the ADD have to do in this context. The answer is: Nothing. This is called "instruction scheduling": Using the time gap of 9 ticks between HUB instructions which would be wasted otherwise...
  • Langco2008Langco2008 Posts: 4
    edited 2008-02-08 14:32
    Thank you - DeSilva - for the "trick", I would not realize this for a long haul if not forever.

    Thank you - Mike - I get it now.
  • AleAle Posts: 2,363
    edited 2008-02-08 17:49
    When I wanted to learn Asm the only book I found (by chance) was a book by John Socha and Peter Norton, something like "Assembly language for the PC". Very didactic, but not enough.
    I'm sure Knuth's book is better, but I never read it.
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2008-02-08 17:50
    DynamoBen said...
    ...·the assembly information seems to be a little thin. Because I'm a high level guy ....
    Then you're halfway to completely getting assembly which is, like·Jimmy Buffett says, "so simple, like the jitterbug, it plumb evaded me". Assembly is terse, straight-forward and to the point.· Deciding what to do in assembly is more than halfway done doing it.

    Don't bother which Knuth until you decide that you really really want get that Nerd License. Instead, pick a program like keyboard.spin and work out what it does.· See what Parallax's people have done in assembly and do likewise. Just about anything Chip Gracey has written is worth any of Knuth's books and a whole lot cheaper.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2008-02-08 18:21
    Ben, think of this analogy: you are accustomed to doing chemistry on the molecular level where complex reactions occur from combinations of elements. This is analogous to using a high-level language: you specify a command which when run on a processor is composed of a series of smaller subfunctions to achieve the higher level command. Doing things in assembly is like doing chemistry on an atomic level, where you have to specify each iterative step to achieve the end result, more difficult to do but much more powerful and capable of doing things which are impossible on the molecular level.

    All assembly commands can be classified into 3 catagories:
    1. Data transport (MOV, RDLONG, WRLONG, WRWORD,...)
    2. Data manipulation (SHL, ADD, SUB, AND, XOR,...)
    3. Program flow (JMP, DJNZ, WAITCNT, WAITPNE, CALL, COGSTOP, ...)

    Knowing this fact helps when figuring out how to work in assembly because it helps you put things in perspective no matter how large the instruction set is.

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

    Parallax, Inc.
  • potatoheadpotatohead Posts: 10,260
    edited 2008-02-08 19:57
    (moved to appendix in beginner document, found in the assembly tutorial thread)

    Felt this was long and outta context, given the replies above. Sometimes a forum conversation sparks some good writing for me. If anybody found that post obtrusive, sorry --It just happens!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Wiki: Share the coolness!

    Post Edited (potatohead) : 2/9/2008 8:42:10 PM GMT
Sign In or Register to comment.