7. APPLICATION INSTRUCTIONS
7 − 18
MELSEC-A
Program Examples WXNR
(1) Program which compares the bit pattern of the 16-bit data of X30 to 3F and that
of the 16-bit data of D99 and stores the number of the same bit patterns and the
number of different bit patterns to D7 and 8, respectively, when XC turns on.
(2) Program which compares the bit pattern of the 16-bit data of X30 to 3F and that
of the data of D99 and stores the result to D7 when X0 turns on.
X00C
0
P
SUM D99
Exclusive NOR of the 16-bit data of X30 to 3F
and the data of D99 is performed and the result is
stored into D99.
Comparing the 16-bit data of D99, the total
number of "1" bits is stored into A0.
• Coding
0 LD X00C
1 WXNRP K4X030 D99
6 SUMP D99
9 MOVP A0 D7
14 MOVP K16 D8
19 -P A0 D8
24 END
Data of A0 (number of the same bits) is stored
into D7.
PK4
WXNR X030 D99
P
MOV A0 D7
PK
MOV 16 D8
P
- A0 D8
Operation of 16 - A0 is performed and the result
(number of different bits) is stored into D8.
16 is stored into D8 in BIN.
X000
0
P K4
WXNR X030 D99 D7
• Coding
0 LD X000
1 WXNRP K4X030 D99 D7
8 END