Rockwell Automation 1775-S5_SR5,D17756.5.5 User Manual PLC-3 FAMILY I/0 User Manual

Page 101

Advertising
background image

Programming DH and DH+

Message Procedures

Chapter 6

6-10

Bitwise Operators

Bitwise operators manipulate the individual bits in a 32-bit operand.

The bitwise 32-bit complement (.BNOT.) inverts the state of each bit in the
32-bit expression. That is, bits set to 1 invert to 0, and bits set to 0 are
invert to 1.

The bitwise 32-bit AND (.BAND.) forms a bit-by-bit logical AND of two
32-bit operands. No carry occurs from one bit position to the next within
the operand. For example:

A contains the bit pattern:

10101010010011110010101010101011

B contains the bit pattern:

01110101011100100010101110001010

Then the assignment C=A.BAND.B yields

C contains the bit pattern:

00100000010000100010101010001010

The bitwise 32-bit EXCLUSIVE OR (.BXOR.) forms a bit-by-bit logical
XOR of two 32-bit operands. No carry occurs from one bit position to the
next within the operand.

The bitwise 32-bit OR (.BOR.) forms the bit-by-bit logical OR of two
32-bit operands. No carry occurs from one bit position to the next within
the operand.

Arithmetic Operators

The arithmetic operations are addition, subtraction, multiplication, and
division. These are binary (not BCD) operations that produce 32-bit
signed integer results.

You should assign a result from these arithmetic operations to a 32-bit
destination. However, you can assign the result to a 16-bit destination if
the result is small enough in absolute value (less than 65,535) to fit into 16
bits. If you assign the result to a 16-bit word and the result is too large to
fit into 16 bits, then an error code of 215 results.

The scanner does not indicate overflow or underflow conditions with
arithmetic operations.

Advertising