December 2001 Commands 7 – 139
7.7.59 BIT TEST (BT)
Syntax: BT (BIT TEST)
Operands: B, W, D, K, X
Action:
With the BIT TEST you can interrogate the status of each bit in the 
accumulator. With the BT command there is a direct transition from word to 
logic processing, i.e. the TNC checks the state of a bit in the word accumulator 
and then sets the logic accumulator. If the interrogated bit = 1, the TNC sets 
the logic accumulator to 1; otherwise it sets it to 0. The corresponding bits are 
selected (addressed) by the content of the specified operand or by a constant. 
As to the bit numbering, bit 0 = LSB and bit 31 = MSB. For operand contents 
greater than 32, the TNC uses the operand value modulo 32, i.e. the integral 
remainder of the result of the operand value divided by 32.
Example:
Load the double word D8 into the accumulator and assign the logical state of 
bit 0 to output O12. 
Initial state:
Double word  D8 = 3E 81 (hex)
Output O12 = ?
The word accumulator and operand contents are shown here in hexadecimal 
notation, the logic accumulator in binary notation.
Function STL Accumulator contents (hex or [bit]) Operand content (hex or 
[Bit])
xx xx xx xx
Load the double 
word D8 into the 
word accumulator.
L D8 00 00 3E 81 00 00 3E 81
Check the state of 
the bit specified in 
the operand.
BT K+0 00 00 3E 81
31..15 ..................... 7 .................. 0
Assign the result to 
output O12.
= O12 x ..... x xxxxxxx1xxxxxxx 1