Shop Learn
Propeller Assembly for beginners - Page 9 — Parallax Forums

Propeller Assembly for beginners

1679111229

Comments

  • HarpritHarprit Posts: 539
    edited 2011-08-06 08:17
    Ron

    I am going to write the code we are discussing as it would appear in the book.
    I would be most interested in hearing your response to it. I included this code
    in the forum at time time because we really need to be able to read a potentiometer
    for a lot of our future experiments but I think you have a very valid point so let
    me redo it and then give me your comments.

    I cannot begin to tell you how important what you have said it. I do not have the
    skill, experience in teaching and expertise that Stephan has but let me give it
    a shot and let us see what turns up. Its going to take me some time to flesh
    the thing out but its Saturday and this is important.

    Regards
    HSS
  • HarpritHarprit Posts: 539
    edited 2011-08-06 12:43
    I am ready to post.
    I need to know how to attach a file to a post
    The post does not allow me drawings in the text
    So I need to make an attachment out of the entire file

    H
  • RonPRonP Posts: 384
    edited 2011-08-06 12:46
    Harprit,

    Click on the Go Advanced button if you are not already not there. Then use the Attachment Manager it's a "paper clip" icon.
    Its kinda self explanatory form there.

    Ron
  • HarpritHarprit Posts: 539
    edited 2011-08-06 12:55
    Attached is the expanded file for beginners
    Let me know if these explanations are adequate of it we need even more
    Even so I will be editing and expanding this further in the final book format
    But I need intermediate feedback.
    It can be made simpler if you like.

    THIS FILE DOES NOT OPEN RIGHT. WORKING ON IT.
    Opens with Open Office for some users.
    Please let me know if you have a problem.
    Both files are same
    PDF version is more secure so should open easier for most

    Ron reposts the pdf in #252

    HSS
  • jstjohnzjstjohnz Posts: 91
    edited 2011-08-06 13:59
    Harprit wrote: »
    Attached is the expanded file for beginners
    Let me know if these explanations are adequate of it we need even more
    Even so I will be editing and expanding this further in the final book format
    But I need intermediate feedback.
    It can be made simpler if you like.

    HSS

    Perhaps there are better choices for file formats if you want people to actually be able to open your files.
  • HarpritHarprit Posts: 539
    edited 2011-08-06 14:20
    Tell me how to do it
    I'm ready and I'll re-post
    I'm not cognizant about a lot of this stuff.

    I just noticed that the file does not open right
    I need help. Its an OO document with a AutoCad inclusion.
    HSS
  • RonPRonP Posts: 384
    edited 2011-08-06 14:30
    Harprit,

    It opened right up for me including the AutoCad inclusion I use OO. For people that use MS Office or something else I don't know. Maybe try "File - Export as PDF" within OO. I think everyone can open a PDF.

    Ron
  • HarpritHarprit Posts: 539
    edited 2011-08-06 15:11
    Here is my tentative outline for the PASM book as it stand today
    Suggestions for and from beginners are welcome

    Preface
    Table of contents

    Part one What we have to work with
    Book resources
    Obex shared resources
    Forum
    Propeller Chip
    This book
    Program listings on the Net
    Propeller manual and how to use it and what it does not tell
    Binary math beginnings
    Simple register manipulations

    Part two Simple Output
    7404 buffers
    The PST
    Development board
    Duplex Full Serial dfs interfacing to PST
    LEDs
    2 lines by 16 char display
    Extended to 4 lines by 20 chars
    Speaker
    Servo motor
    Frequency
    PWM generation

    Part three Simple Input
    read one push button
    read Switches
    Read Keyboard
    read Potentiometer
    read Voltage
    Count pulses.
    read frequency
    1302 interface
    single wire clock/other interface.
    LM34 interface

    Part Four The projects
    Solenoids and relays
    Self leveling Table
    440 cps tone
    Metronome
    Tachometer
    Servo motor R/C
    Temperature reading devices
    Clock chip interfacing
    DC motor
    DC Motor with encoder
    Stepper motors
    Data collection from a solar collector.

    Part five Appendices
    Equipment needs
    PASM words used in text with short meanings.
    Epilogue

    Index

    HSS
  • RonPRonP Posts: 384
    edited 2011-08-06 15:26
    Harprit,

    I think you should add some info on Hexadecimal. Its starting to seem to me that once you've written THE END of the book you will be in a better position to write the Beginning for beginners to understand PASM well. Just a thought. As you start to understand PASM more you will do a better job of teaching it. Don't write the Beginning in stone.:smile:

    I case you didn't figure out the PDF thing I converted your .odt attached below.

    Ron



    CH6 for Dicsussion Group.pdf
  • HarpritHarprit Posts: 539
    edited 2011-08-06 16:04
    What I really want to do is write all the projects first and then come back and explain them and write the beginning.
    Post the projects as I go along but that does cause understanding problems.
    HSS
  • RonPRonP Posts: 384
    edited 2011-08-06 16:32
    Harprit,

    I think your on the right path. Being new to PASM yourself, your trials and tribulations will be fresh your head placing you in a prime position to then write the beginning. Keep it up, its looking good.

    Thanks for inspiring me to take another look at PASM in the last few days I have learned a lot. PASM is no longer the Evil Demon I once had it made out to be, it's no Puppy Dog either but it no longer appears to be completely out of my grasps. Light Bulbs have been going of in my brain constantly, its like a photo shoot with sound and all.

    I might even include some PASM in my project code not cause I need the speed but for the experience. :smile:

    Ron
  • HarpritHarprit Posts: 539
    edited 2011-08-06 16:45
    That was great Ron
    Keep me posted as things progress

    Latest RESET
    Since I have to write all the programs in the outline anyhow, I am going to start writing them and post them one at a time with minimal explanations but lines commented as I progress. Then I'll go back and write the book in detail. Sorry for the confusion. I am learning much I go along and it is affecting my plans.

    HSS
  • kuronekokuroneko Posts: 3,623
    edited 2011-08-06 17:19
    @Harprit: Two things that jumped at me while reading your PDF. The org 0 explanation is still ambiguous and there is in fact a PASM equivalent to cognew (bit 3 of the coginit argument overrides the ID specified in bits 2..0 meaning new). HTH
  • HarpritHarprit Posts: 539
    edited 2011-08-06 20:24
    The readership on this thread is awesome (over 5738 today in a little over 3 weeks) but I am not getting enough feedback
    Come on guys lets hear it. I need your help. And yes it is very important. It changes what I write.
    And many thanks to those who have participated.

    @Ron
    re:Your #254

    I've had the same experience. But I really did not get fired up about this till the guys who thought I could not do it had to say so. Then it became an intellectual challenge. The fat lady has not sung yet but I think she will before this is all over. And yes this book will be helpful to beginners. And yes it will have mistakes in it. So?

    Thank you too for the encouragement.

    @kureneko

    I'll pick them up.

    H
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,719
    edited 2011-08-07 02:13
    re:Ch6 Prop Assembly Temp.pdf

    "The 3208 is capable of reading up to eight potentiometers one at a time at about
    100,000 reading a second."

    Maybe:

    100,000 readings a second

    Or

    100,000 readings/second
  • TtailspinTtailspin Posts: 1,326
    edited 2011-08-07 06:57
    Hello Harprit,

    Just wanted to cheer you on, I like your beginners guide to parallel processing, still refer to it often.
    The only "complaints" I might have about the book are allmost trivial..

    I did not have a 2 X 16 parallel display, I have a serial display, and was not sure how to make it work with your text.
    Not a big deal, but nearly all of the book examples relied on "LCDRoutines4" (its a big chunk of the book)
    so to move forward, I had to learn how to make the serial display work for me.

    I did not have the Xavien motor driver, and was stumped, until I could build an alternative H-bridge.
    I can appreciate building an H-bridge is not a beginner task, and not sure what you could do about this,
    Maybe show a schematic of an H-bridge, and leave it up to the reader's skill level..

    And one more small thing, and this is probably just me, but I think any books index should be the back half of the book.
    You have an index in the book, but I personally think it was thin, but again, thats just me,
    because I thought the parallax official guide had a thin index too. in fact, all book indexes are too thin for my taste...

    Other then those small things, I refer to your book often, and do look forward to your new book.

    As for feedback to this current effort, I don't know enough about assembly to even be dangerous,
    but that is why you are writing the book isn't it?... :smile:

    I guess could suggest to be carefull with PUB/PRI sub names, this is silly I know, but..
    I don't want to write a "null" PUB, I know that null is empty and non exsistant, so what would I do with it??
    Maybe you could rename the "PUB null", to "PUB action and adventure" :smile:, again, that's just me...

    Good luck,
    -Tommy
  • HarpritHarprit Posts: 539
    edited 2011-08-07 08:02
    Tommy

    Thank you so much for your post. I will not say much about the SPIN book except that you are absolutely right on with your comments. LCD routines could have been replaced by an accepted Object from the exchange but LCD Routines are written and modifiable by you and thus enhance your learning. 2x16 displays are only $5.00 so I thought their inclusion was OK. Maybe I should have included a diagram of an H. Bridge, but I did build an H. Bridge and blew it up and so I recommended a commercial unit. I would have preferred a much larger index too (specially so for technical books) but the index is not done by the author. McGraw Hill hires an expert to do it and back charges the author a fortune for the favor. Go Figure.

    Thank and regards
    H
  • TtailspinTtailspin Posts: 1,326
    edited 2011-08-07 08:10
    McGraw Hill hires an expert to do it and back charges the author a fortune for the favor. Go Figure.

    I did not know this... so I forgive the book authors, and will turn my disdain to the publishers instead. :blank:

    -Tommy
  • HarpritHarprit Posts: 539
    edited 2011-08-07 12:39
    Thanks for inspiring me to take another look at PASM in the last few days I have learned

    Ron I need to know what it was specifically that inspired you. I need to put in more of it the book!
  • RonPRonP Posts: 384
    edited 2011-08-07 13:13
    Harprit,

    I will get back to you on this. I need to wash the car and a few other things, I have been neglecting. I have to pick up some friends from LAX later tonight. Maybe before I go this evening I will have some time to look at the Propeller Manual and you code and explain what happened to make me understand what is happening in PASM. And why I didn't understand it before. I need to look at references to explain it.

    Ron
  • RonPRonP Posts: 384
    edited 2011-08-08 13:21
    Harprit,

    Here it go's. I will try to explain my initial misunderstanding's with PASM it will expose my simple mind, but that't ok if you think it will help others (its ok to laugh). Prior to these last few days when I visited the back of the book I couldn't get a clear picture of how the Opcode's worked. How do 32 bit's fit into 9 bit's was beyond me. I closed that section of the book hoping that one day it would make sense. Imagine that being a topic of a thread "How do you fit 32 bit's into 9 bit's?". So every time I looked at the Opcode's ddddddddd, sssssssss it didn't make any sense. Now the Propeller Manual talks about if a source or destination literal is bigger that 9 bits you must use a register (p. 240, 241), that's toward the beginning of the Assembly section page's later are the Opcode Examples so I didn't put it together. There is no little hint later on that says "now remember" these are the reasons a beginner PASM book are needed IMO.

    A few days ago when you posted "Lets start over" #221 and the code in #222 I opened the Propeller Manual and followed along looking at the Opcode's thats when it hit me. The source was a pointer to the register that had the 32 bit value (simple stuff I know). Then I had a vision I can only describe as my brains interpretation of my first understanding about how things might be working on the chip level. In the vision I saw a endless stack of Opcodes with Binary (and some HEX) numbers being moved and added from one location in memory to other locations, albeit a brief vision and at low resolution it was my first. When the Propeller 2 comes out do you think my vision will be in High Definition? That vision is now gone now I keep getting what can only be described as the old Window Defrag Screen (remember that?) I now see chunks of code in that mint color being copied and pasted to other locations I can even hear the hard drive, go figure there is no mechanical parts in a Propeller. If I hit myself on the side of the head I get a brief picture of the original vision then Defrag then Blue Screen. I think that's my brains way of defending itself from overload.

    So you see Harprit it was your code in #222 plus my new understanding of the Opcodes that inspired me to move on with Assembly Education. I do now think as others have said that you need a clear picture of how things work on the "chip level".

    EDIT: I made it sound like there is no beginner book or reference for PASM. I would suggest anyone interested go through potatoheads Assembly PDF and there is also deSilvas PDF. There are links on the first few pages of this thread also in the key index thread at the top of this forum.

    Ron
  • HarpritHarprit Posts: 539
    edited 2011-08-08 19:51
    Ron:

    I have read your post half a dozen times to really get what it meant to my writing a beginners book.
    How it should relate to it. What and how I should write my stuff.
    I think it was very helpful to my thinking.
    Thanks

    Harprit
  • RonPRonP Posts: 384
    edited 2011-08-08 20:40
    Harprit,

    You asked what inspired me, that was the moment. I am going through the Propeller Manual's Assembly Section again understanding a little more this time. Maybe I can share my hangups later when I have more. I don't think I am a good representation of a beginner I am not that bright.

    Ron
  • jazzedjazzed Posts: 11,803
    edited 2011-08-08 20:57
    RonP wrote: »
    I don't think I am a good representation of a beginner I am not that bright.
    Having read some of your comments, I applaud your ability to get where you are after reading the recommended articles and other materials like the manuals. I'm sure some credit goes to the dialog you've had in this thread too.

    Best of luck with the rest.
    --Steve
  • RonPRonP Posts: 384
    edited 2011-08-08 21:37
    Thanks Steve, much appreciated. Working with your code sample from the other thread now. Have a question maybe I'll see you over there later need some time to word up the question.

    Ron
  • HarpritHarprit Posts: 539
    edited 2011-08-09 07:45
    I am unable to understand why this program will not print both values correctly
    My assumption is that there are two PAR registers, one for each cog. Am I wrong.
    Testing the code seems to indicate there is a conflict in the PAR variable in my program
    CON
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
    
    var
      long  stack2 [35] 
      long  stack1 [35]
      long  val_1, Val_2     
      
    OBJ                                                            
      fds : "FullDuplexSerial"
      
    PUB wavelengths 
    fds.start(31,30,0,115200)       'start console at 115200 for debug output
    cognew(@pa_1, @Val_1)           'start new cog                                               
    cognew(@pa_2, @val_2)           'start new cog          
    waitcnt(clkfreq/4+cnt)          
      repeat                        'loop
        fds.tx($1)                  'home to 0,0                                                                              
        fds.dec(val_1)              'print value as decimal    
        fds.tx($d)                  'new line
        fds.dec(val_2)              'print value as decimal
        waitcnt(clkfreq/60+cnt)     'flicker free wait   
        
    dat
                org        0               
    pa_1        mov        mem1,     par
    out1        wrlong     first,    mem1                
                jmp        #out1
    dat
                org        0
    pa_2        MOV        mem2,    PAR
    out2        wrlong     second,  mem2
                jmp        #out2
               
    first      long      1111
    second     long      2222
    mem1 res 1
    mem2 res 1
    

    Harprit
  • HarpritHarprit Posts: 539
    edited 2011-08-09 08:02
    I have a program in which I can replace
                   mov       mem,      par           'get address of PAR
                   wrlong   dat_red,   mem        'write to par
    
    with
                   wrlong   dat_red,   par
    
    and it works just fine. Seems to me that it should not.
    What do I not understand about this?
    My understanding is that I cannot write to PAR, I must write to the address of PAR.

    Harprit
  • StefanL38StefanL38 Posts: 2,290
    edited 2011-08-09 08:26
    Hi Harprit,

    I didn't know the answer so I started testing some variants how to code it. Inspired that each PASM-code that should run in a different cog and therefore needs its own DAT-section and its own org 0 command.

    I assumed that longs and res's that shall belong to a certain cog must be defined in that dat-section of this cog.
    so I changed the code to this and PST.EXE shows the expected values. To make it easier to see if the propeller is running I changed the debug-code.

    To see that the PASM-cogs are running the PASM-code should count up its values too.
    CON
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
    
    var
      long  val_1, Val_2     
      long countup
      
    OBJ                                                            
      fds : "FullDuplexSerial"
      
    PUB wavelengths 
    fds.start(31,30,0,115200)       'start console at 115200 for debug output
    
    cognew(@pa_1, @Val_1)           'start new cog                                               
    cognew(@pa_2, @val_2)           'start new cog          
    waitcnt(clkfreq/4+cnt)          
      repeat                        'loop
        fds.tx($1)                  'home to 0,0
        fds.dec (countup)
        fds.tx(" ")                  'new line
        fds.dec(val_1)              'print value as decimal    
        fds.tx(" ")                  'new line
        fds.dec(val_2)              'print value as decimal
        fds.tx($0d)                  'new line
        countup := countup + 1                                                                              
        waitcnt(clkfreq/60+cnt)     'flicker free wait   
        
    dat
                org        0               
    pa_1        mov        mem1,     par
    out1        wrlong     first,    mem1                
                jmp        #out1
    
    first      long      1111
    mem1       res 1
    
                
    dat
                org        0
    pa_2        MOV        mem2,    PAR
    out2        wrlong     second,  mem2
                jmp        #out2
               
    second     long      2222
    mem2       res 1 
    
    keep the questions coming
    best regards

    Stefan
  • jazzedjazzed Posts: 11,803
    edited 2011-08-09 09:02
    Harprit wrote: »
    I am unable to understand why this program will not print both values correctly
    My assumption is that there are two PAR registers, one for each cog. Am I wrong.
    Testing the code seems to indicate there is a conflict in the PAR variable in my program
    ...
    Harprit

    Stefan provided a good answer.

    Read these again:
    http://forums.parallax.com/showthread.php?132966-Propeller-Assembly-for-beginners&p=1022468&viewfull=1#post1022468
    http://forums.parallax.com/showthread.php?132966-Propeller-Assembly-for-beginners&p=1022423&viewfull=1#post1022423
  • kuronekokuroneko Posts: 3,623
    edited 2011-08-09 17:55
    Harprit wrote: »
    I have a program in which I can replace
    mov      mem, par            '[s]get address of PAR[/s] copy value held in par to mem (address of par is $1F0)
    wrlong   dat_red, mem        '[s]write to par[/s] write to address held in mem/par
    
    with
    wrlong   dat_red, par
    
    and it works just fine. Seems to me that it should not. What do I not understand about this? My understanding is that I cannot write to PAR, I must write to the address of PAR.
    You do exactly that (writing to the address in par) which is why it's working. wrlong expects the destination in the src slot which is either #N (write a long to location #(N & -4)) or a register in which case the address itself is stored in the register (e.g. par).

    Writing to par would mean modifying par itself. Doing so - mov par, cnt - only affects the shadow register not the read-only parameter version (which is also the main reason par is copied and the copy then modified).
Sign In or Register to comment.