Chapter 7 Second Development PlatformVP3000
331
API Instruction code Operand Function
43 D SUM P S, D
Sum of active bits
Type
Operand
Bit devices Word devices
16-bit instruction (5 steps)
SUM
Continuous
execution
type
SUMP
Pulse
execution
type
32-bit instruction (9 steps)
DSUM
Continuous
execution
type
DSUMP
Pulse
execution
type
Associated flag: none
X Y M K H KnX KnY KnM T C D
S
D
Caution for using operand
When using 32-bit instruction, D occupies two registers.
Description
S: source device
D: destination device for storing counted value
The sum of all bits whose contents are "1" in S will be stored in D.
Example
When X0 = OFFON, the 16 bits (4 bits as a group) in D10 rotates to the left, as shown in the
figure below. The bit marked with ※ is sent to carry flag M1022.
When M200 = ON, the sum of whose contents are “1” in 16 bits of D0 will be stored in D2.
0000 00011 100 0000 3
D2D0
SUM D0 D2