Shop OBEX P1 Docs P2 Docs Learn Events
Newbie Questions — Parallax Forums

Newbie Questions

Parallel UniverseParallel Universe Posts: 46
edited 2008-03-02 13:58 in Propeller 1
I have a couple of newbie questions about addresses. I know they're 16 bit words for each·main memory byte, but I don't understand a couple of things.
  1. If the par register cuts off the lower two bits of an address, how do you pass the address of a word with cognew to an assembly program?
  2. In TV.spin, how do you get the tile address into 10 bits? What bits do you cut off?

Thanks

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·</Parallel Universe>

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-02-28 01:29
    1) Strictly speaking you can't. It's always a word address. If you don't plan on passing ROM addresses (in the upper 32K), you can shift the word address left by one bit when passing it and shift it right by one bit in your assembly routine to get a word address.

    2) The tile address is the upper 10 bits of a 16 bit address. It's always on a 64 byte boundary. Since all tiles are 16 longs or 64 bytes, this makes sense. In the ROM, the tiles for the characters are on 64 byte boundaries. If you're supplying the tiles, they do have to be allocated on a 64 byte boundary. Since Spin has no provision for doing this for you, you have to do it yourself by allocating an area dynamically on a 64 byte boundary.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-02-28 01:30
    1. Either shift the word's address left by one bit (and write the ASM code to shift it back to the right), or make sure the word is on a long boundary.

    -Phil
  • potatoheadpotatohead Posts: 10,261
    edited 2008-02-28 02:59
    ...or pass the address of a long aligned block of parameters to be passed, where one of those is your word address.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Wiki: Share the coolness!

    Chat in real time with other Propellerheads on IRC #propeller @ freenode.net
  • Parallel UniverseParallel Universe Posts: 46
    edited 2008-02-29 00:45
    Thanks fror responding so quickly! smile.gif
    I should have clarified that I'm trying to pass a variable. After a little experimentation I discovered that the compiler aligns the first variable of an object to a long boundry. Mystery 1 solved!
    But how do you make sure that your tile is· on a 64 byte boundry? Do you define it in a DAT block and then move it to a set address so that you know it's on a 64 byte/16 long boundry?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·</Parallel Universe>
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-02-29 05:34
    I allocated 63 more longs than necessary and then just 0d the last x bits. It wastes memory but it works. The other option is to put it in the memory after the stack.
  • potatoheadpotatohead Posts: 10,261
    edited 2008-02-29 16:18
    Here's a good thread on that: http://forums.parallax.com/forums/default.aspx?f=25&m=210053

    Coupla options presented, including overallocate.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Wiki: Share the coolness!

    Chat in real time with other Propellerheads on IRC #propeller @ freenode.net
  • Parallel UniverseParallel Universe Posts: 46
    edited 2008-03-01 00:07
    So how about something like this:
    CON
      tile_count
     
    PUB tile_init : new_address
      ...
      new_address := @tile_buf>>6<<6
      longmove(new_address, @tile1, tile_count)
     
    DAT
    tile_buf '15 longs
    ...
     
    tile_1 '16 longs
    ...
    

    I assume that longmove can overwright the data·as·it's copying for this to work, otherwise I'd just have to put it beyond the stack.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·</Parallel Universe>
  • Paul BakerPaul Baker Posts: 6,351
    edited 2008-03-01 00:11
    Yes longmove appropriately observes overlaping regions.

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

    Parallax, Inc.
  • deSilvadeSilva Posts: 2,967
    edited 2008-03-01 00:12
    @PU: Not quite... it should be @tile_1>>6<<6 smile.gif
  • Parallel UniverseParallel Universe Posts: 46
    edited 2008-03-01 18:31
    That's what I ment to do, I guess I was thinking that tile_buf was the address of the END of the buffer for some reason.

    Sorry about the black box in my last post, the forum messed up.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·</Parallel Universe>
  • Parallel UniverseParallel Universe Posts: 46
    edited 2008-03-02 13:58
    Thanks to your advice, my TV is displaying my initials in COLOR! hop.gif· Thanks!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·</Parallel Universe>
Sign In or Register to comment.