Shop OBEX P1 Docs P2 Docs Learn Events
Overlapping bytemove/longmove/wordmove — Parallax Forums

Overlapping bytemove/longmove/wordmove

rokickirokicki Posts: 1,000
edited 2006-05-17 04:18 in Propeller 1
If the regions pointed to by bytemove are overlapping, in either the
positive or negative direction, is bytemove still guaranteed to do the
right thing? Ditto for the other two. Thanks!

Comments

  • cgraceycgracey Posts: 14,133
    edited 2006-05-16 21:33
    You bet! It figures out whether to do a forward or reverse move automatically.
    rokicki said...
    If the regions pointed to by bytemove are overlapping, in either the
    positive or negative direction, is bytemove still guaranteed to do the
    right thing? Ditto for the other two. Thanks!
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
  • rokickirokicki Posts: 1,000
    edited 2006-05-16 21:41
    Great!

    I'm still confused by a few things though.

    If I have:

    var long curline, put

    what is the difference between the expressions

    byte[noparse][[/noparse]curline][noparse][[/noparse]put]

    and just

    curline[noparse][[/noparse]put] ?

    Also, the description of @@ makes me a bit concerned; it says if I have

    dat
    foo "baz", 0
    foo2 "baz2", 0
    bar long @foo, @foo2

    that I need to use @@bar[noparse][[/noparse]0] and @@bar instead of @bar[noparse][[/noparse]0] and @bar
    because the values in bar are not offset by the beginning of the data space.

    Can we get a clarification of exactly when we can expect the values to be
    so offset, and when we cannot? If I use

    x := @foo

    in a program, x gets the address of foo, so I don't need to use @@, right?
    So why doesn't it when I use

    dat
    bar long @foo

    Thanks for all the help!
  • cgraceycgracey Posts: 14,133
    edited 2006-05-17 04:18
    rokicki said...
    Great!

    I'm still confused by a few things though.

    If I have:

    var long curline, put

    what is the difference between the expressions

    byte[noparse][[/noparse]curline][noparse][[/noparse]put]
    Byte[noparse][[/noparse]curline][noparse][[/noparse]put] will access a byte pointed to by 'curline' with 'put' used as a byte·index. In other words, the byte will be located at the value of curline plus the value of put.

    and just

    curline[noparse][[/noparse]put] ?
    Curline[noparse][[/noparse]put] will access the put'th long beginning at the address of curline. Curline is a long, so the index (put) will be shifted left by 2 bits.

    Also, the description of @@ makes me a bit concerned; it says if I have

    dat
    foo "baz", 0
    foo2 "baz2", 0
    bar long @foo, @foo2

    that I need to use @@bar[noparse][[/noparse]0] and @@bar instead of @bar[noparse][[/noparse]0] and @bar
    because the values in bar are not offset by the beginning of the data space.

    Can we get a clarification of exactly when we can expect the values to be
    so offset, and when we cannot? If I use

    x := @foo

    in a program, x gets the address of foo, so I don't need to use @@, right?
    So why doesn't it when I use

    dat
    bar long @foo

    Okay. @@ is used to add the object's base address to some value, usually the address of something in a DAT section. Say you have a list of strings:

    DAT
    s1·· byte· "This is string 1.",0s2·· byte· "This is string 2. Bla Bla.",0s3·· byte· "This is string 3. Note these all have different lengths.",0s4·· byte· "This is string 4....",0

    stringtable word @s1,@s2,@s3,@s4· 'Here is a table of the string offsets within the object

    ...in a PUB/PRI you could access these strings as an array...

    · repeat i from 0 to 3
    ··· printstring(@@stringtable[noparse][[/noparse]i])

    ...printstring is some routine which wants the start address of some string in memory. Stringtable is a list of words which contains offsets of various strings. Stringtable[noparse][[/noparse]i] returns the offset of a particular string. The @@ operator adds the object's base address to give you the actual main memory address of string 'i'.





    Thanks for all the help!
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
Sign In or Register to comment.