Mitsubishi Electronics FXCPU Video Game Controller User Manual


 
11 Applied Instructions (Data Operation)
11.4 SUM / Sum of Active Bits
238
FXCPU Structured Programming Manual
[Basic & Applied Instruction]
3. Operation result of the device specified by according to the value specified by (in
16-bit operation)
Cautions
1) While the command input is OFF, the instruction is not executed. The output of the number of bits in the
ON status is latched in the previous status.
2) Some restrictions to applicable devices
S1:The FX
3G, FX3GC, FX3U and FX3UC PLCs only are applicable.
S2:The FX
3U and FX3UC PLCs only are applicable.
Program examples
When X000 is ON, the number of bits in the ON status in D0 is counted, and stored to D2.
M8020
Zero flag
Bit device Word device
b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 Decimal Hexadecimal
0000000000000000 0 0000 0 ON
0000000000000001 1 0001 1 OFF
0000000000000010 2 0002 1 OFF
0000000000000011 3 0003 2 OFF
0000000000000100 4 0004 1 OFF
0000000000000101 5 0005 2 OFF
0000000000000110 6 0006 2 OFF
0000000000000111 7 0007 3 OFF
0000000000001000 8 0008 1 OFF
0000000000001001 9 0009 2 OFF
0000000000001010 10 000A 2 OFF
0000000000001011 11 000B 3 OFF
OFF
1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 -5 FFFB 15 OFF
1111111111111100 -4 FFFC 14 OFF
1111111111111101 -3 FFFD 15 OFF
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 -2 FFFE 15 OFF
1111111111111111 -1 FFFF 16 OFF
...
...
...
...
The number of "1" in D0 is stored to D2.
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1
D 0 = K0 D 2 = K0
M8020=ON
M8020=OFF
32 16 8 4 2 1
D 0 = K21847 D 2 = K9
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Zero flag
Zero flag
X000
D0
D2
SUM
EN
s
ENO
d
[Structured ladder/FBD] [ ST ]
SUM(X000, D0, D2);
0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1