Shop OBEX P1 Docs P2 Docs Learn Events
Trouble with "@" cog address — Parallax Forums

Trouble with "@" cog address

potatoheadpotatohead Posts: 10,261
edited 2009-09-20 08:13 in Propeller 1
I've attached my text generator code. There is a table in the COG called "pixel_table", and it's offset from the beginning of the cog 90 longs.

Rather than count up all the $(#%*&($#% instructions, I thought it would be simple to just do:

ptable LONG @pixel_table

,or

ptable LONG @pixel_table - @cogstart

to arrive at that 90 longs to use as part of a self-modify pointer index to that table.

That isn't working, and I'm not understanding why this morning. Any hints as to what I've either forgotten, or haven't yet learned?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Wiki: Share the coolness!
Chat in real time with other Propellerheads on IRC #propeller @ freenode.net
Safety Tip: Life is as good as YOU think it is!

Comments

  • BaggersBaggers Posts: 3,019
    edited 2009-09-19 17:56
    shouldn't it just be

    ptable long pixel_table

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    http://www.propgfx.co.uk/forum/·home of the PropGFX Lite

    ·
  • heaterheater Posts: 3,370
    edited 2009-09-19 18:00
    The problem is that using @ to get an address to initialize a long in a DAT section does not produce the same address that @ returns when used in normal old Spin code.

    Don't ask me why. I had a long debate about this here a long time ago. It still does not make sense to me and I think it's nuts. But there it is and we have to live with it.

    What it actually gets you is an address that needs the start of the object adding on to it. This you can get with @0. Some how you have to add that onto all those initialized longs.

    I initialize all such things with Spin code now.

    If you have BST I belive using @@@ might do what you want to initialize a long but I have never used it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-09-19 18:02
    You should use "ptable LONG pixel_table" to get the cog address of "pixel_table". You can also use "pixel_table - cogstart" if "cogstart" is the address of the first location in the cog (in the DAT section). The "@" operator is intended for use with Spin code where things are byte addressable in hub memory. Read the description of "@" and "@@" in the Propeller Manual for a description.

    Remember that you can use DAT sections as a place to put data referenced from Spin code as well as a place to write assembly code. The "@" operator produces the Spin address of the information while just putting the label by itself produces the cog address. This is complicated by the fact that the Spin compiler doesn't know where it will put the DAT information until after it has compiled everything, hence the need for a "@@" operator.

    Post Edited (Mike Green) : 9/19/2009 6:08:35 PM GMT
  • heaterheater Posts: 3,370
    edited 2009-09-19 18:02
    Sorry yes, your table is in COG not HUB so Baggers is right. Teach me not to look at the code first [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • potatoheadpotatohead Posts: 10,261
    edited 2009-09-19 19:06
    Smile!!! That was really stupid!

    Thanks baggars!

    (goes on to building color cog now)

    @Mike -- Of course. I did go and read it. When I'm working between COG and HUB, there are times when I end up with conflicts. I think I've got those sorted, but I just flat out didn't consider where I was addressing.

    Well, some things are really, really easy now! I messed with this for longer than I care to admit [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Wiki: Share the coolness!
    Chat in real time with other Propellerheads on IRC #propeller @ freenode.net
    Safety Tip: Life is as good as YOU think it is!
  • BaggersBaggers Posts: 3,019
    edited 2009-09-20 08:13
    lol, no probs, anytime mate
    not really got time to help, out much on here, as I'm full of man-flu, and working from 8am to around midnight, which isn't good when you're healthy, let alone ill.

    but all will be done by Wednesday night, and I can then go fall into bed for a few days lol

    but I use my little break time, to have a little mooch around this great forum, and if I can help, I do [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    http://www.propgfx.co.uk/forum/·home of the PropGFX Lite

    ·
Sign In or Register to comment.