Rockwell Automation Publication 1756-RM003N-EN-P - October 2011 89
Bit Instructions (XIC, XIO, OTE, OTL, OTU, ONS, OSR, OSF, OSRI, OSFI) Chapter 2
Example: Indirect Serial Bit Reference in a DINT array
Ta g
MyBits : DINT[10]
BitRef : DINT
EndTag
MOV(34,BitRef )
XIC(MyBits[(BitRef AND NOT 31)/32].[BitRef AND 31])
Explanation
(BitRef AND NOT 31)/32=Calculates the element in the DINT
.[BitRef AND 31]=Calculates the bit within the element
If the tag MyBits is defined as an INT or SINT, the mask value would be 15 or 7,
respectively. Both the Diagnostic Detect (DDT) and File Bit Compare (FBC)
instructions provide a bit number as a result of their operation. These
instructions are limited to DINT arrays, and so the indirect addressing example
can be used to programmatically locate the bit number returned from these
instructions.