Shop OBEX P1 Docs P2 Docs Learn Events
Wordmove question — Parallax Forums

Wordmove question

Damien AllenDamien Allen Posts: 103
edited 2007-05-27 13:57 in Propeller 1
Is it possible to use the wordmove instruction to copy words into a byte array?

For example:


byte newarray[noparse][[/noparse]30]
word wordvars[noparse][[/noparse]5]
 
wordmove(@newarray[noparse][[/noparse]3],@wordvars[noparse][[/noparse]2], 2)


I would like to do this because my modbus driver works with bytes but the registers that i'm simulating are words. It would make everything easier if i could achieve this.

i've tried it but without success, i could use a repeat loop but the manual says that wordmove is faster.

Damo

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-05-27 13:43
    It will work IF the byte array is word aligned. I believe the compiler allocates space in an object for long variables first, then word variables, then byte variables. As long as newarray is only preceeded by byte variables with an even number of bytes, you should be ok.
  • Damien AllenDamien Allen Posts: 103
    edited 2007-05-27 13:57
    Thanks Mike, i've located my problem. Silly really. my byte array wasn't big enough to hold what i was trying to copy into it and i was overwriting other data.

    Cheers

    Damo
Sign In or Register to comment.