465
3. Instructions
CS/CJ/NSJ Series Instructions Reference Manual (W474)
Special Math Instructions
3
BCNT
BCNT
Applicable Program Areas
Operands
N: Number of words
The number of words must be 0001 to FFFF (1 to 65,535 words).
z 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
Function block
definitions
Block program areas Step program areas Subroutines Interrupt tasks
SFC action or
transition programs
Usage OK OK OK 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/EM
addresses
Con-
stants
Registers Flags
Pulse
bits
TR
bits
CIO WR HR AR T C DM EM
@DM
@EM
*DM
*EM
DR IR
Indirect
using IR
TK CF
N
OK OK OK OK OK OK OK OK OK OK
OK OK
--- OK --- --- --- ---S
---
---
R OK
Name Label Operation
Error Flag ER • ON if N is 0000.
• ON if result exceeds FFFF.
• OFF in all other cases.
Equals Flag = • 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)
R
to
N words
Binary resul
Counts the number
of ON bits.