Dixon

Mask Move in Sysmac Studio

7 posts in this topic

I need to do a "Mask Move" in Sysmac Studio. AB has this Instruction and i am trying to find or create the same functionality in Sysmac Studio. 

Example:

Source: 1011 0011 1100

Mask: 1001 1111 1001

Destination: 1100 0000 1111


Destination after masked move: 1101 0011 1110

Share this post


Link to post
Share on other sites

I would have thought the destination after the masked move would be 

1001 0011 1000

All the masked move instruction does is a binary AND the source with the mask

Share this post


Link to post
Share on other sites

 

6 minutes ago, chelton said:

All the masked move instruction does is a binary AND the source with the mask

@cheltonI thought so also at first, but after some investigation into this instruciton, I discovered that if the mask has a 0 in it, the corresponding bit in the destination is unchanged.  I am working on a solution now...

 

Share this post


Link to post
Share on other sites

I was able to write up a solution.  This assumes that the Source, Mask and Destination are all datatype WORD.  This is what the code looks like (disregard my mixed use of Global and Local variables, it is not important):

MaskMove.jpg.a17addead661d1e2ff820b835f8

Here is the Watch Window after executing the instruction one time with the values in your initial question:

Values.thumb.jpg.7e0c7b3975d16319235127b

I created a function that did this and put it in a library file.  Here is the file:

MaskMove.slr

Here is my project with both the above code and the function included:

Mask Move testing.smc2

 

To add the library to your project, choose the Project menu, then Library, then Show References as shown below:

library1.jpg.d6f881c26cb53b779524508180c

Then click the + button and navigate to the library file:

library2.thumb.jpg.189c6bc31719cfac767d2

Once you have added the library to the project, the MoveMask Function will show in your Toolbox:

ToolboxMoveMask.jpg.b0b6438ea8f00f107022

1 person likes this

Share this post


Link to post
Share on other sites
1 hour ago, Michael Walsh said:

 

@cheltonI thought so also at first, but after some investigation into this instruciton, I discovered that if the mask has a 0 in it, the corresponding bit in the destination is unchanged.  I am working on a solution now...

 

Yes you are correct my mistake.

another approach would be

source  XOR destination = result

result AND mask = result 2

result 2 XOR destination = destination.

Share this post


Link to post
Share on other sites

This was a fun topic that I tried to test it also.
A little bit off topic but from the test I just found out that "ANY" datatype is not available as a Custom Function In/Out data type.

Kinda weird since some prebuild functions like "AryByteTo" have In/Out variables with ANY datatype, but we cannot access it for custom functions.
By the way I checked the NJ firmware, and the ANY datatype definitely exposed there. :D

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