5.4 Standard Bit Shift Functions
152
FXCPU Structured Programming Manual
(Application Functions)
5.4.2 SHR(_E)
Outline
This function shifts data of specified bit length rightward by the specified number of bits.
1. Format
*1. Output variable
2. Set data
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
1) This function shifts word [unsigned]/bit string [16-bit]/double word [unsigned]/bit string [32-bit] data stored
in a device specified in rightward by "n" bits, and outputs the obtained data to a device specified in
using the data type of data stored in a device specified in .
Data is shifted rightward by "n" bits specified in .
Example: When word [unsigned]/bit string [16-bit] data is stored in a device specified in , and "8" is
specified in
2) "n" bits from the most significant bit become "0".
FX3U(C) FX3G FX2N(C) FX1N(C) FX1S
FX
U
/FX
2C
FX0N FX0(S)
Function name
Expression in each language
Structured ladder ST
SHR
SHR(_IN,_K);
Example:
D10:=
SHR(D0,K1);
SHR_E
SHR_E(EN,_IN,_N,Output label);
Example:
SHR_E(X000,D0,K1,D10);
Variable Description Data type
Input
variable
EN Execution condition Bit
_IN ( )
Word device which stores data to be shifted rightward ANY_BIT
_K,_N ( )
Number of shifted bits ANY_BIT
Output
variable
ENO Execution status Bit
*1 ( )
Word device which will store data obtained by shift ANY_BIT
SHR
*1
D10D0 _IN
_KK1
SHR_E
EN ENO
*1
D10
X000
D0
_IN
_NK1
s
n
d
s
d s
n
s
n
270FH 0 0 10011100001111
0000000000100111
27H
These bits become "0".
270FH 27H
ds
(Word [unsigned]/
bit string [16-bit] data)
(Word [unsigned]/
bit string [16-bit] data)