6F3B0253

7. Instructions

FUN 122

BC

Bit count

Expression

Input [ A BC B ]Output

Function

When the input is ON, this instruction counts the number of ON (1) bits of A, and stores the result in B.

Execution condition

Input

 

Operation

Output

OFF

No execution

 

OFF

ON

Execution

 

ON

Operand

 

Name

 

 

Device

 

 

 

 

 

 

 

 

Register

 

 

 

 

Constant

Index

 

 

X

Y

R

S

T.

C.

XW

YW

RW

SW

T

C

D

I

J

K

 

 

A

Source

 

 

 

 

 

 

 

 

 

B

Count data

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Example

When R020 is ON, the number of ON (1) bits of the register RW032 is counted, and the result is stored in D0102.

The following figure shows an operation example.

F E D C B A 9 8 7 6 5 4 3 2 1 0

RW032 0 0 1 0 0 1 1 1 0 1 0 1 1 0 0 0

Counts the number of ON (1) bits = 7

D0102

F E D C B A 9 8 7 6 5 4 3 2 1 0

0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1

The result data (7) is stored in binary

202 T1-16S User’s Manual

Page 204
Image 204
Toshiba 6F3B0253 user manual FUN Bit count