Dixon Posted February 21, 2018 Report Posted February 21, 2018 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
chelton Posted February 21, 2018 Report Posted February 21, 2018 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
Michael Walsh Posted February 21, 2018 Report Posted February 21, 2018 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...
Michael Walsh Posted February 21, 2018 Report Posted February 21, 2018 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): Here is the Watch Window after executing the instruction one time with the values in your initial question: 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: Then click the + button and navigate to the library file: Once you have added the library to the project, the MoveMask Function will show in your Toolbox: 1
chelton Posted February 21, 2018 Report Posted February 21, 2018 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.
innoaloe Posted February 24, 2018 Report Posted February 24, 2018 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now