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

  • 17 Comments sorted by Date Added Votes
  • 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.

    Re-inventing the wheel is not a waste of time if, when you are done, you understand why it is round.
  • 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.

    Larry

    If the grass is greener on the other side...it's time to water your lawn.
  • Thanks for this! Have tried to learn pasm in past but gave up in frustration...
    Ken N8SYG
  • 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.
    Infernal Machine
  • tomcrawfordtomcrawford Posts: 945
    edited December 5 Vote Up0Vote Down
    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.
    Re-inventing the wheel is not a waste of time if, when you are done, you understand why it is round.
  • lardomlardom Posts: 1,505
    edited December 7 Vote Up0Vote Down
    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.
    Larry

    If the grass is greener on the other side...it's time to water your lawn.
  • I will look into that. I have seen some code examples. This is on my list of projects for further tutorials.
  • 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
    
    
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • 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...
    ◁ FastSpin ▷ ◁ Stay OmmmmmmPtimistic! ▷ ◁ No Source – No Go! ▷ ◁ Please help: http://rosettacode.org/wiki/Category:Spin ▷ ◁ Why Asimov's Laws of Robotics Don't Work - Computerphile ▷ ◁ DNA is a four letter word. ▷
  • @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.
    Larry

    If the grass is greener on the other side...it's time to water your lawn.
Sign In or Register to comment.