Here it is with addresses and symbols:
[attachment]
The thing that might be confusing to you is the indirect address of the bit, which is N7:5/[N7:0], although using symbols can be entered as N7:5/[POINTER].
Gerry is right!!! FBC can be used to count all the bits in a word. I'd forgetten about that instruction, and have never used it that way before.
The code might look something like this:
R6:0.IN
--------+---{U} // SET THE BLOCK TO SCAN FOR ALL
| // MISMATCHES IN A SINGLE SCAN
| R6:0
+---(RES} // RESET THE SOURCE POINTER
|
| R6:1
+---(RES) // RESET THE RESULT POINTER
+----------- FBC ---+
---| SOURCE: #N7:5 | // SAME SOURCE AS IN MY EXAMPLE.
| REFERENCE: #N7:6 | // LOGIC MIGHT BE NEEDED TO ENSURE N7:6 IS ZERO.
| RESULT: #N10:0 |
| CONTROL: R6:0 |
| LENGTH: 16 | // INTERESTED IN 16 BITS IN SOURCE WORD.
| POSITION: 0 |
| CONTROL: R6:1 |
| LENGTH: 16 |
| POSITION: 0 | // THIS VALUE, R6:1.POS WILL CONTAIN
+-------------------+ // THE NUMBER OF BITS SET IN THE SOURCE WORD.
`
If you are interested in keeping track of which bits are set, then you'd need to do a FLL of N10:0 prior to executing the rung.
The only disadvantage of the FBC method is that you need to reserve one
word of Result for each
bit you are interested in counting, which increases your overhead.
And in the SLC, you can't have a Length longer than 128 (i.e., 8 words of Source bits), so that's another limitation.