11 - 375 11 - 375
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
SHA
Function
SHift Arithmetic
• Returns the arithmetically shifted value of the memory content of the specified value.
SHA(<numeric expression 1>,<numeric expression 2>)
Syntax
numeric expression 1
• • • •
Specify the target value of the arithmetic shift as an
integer value.
numeric expression 2
• • • •
Specify the shift direction and the number of bits as
an integer value.
Examples
A%=SHA(B%,C%)
• • • •
Shifts the value of B% arithmetically by the amount
of the value C%, and assigns it to A%.
D%=SHA(E%,12)
• • • •
Shifts the value of E% arithmetically to the left by 12
bits and assigns it to D%.
F%=SHA(G%,-4)
• • • •
Shifts the value of G% arithmetically to the right by 4
bits and assigns it to F%.
Description
• The SHA function shifts the memory content of the value specified in <numeric expression
1> arithmetically by the amount of bits specified in <numeric expression 2> and returns the
shifted value.
• Specify by how many bits the value specified in <numeric expression 1> should be
arithmetically shifted in <numeric expression 2>.
If the value of <numeric expression 2> is positive, the bits are shifted to the left and the
least significant bit is put into OFF status (0) sequentially. Thus, if 16 is specified in
<numeric expression 2>, the function value will always be 0.
Shifted to the
left if the value
of <numeric
expression 2>
is positive.
Shifted to the
right if the value
of <numeric
expression 2>
is negative.
If the value of <numeric expression 2> is negative, the bits are shifted to the right and the value
of the most significant bit remains as is. Thus, if -16 is specified in <numeric expression 2>,
the function value will always be either -1 or 0, depending on the value of the most significant bit.
Bit position
Direction of shift (shift by
<numeric expression 2>)
Function value to
be returned
1
0
0
1
0
0
0
0
1
1
0
1
0
0
1
0
0
0
0
0
0
0
0
0
1
1
1
1
1
b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0
1
0
1
0
0
0
1
1
1
0
1
0
1
0
0
0
0
0
0
0
0
1
1
b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0
• • • •
• • • •
• • • •
• • • •
0
0
0
1
1
0
0
1
0
0
0
1
The value whose bits are
shifted arithmetically
Bit position
Direction of shift (shift by
<numeric expression 2>)
Function value to
be returned
• • • •
• • • •
• • • •
• • • •
The value whose bits are
shifted arithmetically
• If either <numeric expression 1> or <numeric expression 2> is specified as a value other
than an integer, the type of the value is converted into integer data and then processed.
• An error occurs if <numeric expression 1> is not within the range from -32768 to 32767.
• An error occurs if <numeric expression 2> is not within the range from -16 to 16.
Содержание A1SD51S
Страница 183: ...11 13 11 13 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS RUN Before swap A 0 H924 A 1 H1159 After swap A 0 H1159 A 1 H924 OK...
Страница 331: ...11 161 11 161 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the CON ON OFF STOP and ZOPEN functions and Section 7 4...
Страница 557: ...11 387 11 387 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the CHR SPACE and SPC functions...
Страница 629: ...11 459 11 459 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the ZOPEN ZSEND and ZCNTL instructions and Section 7 3 4...
Страница 645: ...11 475 11 475 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the ZEVENT ZSIGNAL and DEF ZEVENT instructions...