Shop OBEX P1 Docs P2 Docs Learn Events
Learning PASM, stuck on simple issue... — Parallax Forums

Learning PASM, stuck on simple issue...

UltraLazerUltraLazer Posts: 30
edited 2009-12-09 02:26 in Propeller 1
Im trying to learn PASM and must be lacking some simple information. In my program:

this works:
   
        mov     P0,par                ' Get data patterns starting address
        mov     P1,P0                  ' Setup working pointer
        
        rdlong Reps,P1                ' Get Repetition count
        add     P1,#4                   ' Advance pointer to sequence timing
        rdlong  Dly,P1                  ' Get sequence timing




And this does not...
       
        mov     st, par
        'mov    ste, st
        'add    ste, #400 
       
        rdlong P0,st
  
        mov     P1,P0                   ' Setup working pointer
        rdlong Reps,P1                  ' Get Repetition count
        add     P1,#4                   ' Advance pointer to sequence timing
        rdlong  Dly,P1                  ' Get sequence timing





Though it is commented out for simplification I am hoping to point "ste" to the 100th element after the address stored in par. in order to wrlong values to to hub at "ste".
I am sure my mistake is embarrassingly simple....

Comments

  • BRBR Posts: 92
    edited 2009-12-08 23:06
    Not sure I'm entirely clear on what you're trying to do, but if you just want to make the bottom code snippet do the same as the top, you need to put a valid hub address in p1 like so:
            mov     st, par
            'mov    ste, st
            'add    ste, #400 
           
            rdlong P0,st
      
            mov     P1,[b]st[/b]                   ' Setup working pointer
            rdlong Reps,P1                  ' Get Repetition count
            add     P1,#4                   ' Advance pointer to sequence timing
            rdlong  Dly,P1                  ' Get sequence timing
    
    



    Your current code snippet loads p0 into p1 then uses p1 as a hub address...however, p0 came from a rdlong, so whatever value happened to be at that location in hub memory will be used as the address in the rdlongs for Reps and Dly.

    Hope this helps.
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2009-12-08 23:40
    Your first bit of code looks fine and adding 400 should work fine but I think you have just got yourself a bit mixed up. This is my best guess at what you want

            mov     st, par                ' Get starting address
            mov    ste, st                 ' Adress of 100th element
            add      ste, #400               ' Ste now holds address of 100th element 
      
            mov     P1,st                   ' Setup working pointer
            rdlong Reps,P1                  ' Get Repetition count (assuming the adress of this was passed in coginit)
            add     P1,#4                   ' Advance pointer to sequence timing
            rdlong  Dly,P1                  ' Get sequence timing
    
    
  • JonnyMacJonnyMac Posts: 9,208
    edited 2009-12-09 02:26
    If I'm not mistaken you're working at creating an LED sequencer (didn't you have another thread on this topic?). As we say here in Hollywood... for your consideration: the attached program is my first cut of an LED sequencer that will work for up to 16 pins (with appropriate changes to the PASM driver). I love movie props and have created a LOT of LED sequencers using the BS2 and the SX -- this is my take for the Propeller.

    Notes:

    I have the code set to eight outputs·for this demo so that I can run in on a demo board.

    My sequence data is a bit different. The first element defines the number of steps in the sequence. The step data follows, with the timing (in milliseconds) embedded into the step record (a long). The format for a sequence looks like this:

    zigzag                  long     14                             ' steps in sequence
    
                            '        ms          outs
    
                            long     11 << 16 | %00000001           ' step 1
                            long     18 << 16 | %00000010
                            long     29 << 16 | %00000100
                            long     47 << 16 | %00001000
                            long     76 << 16 | %00010000
                            long    124 << 16 | %00100000
                            long    200 << 16 | %01000000
                            long    324 << 16 | %10000000
                            long    200 << 16 | %01000000
                            long    124 << 16 | %00100000
                            long     76 << 16 | %00010000
                            long     47 << 16 | %00001000
                            long     29 << 16 | %00000100
                            long     18 << 16 | %00000010           ' step 14
    



    The timing for the step is offset by 16 bits -- this allows one to create a sequence that has up to 16 active outputs (again, with appropriate mods to the driver). Timing is specified in milliseconds to make sequence creation easy and the start() method takes care of setting the timing within the cog for one millisecond. The start method also allows you to align the sequence anywhere you want. On the demo board, for example, you would set the zpin (of the start method) to 16. The reason for this is that you can use the same sequence data in multiple sequencer cogs with different output pins.

    Hopefully, some part of this will be useful for what you're doing.

    Merry Christmas!

    [noparse][[/noparse]Edit] Updated the sequencer object a bit to better handle bad (0) timing within a step (and a couple other tidbits).

    Post Edited (JonnyMac) : 12/12/2009 1:29:23 AM GMT
Sign In or Register to comment.