TSET loc16,#16bit
6-365
TSET loc16,#16bit Test and Set Specified Bit
SYNTAX OPTIONS OPCODE OBJMODE RPT CYC
TSET loc16,#16bit 0101 0110 0000 1101
0000 BBBB LLLL LLLL
1 − 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 and then set the same bit to 1:
TC = [loc16(bit)];
[loc16(bit)] = 1;
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).
TSET performs a read-modify-write operation.
Flags and
Modes
N
If (loc16 = = @AX) and bit 15 (MSB) of @AX is 1, then N flag is set..
Z
If (loc16 = = @AX) and @AX gets zeroed out, then Z flag is set.
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: ;