A.3 bit shift operation – Rockwell Automation 1775-S4B,D17756.5.3 User Manual SCANNER/MSG HND User Manual
Page 139

Using a Peripheral Communication Module
Appendix A
AĆ5
A =?‘ABC’
B =?‘TEST VARIABILES’
P A‘\X’
P B
The 1775-GA module displays:
ABC TEST VARIABLES
Report generation for the 1775-S4B scanner and GA Basic programming
for the peripheral communication module support the bit shift left and bit
shift right expression operators. These shift operators shift binary values a
specified number of bit positions to the left or right.
In report generation on the 1775-S4B scanner:
Bit shift left shifts a 0 into the right most bit.
Bit shift right does not change the state of the left most bit. If the left
most bit is a 0, a 0 shifts in.
Thus, the sign on the value cannot change due to a shift operation. Refer to
chapter 8 for detailed information on bit shift operation. An example is
given below:
The following command lines show a bit shift execution on a negative
value:
A = -1
B = (A>>1)
P A
P B
The 1775-S4B scanner prints out the value -1 for user symbol A and -1 for
user symbol B which is a bit shift operation on user symbol A.
The bit patterns for the two values are given below:
User Symbol
Value Stored
Bit Pattern (32Ćbits)
A
B
Ć1
Ć1
11... 11111111
11... 11111111
In GA Basic programming on the peripheral communication module:
Bit shift left shifts a 0 into the right most bit.
A.3
Bit Shift Operation