2 Instruction Descriptions
2-364
NJ-series Instructions Reference Manual (W502)
ROL and ROR
These instructions rotate a bit string by one or more bits.
* If you omit the input parameter, the default value is not applied. A building error will occur.
These instructions rotate data to rotate In (bit string data) by the number of bits specified in number of
bits Num. Bits that are shifted out of the register are inserted into the other end of the register.
z ROL
The ROL instruction rotates bits from right to left (from least-significant to most-significant bits).
ROL: Rotates the bit string to the left (toward the higher bits).
ROR: Rotates the bit string to the right (toward the lower bits).
Instruction Name FB/FUN Graphic expression ST expression
ROL Rotate N-bits Left FUN Out:=ROL(In, Num);
ROR Rotate N-bits Right FUN Out:=ROR(In, Num);
Variables
Name Meaning I/O Description Valid range Unit Default
In Data to
rotate
Input
Data to rotate Depends on data type.
--- *
Num Number of
bits
Number of bits to rotate 0 to No. of bits in In Bits 1
Out Processing
result
Output Processing result Depends on data type.
--- ---
Boolean
Bit strings Integers
Real
numbers
Times, durations,
dates, and text strings
BOOL
BYTE
WORD
DWORD
LWORD
USINT
UINT
UDINT
ULINT
SINT
INT
DINT
LINT
REAL
LREAL
TIME
DATE
TOD
DT
STRING
In OK OK OK OK
Num OK
Out Must be same data type as In
Function
(@)ROL
EN ENO
In Out
Num
(@)ROR
EN ENO
In Out
Num