13: BIT SHIFT / ROTATE INSTRUCTIONS
13-4 USER’S MANUAL
54 ROTR (Rotate Right)
Key Operation
Valid Operands (Standard Processing)
In the high-speed processing mode, data registers for this instruction are limited to D0 through D31.
Since the bit rotate instructions are executed in each scan while input is on, a pulse input from an SOTU or SOTD instruc-
tion should be used as required.
Example: ROTR
Operand Function I Q M T C R D Constant Repeat
S1 (Source 1) Data for bit rotation ——————0-99 — —
bit Quantity of bits to rotate ——————— 1-15 —
ROTR S1
****
bit
**
When input is on, 16-bit data of the data register designated by S1 is rotated to the
right by the quantity of bits designated by operand bit. The last bit status rotated out
of the data register is set to a carry (special internal relay M303).
Before rotation: 1 0 1010 1 0 1 1 1101 0 0
MSB LSB
S1
When bits to rotate = 1
0After rotation: 1 1100 0 0 1 1 0010 1 1
CY
M303
MSB LSB
S1
1
CY
M303
Rotate to the right
ADV
2 S1
ROTR
( ) : 1bit
5
CC=
4
Enter operand S1 and the quantity of bits to rotate.
Repeat cannot be designated for bit rotate instructions.
To exit, press the key.
M301
ROTR
REP
**
M301 is the initialize pulse special internal relay.
When MICRO
3
starts operation, the MOV (move) instruction sets 13 to data
register D20.
Each time input I1 is turned on, 16-bit data of data register D20 is rotated to
the right by 1 bit as designated by operand bit. The last bit status rotated out
of the data register is set to a carry (special internal relay M303).
Before rotation: D20 = 13
0 0 0000 0 0 0 0 0100 1 1
CY
M303
MSB LSB
D20
After first rotation: D20 = 16387
Bits to rotate = 2
SOTU
I1
MOV S1
13
D1
D20
S1
D20
bit
2
After second rotation: D20 = 53248
00 0 0001 0 0 0 0 1000 0 1
CY
M303
MSB LSB
D20
11 0 0011 0 0 0 0 0000 0 0
CY
M303
MSB LSB
D20