4-58 Series 90-30/20/Micro Programmable Controllers Reference Manual September 1998 GFK-0467K
4
ROL and ROR (WORD)
The Rotate Left (ROL) function is used to rotate 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 (ROR) 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 string length of 1 to 256 words can be selected for either function.
The number of places specified for rotation must be more than zero and less than the number of bits
in the string. Otherwise, no movement occurs and no power flow is generated.
The ROL or ROR 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.
_____
| |
(enable) —| ROL_|— (ok)
| |
| WORD|
| |
(word to be rotated) —|IN Q|— (output parameter Q)
| |
| LEN |
|00001|
| |
(number of bits) —|N |
|_____|
Parameters:
Parameter Description
enable When the function is enabled, the rotation is performed.
IN IN contains the first word to be rotated.
NN contains the number of places that the array is to be rotated.
ok The ok output is energized when the rotation is energized and the rotation length is not
greater than the array size.
QOutput Q contains the first word of the rotated array.
LEN LEN is the number of words in the array to be rotated.