Shop OBEX P1 Docs P2 Docs Learn Events
merge_words_into_long and split_long_into_words operations in Spin — Parallax Forums

merge_words_into_long and split_long_into_words operations in Spin

youngdaveyoungdave Posts: 70
edited 2009-08-10 03:09 in Propeller 1
Dear All
I have an array of word variables. I need to select two of these words according to criteria C, combine them in a temporary long variable, rotate that long left by X bits, and then split that long back into two words.
Anyone have any ideas on how to do merge_words_into_long and split_long_into_words operations in Spin?
TIA David Young

Comments

  • localrogerlocalroger Posts: 3,452
    edited 2009-08-09 22:52
    There are several ways. What I would do is reference word[noparse][[/noparse]@var] and word[noparse][[/noparse]@var+2] wher var is the long. In spin you can do that both for reading and assignment.
  • ericballericball Posts: 774
    edited 2009-08-10 00:52
    localroger said...
    There are several ways. What I would do is reference word[noparse][[/noparse]@var] and word[noparse][[/noparse]@var+2] wher var is the long. In spin you can do that both for reading and assignment.
    Or word[noparse][[/noparse]@longvar][noparse][[/noparse]0] and word[noparse][[/noparse]@longvar][noparse][[/noparse]1].· Just remember the propeller is little endian, so word[noparse][[/noparse]@longvar][noparse][[/noparse]1] is the most significant bits in the long.· And code the variable as a LONG which you access as two WORDs rather than two WORDs which you try to access as a LONG - in order to ensure the variable is LONG aligned.

    ·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Composite NTSC sprite driver: Forum
    NTSC & PAL driver templates: ObEx Forum
    OnePinTVText driver: ObEx Forum


    Post Edited (ericball) : 8/10/2009 12:30:39 PM GMT
  • youngdaveyoungdave Posts: 70
    edited 2009-08-10 03:09
    Thanks very much for the ideas.
    David Young
Sign In or Register to comment.