5 Categories and Use of Basic Application Instructions Operands: S : Source device D : Destination device for storing counted value Explanation: 1. This instruction counts the total active bits in S and store the value in D. 3. When SUM is used as 16-bit instruction, Z device cannot be adopted; when SUM is used as 32-bit instruction, 2. D will occupy two registers when using in 32-bit instruction. V device cannot be adopted. 4. When specifying the bit device of KnX(Y/M/S), the starting No. should be a multiple of 16 in octal or decimal format. For example, K1X0, K4Y20 (octal); K1M0, K4S16 (decimal). 5. If there is no active bits, zero flag M1968 =ON. 6. Flags: Program Example:
When X20 = ON, all active bits in D0 will be counted and the result will be stored in D2. X20 3 D2 D0 DVP-PM Application Manual 5-63 API Mnemonic Operands Function Controllers 20PM 10PM 43 D SUM P Sum of Active bits Type OP Bit Devices Word devices Program Steps X Y M S K H KnX KnY KnM KnS T C D E F SUM, DSUMP: 5 steps DSUM, DSUMP: 9 steps S * * * * * * * * * * * D * * * * * OX O100 Z ero flag M1808 M1968 SUM D0 D2 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0