Shop OBEX P1 Docs P2 Docs Learn Events
Labelling Locations in a DAT Array — Parallax Forums

Labelling Locations in a DAT Array

pjvpjv Posts: 1,903
edited 2013-05-30 13:13 in Propeller 1
Hi All;

Hopefully I can better describe what I'm looking to accomplish than I did last time I posted a question.... so here goes.

Suppose I have declared a zero valued a array in a DAT block in low hub memory; say from some address through $1FF, such as

DAT
HubArray long 0[$1FF - $]

And then I wish to assign labels to access various specific longs in that array.

Is there some more elegant way to do this than breaking up the array definition with those lables interspersed at the required locations, as in:


DAT

HubArray3 long 0[Array4 -$]
HubArray4 long 0[Array8 -$]
HubArray8 long 0[Array22 -$]
HubArray22 long 0[ArrayEnd -$]
ArrayEnd long 0

In other words, is there some clever way to "overlay" labels onto a piece of declared hub memory ??

Thanks,

Peter (pjv)

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2013-05-29 16:36
    Let's say your array starts at location/register BASE then simply put something like this at the end (out of harms way) of your code:
    org     BASE
    
    HubArray3       res     <size of HubArray3 in longs>
    HubArray4       res     <size of HubArray4 in longs>
    HubArray8       res     <size of HubArray8 in longs>
    HubArray22      res     <size of HubArray22 in longs>
    ArrayEnd        res     <size of ArrayEnd in longs>
    
    If you need them as hub addresses instead of cog register indexes then you'll have to adjust the res parameters accordingly (res expects a long count). The principle is the same.

    You could also use CONstant declarations, e.g. #0, base[5], one, two[2], end to the same effect.
  • pjvpjv Posts: 1,903
    edited 2013-05-30 06:35
    Hi Marko;

    Thanks for your response.

    What you suggest works for Cog memory, but what I need is some lableling overlay procedure for Hub memory, and for that it does not work. The "res" directive will not modify the Hub location pointer when the program is being compiled, so the "res" is ignored.

    I can continue to break up the Array declarations into it's component pieces, but I was hoping for something more elegant.

    Cheers,

    Peter (pjv)
  • Mike GMike G Posts: 2,702
    edited 2013-05-30 06:40
    You can allocate an array of pointers that hold the starting addresses of parallel jagged arrays. See app notes http://www.parallaxsemiconductor.com/an003
  • kuronekokuroneko Posts: 3,623
    edited 2013-05-30 06:43
    pjv wrote: »
    What you suggest works for Cog memory, but what I need is some lableling overlay procedure for Hub memory, and for that it does not work. The "res" directive will not modify the Hub location pointer when the program is being compiled, so the "res" is ignored.
    I figured as much (i.e. that it wouldn't be this easy). Can you provide an example which shows which part of your code is trying to access what? E.g. do you share between SPIN and PASM or is it PASM only etc ...
  • Dave HeinDave Hein Posts: 6,347
    edited 2013-05-30 06:59
    What's wrong with breaking the array up? It seems that's the easiest way to do it, especially since all the elements are initialized to zero.
  • pjvpjv Posts: 1,903
    edited 2013-05-30 13:13
    @ Mike; Yes, but I wanted not to add any code..... just labels. The appnote was an interesting read though, thanks for that.

    @ Kuroneko; The access is for both, Spin and PASM. I am setting up a "low memory" reserved area for "direct" mailbox access from each of 7 assembler cogs.

    @ David; Right. That is what I'm doing presently, and is quite workable. I was hoping for a bit cleaner syntax to create the array's access labels.

    Thanks all


    Cheers,

    Peter (pjv)
Sign In or Register to comment.