Dr. Glenn (Customer) asked a question.

I need to parse a double-word value (DoMore Dxxxx) to TWO successive V-memory locations

I need to find a way to "break" a double-word (Example: 123456789) into at the fifth digit: (12345) and place in in the first V-memory location, then put the rest (6789) into the next V-memory location. Why do you ask? I need to transmit a block of data to Dataworx, and it only accepts V-memory transfers. I'm using a DoMore.

 

Any hints or ideas welcome.


  • Dr. Glenn (Customer)

    Modulo conversion snippetI figured it out! I used three steps:

    1. use MODULO 100000 on the D-word value to derive a 5-digit remainder
    2. Write this remainder to the first V-memory
    3. SUBTRACT the value of the remainder from the original value to zero the lowest 5 digits, then divide the expression by 10000 and place the result in the second V-memory!
    Expand Post
  • HOST_franji1 (HOST Engineering)

    You want it split at decimal digits, not binary digits. Use modulo arithmetic in a MATH along with integer division.

     

    V0 = D0 % 10000

    V1 = D0 / 10000

     

    so D0 123456789

    V0 equal to 6789

    V1 equal to 12345

    Expand Post
    • Dr. Glenn (Customer)

      Thank you, Franji1

      I came up with that very solution two minutes prior to your thoughtful solution. Thank you!

  • Tinker (Customer)

    I'm guessing that going from signed to unsigned may be the problem, maybe, I don't know what Dataworx is doing when it recombines the two words. But one might take a look at casting; help topic DMD0309

    Or there might be bigendian smallendian problem

    • Dr. Glenn (Customer)

      I did try casting but it didn't give me what I wanted. Converting from Signed to Unsigned proved problematic: the values changed. Thank you for answering!