Shop OBEX P1 Docs P2 Docs Learn Events
Assembly Help — Parallax Forums

Assembly Help

Circuitbuilder9Circuitbuilder9 Posts: 85
edited 2012-05-01 23:15 in Propeller 1
Hello,everybody:

I was practicing assembly (i am a beginner), and i would like to know how to pass a variable in the DAT section to the PUB section. I know you can modify par's in the PUB, but how do you pass it up from the DAT? I am confused on how to use the par register; it is confusing to know what get's passed to which method, and so far and so forth.

Please help me understand this passing of parameters, and thank you.

Comments

  • turbosupraturbosupra Posts: 1,088
    edited 2012-05-01 19:01
    I'm also a newb, but I kind of understand this so maybe I can explain from a newb point of view.

    If you have Par, that is your zero positioning point. The next spin long that you have is par+1long, after that is par+2longs.

    When you pass par as an address in the PASM initialization, you can then define a ptr to the long par+1, par+2 etc etc and move the address par+1 to a ptr variable defined at the bottom, so you can then write the ptr variable name, and it in turn writes to the address that is associated with it. Does that make sense? I threw together some generalized code, but if you post your project I'll insert applicable code into it.

    Generalized code would look like
    VAR
    
    par
    parPlusOneLong
    parPlusTwoLong
    
    
    PUB Main
    
    cognew(@pasm, @par)
    
    
    
    
    DAT
    
    pasm
    
    initialize
    
    
    restart
    
               code here
    
    
    
              jmp #restart
    
    '---------------------------------------------------------------------------------------------
    ' predefined variables
    
    parPtr   long   0
    parPlusOneLongPtr   long 4
    parPlusTwoLongPtr   long 8
    
    
    
    ' regular variables
    
    one   long   0
    two   long   0
    
    
    
  • User NameUser Name Posts: 1,451
    edited 2012-05-01 19:53
    Circuitbuilder, I would recommend you look at post #3 of this thread.
  • lardomlardom Posts: 1,659
    edited 2012-05-01 21:12
    User Name, Great link. Thanks.
  • User NameUser Name Posts: 1,451
    edited 2012-05-01 23:15
    You are welcome. I really think Graham's series of tutorials do about as fine a job of explaining the basics of Prop programming as any document anywhere.
Sign In or Register to comment.