2-227

2 Instructions
CP1E CPU Unit Instructions Reference Manual(W483)

Special Math Instructions

2

BCNT

BCNT
Applicable Program Areas
Operands

N: Number of words

The number of words must be 0001 to FFFF (1 to 65,535 words).

Operand Specifications
Flags
Function
T

Instruction Mnemonic Variations Function

code Function

BIT COUNTER BCNT @BCNT 067 Counts the total number of ON bits in the specified

word(s).

Symbol
BCNT
Area Step program areas Subroutines Interrupt tasks
Usage OK OK OK
Operand Description Data type Size
N Number of words UINT 1
S First source word UINT Variable
R Result word UINT 1
Area Word addresses Indirect DM addresses Constants CF Pulse bits TR bits
CIO WR HR AR T C DM @DM *DM
NOK OK OK OK OK OK OK OK OK OK --- --- ---
S,R ---
Name Label Operation
Error Flag P_ER • ON if N is 0000.
ON if result exceeds FFFF.
OFF in all other cases.
Equals Flag P_EQ •ON if the result is 0000.
OFF in all other cases.

BCNT(067) counts the total number of bits

that are ON in all words between S and S+(N-

1) and places the result in R.

N: Number of words
S: First source word
R: Result word
BCNT(067)
N
S
R
S+(N–1)
S
R
to
N words
Binary result
Counts the number
of ON bits.