2 Instruction Descriptions
2-360
NJ-series Instructions Reference Manual (W502)
SHL and SHR
These instructions shift 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 shift data to shift In (bit string data) by the number of bits specified in number to shift
Num. The bits that are shifted out of the register are discarded and zeros are inserted into the other end
of the register.
z SHL
The SHL instruction shifts bits from right to left (from least-significant to most-significant bits).
SHL: Shifts the bit string to the left (toward the higher bits).
SHR: Shifts the bit string to the right (toward the lower bits).
Instruction Name FB/FUN Graphic expression ST expression
SHL N-bit Left Shift FUN Out:=SHL(In, Num);
SHR N-bit Right Shift FUN Out:=SHR(In, Num);
Variables
Name Meaning I/O Description Valid range Unit Default
In Data to
shift
Input
Data to shift Depends on data type. ---
*
Num Number to
shift
Number of bits to shift 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
(@)SHL
EN ENO
In Out
Num
(@)SHR
EN ENO
In Out
Num