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

Assembly help

Circuitbuilder9Circuitbuilder9 Posts: 85
edited 2012-02-26 20:52 in Propeller 1
Hi, newbie again.
I would like to know how to change the "par" register in order to store it into more than one variable. thnx

Comments

  • pgbpsupgbpsu Posts: 460
    edited 2012-02-25 18:14
    Hi Circuitbuilder9-

    The PAR register can not be expanded. I've always thought of it/treated it as a memory address that you get to set when you launch PASM code. If you put all the HUB items you'd like to have access to in order and pass the address of the first one, as the developer you know where everything else is relative to the address you passed in PAR. By adding 4 to the PAR value you can rdlong, adding 2 allows you to rdword, and adding one will increment to the next rdbyte in HUB.
  • Cluso99Cluso99 Posts: 18,069
    edited 2012-02-25 18:17
    circuitbuilder9: Firstly, welcome to the fabulous world of the prop.

    As has been said, the PAR is a read only register that is set by the coginit/cognew routine. You should examine this in the Propeller Manual (both in spin and in pasm) for ways it is set.

    Usually we use this as an address pointer to hub where a set of parameters reside.
  • JonnyMacJonnyMac Posts: 9,197
    edited 2012-02-25 19:28
    Usually we use this as an address pointer to hub where a set of parameters reside.

    And the attached program -- yep, a blinky LED thing -- shows you how this works. You pass the address of the first of a group of longs. Knowing that the variables are longs the PASM code adds 4 to par (actually a copy of it as par is read-only from PASM) for each element after.
  • Cluso99Cluso99 Posts: 18,069
    edited 2012-02-25 20:48
    Thanks for chiming in Jon. I couldn't think of a simple example - I thought of the VGA but that would be OTT ATM.
  • Circuitbuilder9Circuitbuilder9 Posts: 85
    edited 2012-02-26 11:35
    Thanks, guys!
    One more question (sorry if this is a dumb question; I am a freshman in high school): registers such as add and adds; what is a signed value? thnx.
  • JonnyMacJonnyMac Posts: 9,197
    edited 2012-02-26 11:53
    A signed value can represent negative and positive values.
  • tonyp12tonyp12 Posts: 1,951
    edited 2012-02-26 12:21
    there is a second way of passing along vars
    as the code is in hubram before it get sent away to cogram,
    you could modify the code with the pointers you want.

    I'm not sure which is the preferred method as both works.
    This example does both, pass a value in PAR and also selfmod the pin used.

    When I reserve 3 longs in the way I do it for hub1,hub2,hub3
    they all will be after each others in hub ram
    So I make PAR point to the first one.




    --- the spin code--
    PUB DisplayDemo | hub1,hub2,hub3
    LED.Display(@hub1, 0{←the pin to use})

    --- the spin part of cognew that gets the pointers---
    PUB Display (hub1,pin) 'the values @hub1,Pin from Demo
    CLKpin := |<pin 'set the pin with selfmod
    cognew(@asm_entry, hub1) 'launch assembly program in a COG, PAR will point to hub1 address.

    DAT
    org 0
    asm_entry mov dira,CLKpin 'make only clk pin an output
    mov hubadrs,par 'reset (par=hub address of @hub1)
    ...
    if_nz add hubadrs,#4 'next long hub adress
    ...
    CLKpin long 0-0
    hubadrs res 1
  • JonnyMacJonnyMac Posts: 9,197
    edited 2012-02-26 16:30
    That is certainly a working solution if your PASM code will only connect to Spin. It has been suggested and encouraged of late that the only access between the high-level code and the PASM code be through the par register. The reason for this is that while Spin can modify the PASM code before launching it into a cog, other languages (e.g. PropGCC) may not. By sticking with par ("mailbox") access your PASM code can be used with languages other than Spin. I just started experimenting with linking PASM code to PropGCC this morning -- in fact, using the PASM blinker I posted above.
  • Circuitbuilder9Circuitbuilder9 Posts: 85
    edited 2012-02-26 18:49
    Cool, Jonny.
    One last thing (about hardware this time): where do you insert the capacitor for servos with very long wire extensions? Or do you not need one? If it is possible, i would like to see a schematic.
  • JonnyMacJonnyMac Posts: 9,197
    edited 2012-02-26 20:52
    Just a note of forum use: it's not a great idea to change topic mid-stream; you should post separate topics separately.

    One you quesion... the Propeller only puts out 3.3v which is fine if your servos are close, not so good if they're a long way (I have a client who just went through this when he extended his connections). It's a good idea to put some kind of buffer between the Propeller and the servos. In my client's case there is only two servos so we're using a TC4427 because it allows him to select the output voltage for the servo pulse.
Sign In or Register to comment.