+ Reply to Thread
Page 1 of 43 1234511 ... LastLast
Results 1 to 20 of 850

Thread: Propeller Assembly for beginners

  1. #1

    Default Propeller Assembly for beginners

    After total frustration in getting things done really fast in Spin, which I'm not very good at, I have decided to learn Assembly Language for the Propeller and to write a book about it as I go along, as I did for the Beginners Book. Maybe that will help me and others.

    Its going to take a while in that, for me, the going is slow. I don't know a thing about it right now and I've been at it for quite a while! Meaning that I still cannot write anything but the shortest of programs.

    I solicit advise as to where I might learn more about this. I have read the Prop Manual umpteen times so I need more than that. I also need to understand binary manipulations better and was unable to find a suitable book on Amazon.

    Any guidance would be greatly appreciated. Please keep in mind my "knows little of nothing" status.

    Thanks
    Harprit.

  2. #2

    Default Re: Propeller Assembly for beginners

    If you have no experience programming in assembly language, then it's going to take some time to get the hang of it. The biggest difference between ASM and high level languages (like SPIN) is everything in ASM is a small step. You have to break down each task into a list of single operations.

    It also helps to have a "bottom up" programming style. You first break down your objective into tasks, then start with the most repeated / time-sensitive task and program that as efficiently as possible. Then structure all other tasks to feed data to the "core" task.

    With ASM the lines between data types also get blurred. There's no type checking. Whether a given 32-bit value is signed or unsigned; integer, fixed-point, float or character(s) (or even code) can change as required. While some opcodes might "prefer" one or the other, you can "bend the rules" as necessary.

    PASM also has a few quirks versus most other ASMs:
    1. There are 496 "registers" which may contain code or data. Certain constructs require operating on code as data (i.e. arrays in COG RAM).
    2. Pipelining means changes to instructions don't take effect until the next instruction.
    3. How JMPRET (aka JMP, CALL, RET) and DJNZ/TJNZ/TJZ work thus why you normally put an # before the label.
    4. Flags - having to specify which flags get updated, the power of conditional operations, and the limitations of only having two flags.
    Pay for your free software - let the developers know how much you appreciate their work!

    Links to Propeller stuff I've done (mostly composite video)

  3. #3

    Default Re: Propeller Assembly for beginners

    There was some post from desilva, boy, we miss him, and I thought it was in the Stickt, but I couldn't find it.

    Here's a link to the thread:

    http://forums.parallax.com/showthrea...ight=assembler
    Infernal Machine

  4. #4

    Default Re: Propeller Assembly for beginners

    Doug's (potatohead) tutorial series is In the deSilva thread. It's probably much more valuable for beginners.

    This is worth a look too: http://forums.parallax.com/showthrea...l=1#post575479

    You might consider using PropBasic ... it will produce some generic PASM for you.

    I hope you're able to figure it all out and produce a quality book.
    I promise to look at your posted samples and offer constructive comments.

    Good luck.
    “I have no special talents. I am only passionately curious.” Einstein
    ~v~^~v~^~v~^~v~^~v~^~v~^~v~^~v~^~v~^~v~^~v~^~v~^~v ~^~v~^~v~
    Learn Parallax PropellerC: http://learn.parallax.com/propeller-c
    PropellerGCC Documents: http://sites.google.com/site/propellergcc
    PropellerGCC Wiki Page : http://code.google.com/p/propgcc/w/list
    PropellerC Arduino Code : tonokip project SeeedStudio 2.8" LCD V1.0
    CommunityGCC Libraries: propware and libpropeller

    Linux/Mac/Windows PropellerIDE: PropellerIDE Forum Thread

  5. #5

    Default Re: Propeller Assembly for beginners

    Where can I find the addresses of various registers used in PASM math operations and manipulations.
    They do not seem to be in the data sheet

    Harprit

  6. #6

    Default Re: Propeller Assembly for beginners

    The addresses may not be in the "Propeller Manual" but they are in the "Propeller Datasheet" in the first figure under "MEMORY ORGANIZATION". Page 15 of Propeller Datasheet v.12.pdf ... I use the Propeller Tool Help tab to open the pdfs.
    “I have no special talents. I am only passionately curious.” Einstein
    ~v~^~v~^~v~^~v~^~v~^~v~^~v~^~v~^~v~^~v~^~v~^~v~^~v ~^~v~^~v~
    Learn Parallax PropellerC: http://learn.parallax.com/propeller-c
    PropellerGCC Documents: http://sites.google.com/site/propellergcc
    PropellerGCC Wiki Page : http://code.google.com/p/propgcc/w/list
    PropellerC Arduino Code : tonokip project SeeedStudio 2.8" LCD V1.0
    CommunityGCC Libraries: propware and libpropeller

    Linux/Mac/Windows PropellerIDE: PropellerIDE Forum Thread

  7. #7

    Default Re: Propeller Assembly for beginners

    Does this mean there is no accumulator like register in PASM
    Which makes me think that all registers can be used as targets of math/bit/byte manipulations

    H

  8. #8

    Default Re: Propeller Assembly for beginners

    Quote Originally Posted by Harprit View Post
    Does this mean there is no accumulator like register in PASM
    Which makes me think that all registers can be used as targets of math/bit/byte manipulations
    Yes all cog memory addresses are register destinations except PAR, INA, and INB (there are advanced exceptions).

    Basic PASM syntax: [if various] <instruction> <destination register>, [#]<source> [W[C|Z|R] | NR]

    Examples below show 3 ways to loop 20 times.
    Code:
    PUB main
    
    DAT
    ORG 0  ' set the COG address count to 0. 0 is assumed if left out.
    
    PASM_EXAMPLES
    {
    Names ndx, loop1, loop2, loop3, DIRA, and OUTA are registers.
    The name ":loop" can be used multiple times.
    Everything with # is an immediate constant which is limited to 0..511
    }
                    MOV DIRA,#$100  ' set bit P8 to output
    
                    MOV ndx, #20
    loop3
                    XOR OUTA,DIRA   ' toggle bit P8
                    DJNZ ndx, #loop3' jump to loop3 20
    
                    MOV ndx, #20
    loop2
                    XOR OUTA,DIRA   ' toggle bit P8
                    SUB ndx,#1 wz
        IF_NZ       JMP #loop2      ' jump to loop2 20
    
                    MOV ndx, #20
    loop1
                    XOR OUTA,DIRA   ' toggle bit P8
                    SUB ndx,#1
                    TJNZ ndx,#loop1 ' jump to loop1 20
    
                    JMP #$          ' special loop here forever syntax
    
    ndx long 0
    Last edited by jazzed; 07-20-2011 at 01:21 AM. Reason: PAR is read-only (except for the shadow)
    “I have no special talents. I am only passionately curious.” Einstein
    ~v~^~v~^~v~^~v~^~v~^~v~^~v~^~v~^~v~^~v~^~v~^~v~^~v ~^~v~^~v~
    Learn Parallax PropellerC: http://learn.parallax.com/propeller-c
    PropellerGCC Documents: http://sites.google.com/site/propellergcc
    PropellerGCC Wiki Page : http://code.google.com/p/propgcc/w/list
    PropellerC Arduino Code : tonokip project SeeedStudio 2.8" LCD V1.0
    CommunityGCC Libraries: propware and libpropeller

    Linux/Mac/Windows PropellerIDE: PropellerIDE Forum Thread

  9. #9
    StefanL38's Avatar
    Location
    northern part of Hessen (Germany)
    Posts
    2,136

    Default Re: Propeller Assembly for beginners

    Hi Harprit,

    take a look at PASD the propeller assembly debugger http://insonix.ch/propeller/prop_pasd.html

    The website is german but the manual is in english.

    With this tool you can single-step through PASM-code and lookup the value of each long in the COG-RAM.
    very helpful for analysing what is going on.

    keep the questions coming
    best regards

    Stefan

  10. #10

    Default Re: Propeller Assembly for beginners

    Quote Originally Posted by Harprit View Post
    After total frustration in getting things done really fast in Spin, which I'm not very good at, I have decided to learn Assembly Language for the Propeller and to write a book about it as I go along, as I did for the Beginners Book. Maybe that will help me and others.

    Its going to take a while in that, for me, the going is slow. I don't know a thing about it right now and I've been at it for quite a while! Meaning that I still cannot write anything but the shortest of programs.

    I solicit advise as to where I might learn more about this. I have read the Prop Manual umpteen times so I need more than that. I also need to understand binary manipulations better and was unable to find a suitable book on Amazon.

    Any guidance would be greatly appreciated. Please keep in mind my "knows little of nothing" status.

    Thanks
    Harprit.
    Sounds like a great endeavour - having a beginner's perspective can really help identify the tricky concepts for newbies. Perhaps keep this thread alive when you need help with the harder concepts and tricks...

    As for binary manipulation I doubt there's a single book that covers the ground - you'll want to familiarised yourself with 2-s complement representation, use of hexadecimal notation, how to multiply works in binary, boolean algebra, and uses for shift and rotate, and of course manipulating ina/outa/dira/cnt/frq/phs registers directly. Wikipedia will have some of this, these forums will have the Propeller-specific stuff.

  11. #11
    localroger's Avatar
    Location
    Culture GSV Quietly Confident
    Posts
    2,431
    Blog Entries
    12

    Default Re: Propeller Assembly for beginners

    Binary manipulations (what in snootier corridors are called "finite math") are one of those things that was so necessary and useful that every introductory book about any microprocessor from the 1970's would have an extensive introduction to it -- the logical operations, the usefully self-reversing XOR, 2's complement and circular math, and if the platform supported floating point the nasty little errors that creep in where you least expect them. Turning around and glancing at mybookshelf, I see Programmer's Guide to the 1802, The 8080A BugBook, The Z-80 Microcomputer Handbook, and The Z-80 User's Manual all of which have at least a chapter devoted to binary logic and math.

    Nowadays? They don't teach that stuff any more. It's assumed that either you know it already or you don't need it. Which is tragic, because I've seen several majorly fatal mistakes made by otherwise good programmers who simply didn't know, for example, that 1/10 is an infinitely rebeating fraction in binary and it will truncate and expand back to .999999 like 1/3 does in decimal if you don't round off your results -- especially if you use double precision math, where the routines don't automatically round off for you.

    The Propeller has a particularly rich set of capabilities for binary work with its wonderfully extensive list of conditions that can be applied to each and every instruction and the ability to separately and selectively repress the C, Z, and numeric results of any operation. I'm doing a big job in 80386 assembly at work right now and I am feeling so spoiled by PASM.

  12. #12

    Default Re: Propeller Assembly for beginners

    Rather off topic but I'm suddenly nostalgic about the Sparc architecture - if only PASM had save/restore!! [ Actually also the IBM370 too - found old programming manual ]

  13. #13

    Default Re: Propeller Assembly for beginners

    Thanks for a lot of good stuff guys
    I will look into it all as i proceed
    Keep it coming and I'll get the job done
    Its starting to make sense
    Thanks again
    Regards
    Harprit

  14. #14

    Default Re: Propeller Assembly for beginners

    Off topic
    How do I put a picture back under my name on the left
    H

  15. #15

    Default Re: Propeller Assembly for beginners

    Click "Settings" on the upper right. Along the left edge you'll see "Edit Avatar" as one of the choices.

  16. #16

    Default Re: Propeller Assembly for beginners

    Thanks Jason
    H

  17. #17

    Default Re: Propeller Assembly for beginners

    Dear Harprit,

    I'm looking forward to your next book about Propeller. I bought yours about the SPIN language and it's a pretty good read.

  18. #18

    Default Re: Propeller Assembly for beginners

    Thank you John.
    Its always encouraging for an author to hear good things about his work.

    Harprit

  19. #19

    Default Re: Propeller Assembly for beginners

    My thought process to date...

    I am thinking I will follow the outline of the beginner's book on SPIN pretty closely
    but instead of doing things in SPIN, everything will be in PASM this time. This will
    allow comparisons during the learning process that might be very useful. We can
    also then compare the speeds of the two languages.

    Of course the outline will have to change here and there to allow PASM to be explained
    and explored from time to time. Might even include some basic stuff on binary math. Just
    enough for reference. Not a tutorial in any way. That would be a book in itself.

    I just received Crowder's book on "The arithmetic of Computers" written in 1960!
    From Amazon.
    I was a Sophomore at the U for Illinois then.
    Seems like a long time ago.
    Its pretty good on Binary math.
    I will be able to learn enough to get the job done.

    Comments Please?

    Harprit

  20. #20

    Default Re: Propeller Assembly for beginners

    Quote Originally Posted by Harprit View Post
    Comments Please?
    Introduce required math slowly.

    Maybe have a math appendix document that describes:
    • binary, hex, and tertiary (for video drivers) numbers and conversions
    • logical operations, boolean math up to DeMorgan's theorm, arithmetic
    • some transcendental functions supported in Propeller ROM
    “I have no special talents. I am only passionately curious.” Einstein
    ~v~^~v~^~v~^~v~^~v~^~v~^~v~^~v~^~v~^~v~^~v~^~v~^~v ~^~v~^~v~
    Learn Parallax PropellerC: http://learn.parallax.com/propeller-c
    PropellerGCC Documents: http://sites.google.com/site/propellergcc
    PropellerGCC Wiki Page : http://code.google.com/p/propgcc/w/list
    PropellerC Arduino Code : tonokip project SeeedStudio 2.8" LCD V1.0
    CommunityGCC Libraries: propware and libpropeller

    Linux/Mac/Windows PropellerIDE: PropellerIDE Forum Thread

+ Reply to Thread

Similar Threads

  1. Book for absolute beginners. Propeller 101
    By Harprit in forum Propeller 1 Multicore Microcontroller
    Replies: 121
    Last Post: 06-27-2010, 10:37 PM
  2. Propeller Assembly Q&A
    By Paul Baker in forum Propeller 1 Multicore Microcontroller
    Replies: 68
    Last Post: 10-07-2009, 12:52 AM
  3. Propeller PLL for beginners
    By Loopy Byteloose in forum Propeller 1 Multicore Microcontroller
    Replies: 0
    Last Post: 02-14-2008, 08:22 PM
  4. How many beginners would like to see a Beginners Sub Section?
    By TonyA in forum Propeller 1 Multicore Microcontroller
    Replies: 54
    Last Post: 08-10-2007, 09:52 PM
  5. How many beginners would like to see a Beginners Sub Section Forum?
    By TonyA in forum Propeller 1 Multicore Microcontroller
    Replies: 1
    Last Post: 08-02-2007, 09:10 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts