GFK-0467K Chapter 4 Series 90-30/20/Micro Instructions Set 4-55
4
SHL and SHR (WORD)
The Shift Left (SHL) function is used to shift all the bits in a word or group of words to the left by a
specified number of places. When the shift occurs, the specified number of bits is shifted out of the
output string to the left. As bits are shifted out of the high end of the string, the same number of bits
is shifted in at the low end.
MSB LSB
B2 1101111111001000B1
The Shift Right (SHR) function is used to shift all the bits in a word or group of words a specified
number of places to the right. When the shift occurs, the specified number of bits is shifted out of
the output string to the right. As bits are shifted out of the low end of the string, the same number
of bits is shifted in at the high end.
MSB LSB
B1 1101111111001000B2
A string length of 1 to 256 words can be selected for either function.
If the number of bits to be shifted (N) is greater than the number of bits in the array (LEN) * 16, or
if the number of bits to be shifted is zero, then the array (Q) is filled with copies of the input bit
(B1), and the input bit is copied to the output power flow (B2). If the number of bits to be shifted
is zero, then no shifting is performed; the input array is copied into the output array; and input bit
(B1) is copied into the power flow.
The bits being shifted into the beginning of the string are specified via input parameter B1. If a
length greater than 1 has been specified as the number of bits to be shifted, each of the bits is filled
with the same value (0 or 1). This can be:
The boolean output of another program function.
All 1s. To do this, use the special reference nickname ALW_ON as a permissive to input B1.
All 0s. To do this, use the special reference nickname ALW_OFF as a permissive to input B1.
The SHL or SHR function passes power flow to the right, unless the number of bits specified to be
shifted is zero.
Output Q is the shifted copy of the input string. If you want the input string to be shifted, the output
parameter Q must use the same memory location as the input parameter IN. The entire shifted
string is written on each scan that power is received. Output B2 is the last bit shifted out. For
example, if four bits were shifted, B2 would be the fourth bit shifted out.