Shop OBEX P1 Docs P2 Docs Learn Events
pasm tutorial — Parallax Forums

pasm tutorial

This is a pasm tutorial that I have started. I have found that almost all the tutorials that I have seen start simple and suddenly jump to something very complex. I decided to write one with examples of all of the pasm directives. This example is just the beginning part. Thanks to all who have answered my questions.
BTW I am no expert and this is mostly for me so I can learn pasm better. If anyone has any suggestions they are greatly appreciated.
Thanks

Comments

  • Pilot:
    I downloaded and printed your tutorial. Clearly a good deal of time and effort. Thanks. A few comments on the part I have studied.

    First, I like the idea of a tutorial that does more than blink a light.

    On your first program, I don't see the limitation of values of 0 to 256. The number is always in a long, both in the spin portion and the PASM portion.

    In the PASM portion, I would have written:
    asm    org   0
              mov  data_adrs, par     'input parameter address
              mov  answer_adrs, par   'another copy
              add  answer_adrs, #4    'output address
              rdlong temp, data_adrs       'fetch from hub
              wrlong temp, answer_ads    'stash into hub
              cogid temp
              cogstop temp                    'never ever run off the end of a PASM
    data_adrs  res 1                           'I think this variable is more descriptive
    answer_adrs  res 1
    temp    res  1
    
    Finally, I would have defined the variables datavar and answervar as an array. This is because I am superstitous and do not trust spin to assign variables in order.

  • I find it interesting to see the code I write in C and then reveal it in assembler as there is an option in SimpleIDE to show the assembler code.

    I find writing assembler code on the C side much more difficult then doing it in Spin. The nice thing is that C was developed to write assembler code so not always necessary to do that.

    Mike
  • pilot0315,

    Please add all the code as text so it can be copied.
  • I will post the code soon.
    It is my understanding that the limit is 256. I tried larger numbers and got gobblygook. From my readings of other code it takes more work to get a number bigger. So I am still researching that. As there is not a book on this and I am searching through old books on assembly language.
    Thanks for the feedback.
    My goal is to attempt to explain all of the directives in the manual and have functioning code for each.
  • For iseries, I will be getting to the C/pasm issue soon. There is some stuff out there but gotta look at it.
    Thanks
  • Tom Crawford, that is the feedback I am looking for. Thanks
  • Finally, I would have defined the variables datavar and answervar as an array. This is because I am superstitous and do not trust spin to assign variables in order.
    That is advice that I will follow. I've only written one PASM object so I have a lot to learn.

  • Thanks for this! Have tried to learn pasm in past but gave up in frustration...
  • There will be more coming soon. Thanks for the feedback.
    I was frustrated also.
  • Thanks for this. It's good to see more sharing in the nuts and bolts of P1 Assembler.
  • tomcrawfordtomcrawford Posts: 1,126
    edited 2018-12-05 18:56
    Publison wrote: »
    Thanks for this. It's good to see more sharing in the nuts and bolts of P1 Assembler.

    But you really MUST do something properly terminate at the end of the PASM code. Either jmp #$ or CogID/Cogstop. If you don't, the cog will be executing its constants, its variables, and whatever else happened to have loaded by the Cognew. The most insidious thing is for it to overwrite the spin byte codes, trashing your spin program.
  • lardomlardom Posts: 1,659
    edited 2018-12-07 17:56
    A PASM sticky was suggested years ago.
    In the Propeller manual PDF on page 297 for INA it says:
    See Registers, page 338, and the Spin language INA, INB section, page 118, for more information. Keep in mind that in Propeller Assembly, unlike in Spin, all 32 bits of INA are accessed at once unless the MUXx instructions are used.
    The PDF includes an explanation but I could not find an example of 'how' this is done in assembly in the PDF.
    In Spin you can write: If ina[5] but in PASM that expression requires several lines of code.

    When I find tutorials I paste them into a desktop folder but that is not a perfect solution. I think a sticky or a category might be a better solution.
  • I will look into that. I have seen some code examples. This is on my list of projects for further tutorials.
  • Cluso99Cluso99 Posts: 18,069
    Been suggested so many times :(

    Here is how you read the 32 input pins into register x. And an example of outputting too.
       mov   x,ina   ' read p0-32 into x
    
       mov   dira,mask   ' set some pins as outputs
    
       mov   outa,val   ' output a value on the output pins
    
    x    long 0
    mask long $0000_000F ' P3-0 as output pins
    val  long $0000_0006 ' P3=0 P2=1 P1=1 P0=0
    
    
  • Docu, turorials, tools ... there should be a community driven place to collect know how, sources et al... but all attempts beached...

    –▷ Solving The Documentation Problem - Opinions Please
    –▷ Idea: "Propeller Plumbers" organization on Github.
    –▷ https://github.com/rosco-pc/propeller-wiki/wiki

    Until a better idea shows up, the wiki probably is the easiest way to carve some letters for coming generations into the bitstone...
  • @yeti, I bookmarked https://github.com/rosco-pc/propeller-wiki/wiki
    I browsed the links you posted and I see that solutions have been attempted. Frustrating.
    The need for the P1 will not go away. I wrote my first Pasm object based on Graham Stabler's tutorials. I could not have done it without being able to refer to his work.
    In my view it is important to continue to try to build a resource for those that want to learn Propeller assembly. Thanks for your efforts.
  • Here is a little more. I am adding subroutines. It's not finished.
  • yetiyeti Posts: 818
    edited 2018-12-16 11:21
      pst : "parallax serial terminal"
    
    Some OSes have case sensitive filesystems and will fail on this line with not finding this file.
  • Thank you yeti and cluso99
  • I have one of the P2 evaluation boards and have ported over some of the P2Pasm code to the tutorial. There are some differences between both silicon. I am getting used to it.
    First of all there is no official interpreter at this time. It is programmed in P2pasm or .spin2, c or basic. Gui from Parallax is called Pnut and is in pasm only. Serial terminal has to be coded in by the user. Examples are available. Spin2Gui an unofficial gui uses the .spin2 and the other code languages.
    I have attached tutorial with the P2 code after the P1 code.
    Used the same format for sharing variables from spin to pasm and back.
  • PublisonPublison Posts: 12,366
    edited 2019-03-16 22:36
    Just took a quick look. That's a great start! Thanks for the effort to share with the community.
    Just printed to read with morning coffee.
  • Thanks. I am still teaching myself pasm.
    I didn't like the other tutorials that start small then explode into confusion assuming that the reader completely understands. No offense to those who wrote them.
    As an instructor of aircraft mechanics and a certified flight instructor/instrument learning takes baby steps.
    Martin
  • Pilot:
    I downloaded and printed your tutorial. Clearly a good deal of time and effort. Thanks. A few comments on the part I have studied.

    First, I like the idea of a tutorial that does more than blink a light.

    On your first program, I don't see the limitation of values of 0 to 256. The number is always in a long, both in the spin portion and the PASM portion.

    In the PASM portion, I would have written:
    asm    org   0
              mov  data_adrs, par     'input parameter address
              mov  answer_adrs, par   'another copy
              add  answer_adrs, #4    'output address
              rdlong temp, data_adrs       'fetch from hub
              wrlong temp, answer_ads    'stash into hub
              cogid temp
              cogstop temp                    'never ever run off the end of a PASM
    data_adrs  res 1                           'I think this variable is more descriptive
    answer_adrs  res 1
    temp    res  1
    
    Finally, I would have defined the variables datavar and answervar as an array. This is because I am superstitous and do not trust spin to assign variables in order.

    @tomcrawford
    @"Mike Green"

    Hello,
    I have been attempting to print out an individual cell in an array in p2asm and have scoured the forums and tried the obex, which is a pain now that it is in github can't figure out how to navigate github and working on it.
    I have a routine that is looking at a gps feed. Wanting to just print an individual cell of the array instead of the whole array. Eventually to tease out the data.
    Would you be able to show me how?

    Btw I think I now understand the quoted code, thank you for that.
    Here is the basic code I am working with. Attempting nothing fancy at this time like modifying the next value with alts or altd don't understand them right now.
Sign In or Register to comment.