Shop OBEX P1 Docs P2 Docs Learn Events
Pointer arithmetic in Propeller assembly - is memory byte-addressable or only l — Parallax Forums

Pointer arithmetic in Propeller assembly - is memory byte-addressable or only l

Dennis FerronDennis Ferron Posts: 480
edited 2007-02-24 19:00 in Propeller 1
Is the RAM in Propeller assembly byte addressable, or does everything have to happen in 32-bit increments? For instance, if I am pointing at one long, and want to advance to the next, would I say "add ptr, #4" (four bytes) or would I say, "add ptr, 1" (one long)? If I'm pointing at the 100th long from 0, is the literal value of that pointer "100" (one-hundred longs past 0) or is it "400" (the four-hundredth byte)?

Comments

  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-02-24 01:29
    Cog ram is in long, hub ram byte addressable but follows boundries. Here's the easy way to remember:

    When a byte is addressed (RD/WRBYTE) the entire pointer is used.
    When a word is addressed the last bit of the pointer is X (dont care).
    When a long is addressed the last 2 bits are X.

    So when interating through hub memory, bytes are 1, words are 2 and longs are 4.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • CJCJ Posts: 470
    edited 2007-02-24 01:29
    cog ram is only long addressable
    hub ram is byte, word, and long addressable with bytewise numbering, I think I read in a thread that alignment is enforced for word and longs though, not 100% sure on that though

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Who says you have to have knowledge to use it?

    I've killed a fly with my bare mind.
  • Dennis FerronDennis Ferron Posts: 480
    edited 2007-02-24 03:11
    Thanks.
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2007-02-24 19:00
    Remember also that there are 512 longs in the COG ram. That is nine bits, and it is no coincidence that the source and destination fields are also nine bits. You will often see self-modifying code, involving the source and destination fields within an instruction, as pointers to tables or other stuctures in COG ram.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
Sign In or Register to comment.