TBIT loc16,#bit
6-359
TBIT loc16,#bit Test Specified Bit
SYNTAX OPTIONS OPCODE OBJMODE RPT CYC
TBIT loc16,#16bit 0100 BBBB LLLL LLLL X − 1
Operands
loc16#bit
Addressing mode (see Chapter 5)
Immediate constant bit index from 0 to 15
Description Test the specified bit of the data value in the location pointed to by the
“loc16” addressing mode:
TC = [loc16(bit)];
The value specified for the #bit immediate operand directly corresponds
to the bit number. For example, if #bit = 0, you will access bit 0 (least
significant bit) of the addressed location; if #bit = 15, you will access bit 15
(most significant bit).
Flags and
Modes
TC
If the bit tested is 1, TC is set; if the bit tested is 0, TC is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example
; if( VarA.Bit4 = 1 )
; VarB.Bit6 = 1;
; else
; VarB.Bit6 = 0;
TBIT @VarA,#4 ; Test bit 4 of VarA contents
SB $10,NTC ; Branch if TC = 0
TSET @VarB,#6 ; Set bit 6 of VarB contents
SB $20,UNC ; Branch unconditionally
$10: ;
TCLR @VarB,#6 ; Clear bit 6 of VarB contents
$20: ;