Mitsubishi QD51 Programming Manual page 39

Logic controller
Hide thumbs Also See for QD51:
Table of Contents

Advertisement

2 THE BASICS OF AD51H-BASIC
63 AND 16 • • • • • • • • • • 16
15 AND 14 • • • • • • • • • • 14
-1 AND 8
• • • • • • • • • • 8
4 OR 0
• • • • • • • • • • 6
10 OR 10 • • • • • • • • • • 10
-1 OR -2
• • • • • • • • • • -1
NOT X
• • • • • • • • • • -(X+1)
2 - 22
Note
• Operations involving logical operators are performed after converting the numeric
constant or numeric variable to an integer within the range from –32768 to
+32767 (expressed as two's-compliment number if negative).
If the value exceeds the range from –32768 to +32767, an Overflow error will
occur.
• Logical operations are performed bitwise between two integers. The
corresponding bits in the two integers determine each resulting bit.
For example, an AND operator can be used to "mask" all bits except a certain bit.
Then an OR operator can be used to combine the contents of the two bytes. This
allows the creation of a specific binary number.
The following describes how this is done using logic operators.
Example
63 is 111111 in binary code. 16 is 10000 in binary code.
Therefore, 63 AND 16 = 16.
AND 16 • • • 0000 0000 0001 0000
15 is 1111 in binary code. 14 is 1110 in binary code.
Therefore, 15 AND 14 = 14.
-1 is 1111111111111111 in binary. 8 is 1000 in binary.
Therefore, –1 AND 8 = 8.
4 is 100 in binary. 2 is 10 in binary.
Therefore, 4 OR 2 = 6.
OR 2 • • • 0000 0000 0000 0010
10 is 1010 in binary code. Therefore, 1010 OR 1010 = 1010 (in
other words, 10.)
-1 is 1111111111111111 in binary code. –2 is 1111111111111110
in binary code. Therefore, -1 OR -2 = -1.
Two's-compliment of an arbitrary integer is the value obtained by
reversing all the bits of the integer and adding 1.
Bit reversal • • • 1111 1111 1111 1100
63 • • • 0000 0000 0011 1111
0000 0000 0001 0000 • • • 16
4 • • • 0000 0000 0000 0100
0000 0000 0000 0110 • • • 6
3 • • • 0000 0000 0000 0011
Add 1 • • •
–3 • • • 1111 1111 1111 1101 • • • two's-compliment
MELSEC-Q
1
numbers
2 - 22

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ad51h-s3Qd51-r24A1sd51s

Table of Contents