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".
FX
3U(C)
FX
3G
FX
2N(C)
FX
1N(C)
FX
1S
FX
U
/FX
2C
FX
0N
FX
0(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
D10
D0
_IN
_K
K1
SHR_E
EN
ENO
*1
D10
X000
D0
_IN
_N
K1
s
n
d
s
d
s
n
s
n
270FH
0
0
1
0
0
1
1
1
0
0
0
0
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
1
1
1
27H
These bits become "0".
270FH
27H
d
s
(Word [unsigned]/
bit string [16-bit] data)
(Word [unsigned]/
bit string [16-bit] data)