User Manual
Chapter 10
GFK-1503F
Jan 2020
Instruction Set Reference
107
10.1.7
Bit Operation Functions Rotate Bits Right,Rotate Bits
Left
The Rotate Left function rotates all the bits in a string a specified number of places to the
left. When rotation occurs, the specified number of bits is rotated out of the input string to
the left and back into the string on the right.
The Rotate Right function rotates the bits in the string to the right. When rotation occurs,
the specified number of bits is rotated out of the input string to the right and back into the
string on the left.
A length of 1 to 256 words can be selected for either function. The number of places to
rotate must be more than zero and less than the number of bits in the string.
The Rotate Bits function passes power flow to the right, unless the number of bits specified
to be rotated is greater than the total length of the string or is less than zero. The result is
placed in output string Q. If you want the input string to be rotated, the output parameter
Q must use the same memory location as the input parameter IN. The entire rotated string
is written on each scan that power is received.
Figure 69
Parameters of the Rotate Bits Right / Left Functions
Input/ Output Choices
Description
enable
flow
When the function is enabled, the rotation is
performed.
IN
I, Q, M, T, S, G, R, AI, AQ
IN contains the first word to be rotated.
N
I, Q, M, T, G, R, AI, AQ,
constant
N contains the number of places the array is to be
rotated.
ok
flow, none
The OK output is energized when the rotation is
energized and the rotation length is not greater
than the array size.
Q
I, Q, M, T, SA, SB, SC, G, R,
AI, AQ
Output Q contains the first word of the rotated
array.
Example
In the example, whenever input %I0001 is set, the input bit string in location %R0001 is
rotated 3 bits. The result is placed in %R0002. The input bit string %R0001 is not changed by
the function. If the same reference is used for IN and Q, a rotation will occur in place.