Shop OBEX P1 Docs P2 Docs Learn Events
How do I get the HUB address of a DAT label that is located in an object ? — Parallax Forums

How do I get the HUB address of a DAT label that is located in an object ?

BeanBean Posts: 8,129
edited 2009-12-02 12:08 in Propeller 1
I has PASM code in the main file that needs to use COGINIT to start a PASM routine that is in an object.

I tried using mov __temp1,@MyObject.Labelname but that doesn't work. So I tried @@MyObject.Labelname (no dice), then I tried #MyObject.Labelname (no go).

The label is in the DAT section (PASM code).

Help...

Bean.



▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1st rule of finance...Don't lose money.
Never be ashamed of making an honest·profit.
Live within your means...Make do, or do without.
·

Comments

  • RaymanRayman Posts: 14,876
    edited 2009-12-01 17:46
    I think you'd need a function in your object to either return that address or do the coginit...

    With the Prop Tool, anyway. Maybe BradC's one is more flexible?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
  • BeanBean Posts: 8,129
    edited 2009-12-01 17:51
    Thanks Rayman,

    If I have a PASM label in the same file I know that "mov __temp1,label" will get the cog address of the label, but will "mov __temp1,@label" give me the HUB address of that label ? This is because coginit requires the HUB address of the label.

    Bean

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    1st rule of finance...Don't lose money.
    Never be ashamed of making an honest·profit.
    Live within your means...Make do, or do without.
    ·
  • RaymanRayman Posts: 14,876
    edited 2009-12-01 18:23
    Oh, you want to do coginit from within PASM? I still think you'd have to do a SPIN call to the object first to get the address....

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
  • kwinnkwinn Posts: 8,697
    edited 2009-12-01 18:26
    Put the address in a dat variable before doing the cog init using spin.
  • BeanBean Posts: 8,129
    edited 2009-12-01 18:28
    Okay, here is the code I'm trying to get working.

    test.spin is the main code and dosomething.spin is the object.

    It should blink the LED on pin 16 for 10 seconds then stop. But it does nothing ???

    Bean.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    1st rule of finance...Don't lose money.
    Never be ashamed of making an honest·profit.
    Live within your means...Make do, or do without.
  • RaymanRayman Posts: 14,876
    edited 2009-12-01 18:39
    Looks good, except I'm not sure why all those shifts are there...
    I think this would work:
    [s]                mov         __temp1,par       ' par is the same as this cogs par
                    rdlong      __temp2,__temp1       ' get address from hub variable "HubAddr"                       [/s]
    [s]                coginit     __temp2 WR        ' Start cog and return new cogid                                          
                    mov         cog1,__temp1      ' save cogid  [/s]
    

    Ooops, I see the assembly coginit doesn't work like I thought...· I see why you need the shifts now...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm

    Post Edited (Rayman) : 12/1/2009 8:34:50 PM GMT
  • BeanBean Posts: 8,129
    edited 2009-12-01 19:58
    Oh, I found the problem. The fields only hold 14 of the 16 bit address (the lower 2 bits are not given).

    Got it working. Thanks...

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    1st rule of finance...Don't lose money.
    Never be ashamed of making an honest·profit.
    Live within your means...Make do, or do without.
    ·
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2009-12-01 21:39
    Bean (Hitt Consulting),

    For my own future reference I would like to see what you did. I have come across a similar situation in the past and had figured out some convoluted way to manage it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • BeanBean Posts: 8,129
    edited 2009-12-01 22:39
    This is slightly modifed from the PropBASIC compiler.

    Bean.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    1st rule of finance...Don't lose money.
    Never be ashamed of making an honest·profit.
    Live within your means...Make do, or do without.
  • RaymanRayman Posts: 14,876
    edited 2009-12-01 23:48
    Wait, where's the shifts?

    [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
  • BeanBean Posts: 8,129
    edited 2009-12-02 01:29
    Rayman said...
    Wait, where's the shifts?

    [noparse]:)[/noparse]

    I found that I could pre-calculate them in the spin code.

    But I'm sure you knew that...

    Bean



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    1st rule of finance...Don't lose money.
    Never be ashamed of making an honest·profit.
    Live within your means...Make do, or do without.
    ·
  • heaterheater Posts: 3,370
    edited 2009-12-02 12:08
    Don't know if this helps in your case but if you use BST instead of the Prop tool. Then you can use:

    DAT
    something long 0
    address_of_something long @@@something

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
Sign In or Register to comment.