Paolo_911

Using bytes (not words) with MOV

6 posts in this topic

In GXWorks2, using a Q03UDECPU, is it possible to move data with length specified in bytes (8bits) rather than words? I have data coming from a Datalogic scanner, which overwrites data rather than resets/clears it. This data length is specified in bytes, and so I am currently doing math (dividing by 2) to get the number of words to move. This is a problem because it obviously rounds and so sometimes I move an extra byte of data that affects my process.

Example:

/  D3012  K2  D3013   (D3012 is 8bit/byte length) and D3013 is word length

MOV  D3013  D200  (I want  to use D3012 here, but can't)

If I can't use byte length, then maybe there is a way to check to see if D3012 is an odd number. If it is an odd number then I could clear out the last half (8 bits) of D200, after I move the data over?

Share this post


Link to post
Share on other sites

You can use "MOD" instruction to check if it's dividable by 2:

MOD D3012 K2 -> NE 0 -> "FlagIndicatingOdd"

If you receive the flag, it indicates that you have an odd number, and you can remove the 8 bits and possibly generate a number of words increased by one (compared to the division by 2 earlier).

Share this post


Link to post
Share on other sites

Check for ODD or EVEN

IF EVEN move upper 8 bits only

IF ODD move all bits.

 

Ladder.JPG

ODD.JPG

Even.JPG

Share this post


Link to post
Share on other sites

Edit is not working:

I have left an deliberate mistake for you to find :)

Share this post


Link to post
Share on other sites

Thank you both! Thanks Veganic for the mystery haha. Would it be WAND HFF00 in the top rung and WAND HFFFF in the bottom? 

Share this post


Link to post
Share on other sites

You've got it. 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now