1 dual operand (dyadic) operators (continued) – Rockwell Automation 1771-DB Basic Module User Manual - Series A User Manual

Page 81

Advertising
background image

Operating Functions

Chapter 5

5–44

5.5.1.1 Comments on logical operators .AND.,.OR. and .XOR.

These operators perform a BIT-WISE logical function on valid
INTEGERS. This means both arguments for these operators are between 0
and 65535 (0FFFFH) inclusive. If they are not, the BASIC Module
generates a BAD ARGUMENT ERROR. All non-integer values are
truncated, not rounded. Use the following chart for bit manipulations on 16
bit values.

Hex Decimal

To set bit

0

1

2

3

4

5

6

7

10

11

12

13

14

15

16

17

.OR. VARIABLE WITH

0001H

0002H

0004H

0008H

0010H

0020H

0040H

0080H

0100H

0200H

0400H

0800H

1000H

2000H

4000H

8000H

1

2

4

8

16

32

64

128

256

512

1024

2048

4096

8192

16384

32768

Example: 10 A= A .OR. 0100H:REM SET BIT 10

To clear bit

0

1

2

3

4

5

6

7

10

11

12

13

14

15

16

17

.AND. VARIABLE WITH

0FFFEH

0FFFDH

0FFFBH

0FFF7H

0FFEFH

0FFDFH

0FFBFH

0FF7FH

0FEFFH

0FDFFH

0FBFFH

0F7FFH

0EFFFH

0DFFFH

0BFFFH

7FFFH

65534

65533

65531

65527

65519

65503

65471

65407

65279

65023

64511

63487

61439

57343

49151

32767

Example: 10 A= A .AND. 0F7FFH: REM CLR BIT 13

To clear all bits

.XOR. VARIABLE WITH

ITSELF

Example: 10 A = A.XOR.A : REM CLR A

5.5.1
Dual Operand (dyadic)
Operators (continued)

Advertising