Shop OBEX P1 Docs P2 Docs Learn Events
PASM 101 for beginners? — Parallax Forums

PASM 101 for beginners?

HarpritHarprit Posts: 539
edited 2010-06-24 01:38 in Propeller 1
I may actually have to learn to use PASM in order to do what I want to do with the Propeller
I'll write it up as I learn if there is a need/interest in a book
What is the real level of interest in a book on this subject.
How many beginners realize that they need to know about binary math and boolean algebra
to be able to really use PASM. A large part of a book could be devoted to just that! Does it
need to be?

Comments please

Harprit

Comments

  • LeonLeon Posts: 7,620
    edited 2010-06-22 15:03
    Binary maths is very easy, it's only 1s and 0s. smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Leon Heller
    Amateur radio callsign: G1HSM
  • HarpritHarprit Posts: 539
    edited 2010-06-22 15:06
    Yes and No. So is designing supercomputers.

    Harprit
  • KyeKye Posts: 2,200
    edited 2010-06-22 15:25
    I would say you'll need a section on that.

    You need to be able to go from HEX to Binary and look at bit patterns very quickly. You also have to know your logic tables.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • jazzedjazzed Posts: 11,803
    edited 2010-06-22 15:45
    Doug Dingus (aka potatohead) has a really good PASM tutorial that should be published:
    PASM Primer for the Absolute Beginner*

    *The title listed on page 1 is "Assembly Language Primer for the Absolute Beginner."

    If you post questions/examples as you learn, most likely you will get feedback from
    me and others. A healthy discussion of the topics at hand will make the result better.
    It will serve as a learning experience for us all I'm sure.

    If you can understand GEAR mentioned in potatohead's tutorial and present a good
    description of how to use it effectively, I would certainly appreciate it since I don't get it.

    There are various debuggers that can help you along the way. I use mine [noparse]:)[/noparse] which
    is text based and allows for multiple COG interpreted stepping, animation, instruction
    watch, break, and real-time breakpoints. It is effective when used with BST .list files.
    My debugger HUB footprint moderate, and I use it developing the Propeller JVM.

    I have also used PASD which has a reasonable GUI and most people here have used.
    PASD is a friendly program and has a small overall HUB footprint.

    Cheers,
    --Steve
    Leon said...
    Binary maths is very easy, it's only 1s and 0s. smile.gif
    Ha! Either you know it or you don't!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Pages: Propeller JVM

    Post Edited (jazzed) : 6/22/2010 5:47:07 PM GMT
  • HollyMinkowskiHollyMinkowski Posts: 1,398
    edited 2010-06-22 17:40
    A PASM beginners book is certainly needed!

    I even wrote a few pages of one myself a few months ago.
    But I'm not a good writer and the result was so poor I'd be
    embarrassed to show it.

    I had decided to write a small .pdf about basic computer math
    so that anyone who needed it could download it. Might be a good
    way to go if you decide to write something. Someone else has
    probably already written such a math primer, so you might be
    able to just refer readers to that instead of re-inventing the wheel.
  • potatoheadpotatohead Posts: 10,261
    edited 2010-06-22 18:22
    I can expand on that work easily enough, and actually did start that based on a thread I was on a while back. Thanks for the mention.

    What I see being needed is a blend between just getting started, and the transition to more advanced uses. That's kind of a gap in what we do have online right now. My work being a basic, and DeSilva's actually doing a very solid intermediate / advanced work.

    I just noted the comment on Gear. That section needs an update. I used Gear a lot early on, particularly when I was unable to get access to a Propeller on the go. It's quite useful for learning a lot about PASM. That's been moved to the top of the list, along with the errata people have sent me this last coupla weeks.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Wiki: Share the coolness!
    8x8 color 80 Column NTSC Text Object
    Wondering how to set tile colors in the graphics_demo.spin?
    Safety Tip: Life is as good as YOU think it is!

    Post Edited (potatohead) : 6/22/2010 6:33:03 PM GMT
  • bill190bill190 Posts: 769
    edited 2010-06-22 19:11
    What I need to program in assembly language, is first a general overview of the basics - like what gizmos are included in the chip and what they do in general.

    Then·detailed explanations of the *hardware* for each gizmo and functional diagrams like in this document for the counters...

    AN001 - Propeller Counters v1.0

    http://forums.parallax.com/attachment.php?attachmentid=59613

    I need to be able to picture or understand what is going on when I set a particular bit to 1 in a register. How that "rewires" the circuits so certain things then happen.

    Once I understand "how it works", then I can program away. (I like to look at the pictures burger.gif)
  • tonyp12tonyp12 Posts: 1,951
    edited 2010-06-22 20:33
    Start with something simple like toggling·a LED.
    http://www.youtube.com/watch?v=_5zRxYyfDN0
      
    {{ AssemblyDualToggle.spin }}
    CON
    _clkmode = xtal1 + pll16x
    _xinfreq = 5_000_000
     
    PUB Main
    {Launch cog to toggle P21 and P23 endlessly}
    cognew(@Toggle, 0) 'Launch new cog
     
    DAT
                org 0                         'Begin at Cog RAM addr 0
    Toggle      mov dira, Pin                 'Set Pins to output
                movi outa, #%000000001        'set pin23 high, mov[b]i[/b] only effects bits 31 to 23
                mov Time, cnt                 'Calculate delay time
                add Time, #9                  'Set minimum delay here, don't insert code below without increasing 9 
    :loop       waitcnt Time, Delay           'Wait
                xor outa, Pin                 'Toggle Pins, low will be high - high will be low
                jmp #:loop                    'Loop endlessly
     
    Pin   long %101<<21           'Pin numbers, same as %00000000_10100000_00000000_00000000
    Delay long 12_000_000         'Clock cycles to delay
    Time  res 1                   'System Counter Workspace
    



    Self Modifying code is normally frown on, but with prop is a must.
    Good idea to put 0-0 there, just to show that this number is changed when the program is run.
    But make sure you do not·modify the code·one line·just below, insert a nop if needed.

    AND, OR and·XOR are all bit logic.
    Use the windows calc program in programming mode with Dword selected to view decimals as binary.

    What is asm code instructions·and what is actually just label names (place holders) can be a little confusing first.
    If you always start label names with an uppercase letter would be·good.


    Some math is done when the proptool assembles the code.
    The Pin label above shows "<<21",
    that means left shift it 21 spots up and that the proptool calculates before that number is included in the code.


    Post Edited (tonyp12) : 6/22/2010 8:42:00 PM GMT
  • DynamoBenDynamoBen Posts: 366
    edited 2010-06-22 20:38
    HollyMinkowski said...
    A PASM beginners book is certainly needed!

    I was told at UPEC that Parallax was working on a PASM tutorial. Not sure what the time line is.
  • jazzedjazzed Posts: 11,803
    edited 2010-06-22 21:25
                mov         Time,   #9              ' Set minimum delay here
                add         Time,   cnt             ' Calculate delay time
    :loop       waitcnt     Time,   Delay           ' Wait
                jmp        #:loop
    
    


    FYI: It is generally better practice and more precise timing to add count after setting minimum delay.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Pages: Propeller JVM
  • KMyersKMyers Posts: 433
    edited 2010-06-22 22:39
    Hi, I would welcome a good guide to assembly and gear. Dont understand machine language very good but did some codeing on an RCA 1802 many years ago. Never got past simple LED programs. Just downloaded the above mentioned pdf from Potatohead.

    Wish me luck!

    Ken
  • GranzGranz Posts: 179
    edited 2010-06-23 02:20
    Kye said...
    I would say you'll need a section on that.

    You need to be able to go from HEX to Binary and look at bit patterns very quickly. You also have to know your logic tables.

    Hex is definitely needed, but don't make the mistake that lots of people do: don't treat hex as a native numbering system. What that means is that you need to remember that the ONLY reason for hex in computers/electronics is for easier representation of binary numbers. Too many people have their students jump through hoops to convert hex to decimal, decimal to hex, hex to base 37 (whatever), etc. That only wastes time for the computer engineering student and does not help them (leave that kind of stuff to the higher math students). You need to memorize 16 conversions/translations (0000 = 0..1111=F) and nothing else (at least not in this context).

    Sorry, just that this kind of unnecessary work for students turns them off of the field, and bad teaching is a pet peeve of mine (Don't get me started on teaching Metric - the US Education System did everything in their power to kill our chances at metric by insisting that in order to learn Metric you had to memorize that one kilometer = 1/1.609344 mile, not "about 5 city blocks". And that only exact conversions will work. We learned that a yard is (holding arms out) "about this long"; an inch is (holding the index finger up and pointing from the first to the second knuckle) "abut this far"; we should learn the same way for the meter and the centimeter. Extra, unnecessary, work for students kills their learning.)

    Art
  • potatoheadpotatohead Posts: 10,261
    edited 2010-06-23 04:02
    Agreed. That example was written a long time ago, and taken from an early Parallax text. I think it's the Prop Manual.

    Added to update list.

    Granz, I would add memorization of the first 16 powers of 2, and the first few powers of 16.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Wiki: Share the coolness!
    8x8 color 80 Column NTSC Text Object
    Wondering how to set tile colors in the graphics_demo.spin?
    Safety Tip: Life is as good as YOU think it is!
  • GranzGranz Posts: 179
    edited 2010-06-23 05:11
    potatohead said...
    Agreed. That example was written a long time ago, and taken from an early Parallax text. I think it's the Prop Manual.

    Added to update list.

    Granz, I would add memorization of the first 16 powers of 2, and the first few powers of 16.

    Absolutely! Those are important.

    Art
  • HarpritHarprit Posts: 539
    edited 2010-06-23 18:56
    Mostly I am in complete agreement with the posts received so far. However I fail to understand
    why there being some apparently very good notes on the subject means that there is no need for a
    comprehensive book on PASM. Seems to me that the more books there were the better it would be for
    the whole Propeller community. There seems to be feeling that somehow the knowledge is to be held close.
    We know that we know and we are not really interested in anyone else knowing it. That is the undertone as
    I hear it.

    Since I myself cannot understand even the simplest examples that are posted on the forum
    and in spite of a sincere couple of readings of the Propeller manual am still at a complete loss as
    to what the PASM assemblage is all about, it seems to me that there is a screaming need
    for a book that takes it from the absolute beginnings for fools like me.

    What am I missing.?

    There is a need for a book. If there is someone working on it speak up. That not withstanding, I need to
    comprehend PASM and it looks like I will have to do it by writing a book.

    Harprit.
  • Chris_DChris_D Posts: 305
    edited 2010-06-23 19:12
    Harprit,

    I am with you on the "can't have too many books to explain things".· I read through just about everything on PASM to get started and from there had to figure out a lot on my own.· There is certainly good information already available - it is just spread out in different places, in different PDFs, in different threads, and just about everywhere.·

    If I had the time, I would certainly take the time to write what I can about PASM - i know enough to do what I need to but I don't know anything about binary or hex math or numbers.· From my perspective, a good book that doesn't start with the assumption of "asm experience" or even "C experience" is the basis to begin with.· I have a "BASIC" background and it seems that I can associate PASM with BASIC better than I can with anything else so that is how I look at everything.

    If you decide to go down the path of writing a book on PASM - I would gladly help you in any way I can.· I could be a very good "sounding board" for explanations etc.· I have written many programming manuals for industrial controls, but never did anything for regular programming languages.

    Let me know if you want help or a sounding board or anything else.· In my opinion, you cannot have too many books covering a subject and furthermore, I believe the real power (speed) of the prop is released with the PASM language.



    Chris
  • jazzedjazzed Posts: 11,803
    edited 2010-06-23 19:29
    @Harprit,

    Of course there is a need for such a book. But can you write it?

    You are clearly able write so that beginners can understand;
    however, you don't have enough PASM skill to do it yourself.

    There is great risk that you won't able to "get it" any time soon ....

    IMHO, you should find a co-writer that actually understands PASM.

    Frankly, but very sincerely,
    --Steve
    Harprit said...
    ...
    Since I myself cannot understand even the simplest examples that are posted on the forum
    and in spite of a sincere couple of readings of the Propeller manual am still at a complete loss as
    to what the PASM assemblage is all about, it seems to me that there is a screaming need
    for a book that takes it from the absolute beginnings for fools like me.

    What am I missing.?

    There is a need for a book. If there is someone working on it speak up. That not withstanding, I need to
    comprehend PASM and it looks like I will have to do it by writing a book.

    Harprit.
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Pages: Propeller JVM
  • Chris_DChris_D Posts: 305
    edited 2010-06-23 20:03
    Jazzed,

    You are pointing out the obvious problem, only it exists in reverse.· Most of the tutorials I have read so far assume I know more than I do.· This usually comes from someone who has learned the subject to the point of assuming it to be common knowledge.· This is where someone learning it (and who can understand it) can do a much better job of explaining it than the "old pro".

    I would assume nothing as that is my starting point and I am sure Harprit would do the same.· What does make it a bit more difficult to do as a "learner" who is writing, is that the subject mater must be understood well enough to write with authority.· That is where the advice of the experienced guys pays off.·

    Chris
  • GranzGranz Posts: 179
    edited 2010-06-23 20:08
    jazzed said...
    @Harprit,

    Of course there is a need for such a book. But can you write it?

    You are clearly able write so that beginners can understand;
    however, you don't have enough PASM skill to do it yourself.

    There is great risk that you won't able to "get it" any time soon ....

    IMHO, you should find a co-writer that actually understands PASM.

    Frankly, but very sincerely,
    --Steve
    Harprit said...
    ...
    Since I myself cannot understand even the simplest examples that are posted on the forum
    and in spite of a sincere couple of readings of the Propeller manual am still at a complete loss as
    to what the PASM assemblage is all about, it seems to me that there is a screaming need
    for a book that takes it from the absolute beginnings for fools like me.

    ...
    I'm not sure that I can agree with that; I have found that when I teach a subject (have been teaching for over twenty years, on and off), or write about it, I learn so much through my studies that I know the subject far better than if I were to use it in a regular job. (Don't get me wrong.. I am NOT advocating teaching without experience - that is another of my pet peeves.) I have over three decades of experience in computers and more than an additional decade in electronics. I do not go into the "new" subjects totally raw. Anyone who has a fair bit of experience can gain the knowledge to write about or teach a "new" subject - the information is out there. Yes, it will take extra work in your background research, but that is what the background research is for.

    I am not saying that an amateur can, or should, write a beginners book. But then that is not how I see Harprit. What I have seen of his writing shows that he has a pretty good grasp of the field, he does not appear to be an amateur. The extra effort he puts in to his examples and code commenting will help him to better understand the little that he does not grasp before writing the book. Every author will and should grow through the process of writing a book; writing about new territory will just make the growth that much farther.

    Art

    P.S. Harprit - don't take this as an permission to slack off, we have seen what you can do and now are holding you to a "higher standard" - smilewinkgrin.gif
  • potatoheadpotatohead Posts: 10,261
    edited 2010-06-23 20:12
    I plan on significantly expanding the text referenced here. Whether or not that means published book remains to be seen.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Wiki: Share the coolness!
    8x8 color 80 Column NTSC Text Object
    Wondering how to set tile colors in the graphics_demo.spin?
    Safety Tip: Life is as good as YOU think it is!
  • jazzedjazzed Posts: 11,803
    edited 2010-06-23 20:12
    I absolutely agree with everything you said. That's why I suggested finding a co-writer.
    That way the result can be easy reading and credible authoring.

    Cheers,
    --Steve
    Chris_D said...
    Jazzed,

    You are pointing out the obvious problem, only it exists in reverse. Most of the tutorials I have read so far assume I know more than I do. This usually comes from someone who has learned the subject to the point of assuming it to be common knowledge. This is where someone learning it (and who can understand it) can do a much better job of explaining it than the "old pro".

    I would assume nothing as that is my starting point and I am sure Harprit would do the same. What does make it a bit more difficult to do as a "learner" who is writing, is that the subject mater must be understood well enough to write with authority. That is where the advice of the experienced guys pays off.

    Chris
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Pages: Propeller JVM
  • Kevin WoodKevin Wood Posts: 1,266
    edited 2010-06-23 20:47
    >>> Of course there is a need for such a book. But can you write it? ...

    This sounds kind of harsh, considering that those with the knowledge to write such books, well, aren't writing them.

    Post Edited (Kevin Wood) : 6/23/2010 8:52:02 PM GMT
  • HarpritHarprit Posts: 539
    edited 2010-06-23 20:55
    Well Steve:

    If I may....

    I knew nothing about SPIN and I think I wrote a damn good introduction the SPIN.
    Before David H suggested the book to me I did not even know there was a thing called a Propeller chip.
    One reviewer said "This book was flat out amazing!". Not shabby for some one who had to learn SPIN from scratch.
    It took me a year. A lot of it has to do with hanging in there and not giving up. Not throwing in the towel. You may
    want to take time to think about that. There are some pretty determined guys out there.

    Your question as to "But can you write it?" maybe a bit strong because in it is the suggestion that there
    may be people who are not smart enough to learn PASM, me being one of them! What a remarkably
    interesting idea!!

    I may well decide to not publish my notes as I learn PASM but I don't think I cannot learn the language
    well enough to introduce others to it.

    My expertise is not in climbing Everest. My expertise is determining what it would take to climb Everest. Two
    very different skill sets. (Incidentally it maybe of interest to you that I am a "Materials Scientist", not a computer guy).

    I will ask for help as I need it and if you can find me a co-author willing to put in the time I am I will be
    glad to work with him or her. I hope that you will be able to lend a hand.

    Lets see how it goes. The fat lady ain't ready to sing quite just yet!
    Mind my mind is still fluid on this one.

    Best regards
    Harprit
  • HollyMinkowskiHollyMinkowski Posts: 1,398
    edited 2010-06-23 21:14
    Anyone smart enough to find this forum and sign up
    is smart enough to learn PASM. IMO it is simpler than SPIN.
    I'm certain Harprit can write this book if he wants to.

    Keeping a good notebook that details every step you make
    while learning PASM will give you an outline of what the book
    should cover.
  • Chris_DChris_D Posts: 305
    edited 2010-06-23 21:35
    Harprit,

    While I cannot brag at all about my skills of coding in ASM, I was able to figure enough of it out to handle the motion control aspects for my CNC controller.· In some regards I found it very easy to learn and work with PASM.· It is not nearly as confusing as ASM for the other micros I have played with (Atmel).· I suspect the really big difference has to do with registers, on the Atmel, it appears you have very specific registers to hold very specific data or results.· With PASM, that confusion went away very quickly and I was able to move forward fairly quickly.· Without any ASM history to compare with I can only say that where I failed with other micros using ASM, I got through it and was able to do some cool stuff with PASM.

    I suspect that once you start to mess with it, you are going to fall in love with it - I know I did.

    Chris
  • jazzedjazzed Posts: 11,803
    edited 2010-06-23 22:18
    Harprit said...
    I will ask for help as I need it and if you can find me a co-author willing to put in the time I am I will be
    glad to work with him or her. I hope that you will be able to lend a hand.
    @Harprit,

    We are all happy to help you with PASM; I'm as qualified as the next guy, and will help when I see value in it. Most of your Spin programs were like fingernails on a chalkboard to me though, so I just left the room instead of trying to help and for that I apologize. That is why I decided to speak up this time; for this I am not sorry and will never be.

    To your credit, your Spin programs did end up better than they started. Yes, I realized early on that you were not a programmer, but to paraphrase what I said before, as long as you have enough knowledge to add value, it is of some advantage be a beginner in writing to teach something to the hopeful masses ... it's easier to relate to the intended audience when walking in their footsteps.

    The question is not whether you can learn PASM. I'm sure you can become proficient given enough time. Some day you will have enough working knowledge. At least one potential co-author has already contributed to posts here ... if you ask him, perhaps he will oblige if there is time for it.

    There are obviously others who could help you climb your mountain, and there are several greedy enough to dig in and help push you up the slopes ... just beware of such enthusiasm at the summit [noparse]:)[/noparse].

    Sincerely,
    --Steve

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Pages: Propeller JVM
  • HarpritHarprit Posts: 539
    edited 2010-06-24 01:38
    Well...Steve

    Once I get a working program and post it I'll be looking for expert commentary and inexpert help
    Lets see how long it takes me to pass muster.

    As for the other posters, thanks for the encouragement, I needed every bit.
    And I'll try not to let the newbies down.

    Harprit
Sign In or Register to comment.