Test under Mask

The test under mask instruction is used to test the values of selected bits in a byte of storage.


Format:  label     TM    D(B),mask

The value of the bits in the mask determine which bits of the byte at D(B) are tested. Bits that correspond to a 1 in the mask are tested, while bits that correspond to a 0 in the mask are not tested.

The condition code is set:


Code    Meaning
 0      Every bit tested was 0
 1      Bits tested are a mix of 0s and 1s
 2      --
 3      Every bit tested was 1



Suppose that BYTE contains X'0E'.  Execution of:

     TM    BYTE,B'10010000'
     
BYTE   X'0E' ->  B'00001110'
mask         ->  B'10010000'

will set the condition code to 0, since bits 0 and 3 of BYTE are both
0.


Execution of:

     TM    BYTE,B'10001000'
     
BYTE   X'0E' ->  B'00001110'
mask         ->  B'10001000'


will set the condition code to 1, since bits 0 is 0 and bit 4 is 1.


Execution of:

     TM    BYTE,B'00001110'
     
BYTE   X'0E' ->  B'00001110'
mask         ->  B'00001110'


will set the condition code to 3, since bits 4, 5, and 6 are all 1.

TM instructions are commonly followed by a branch instruction. The most common ones are:


BZ    branch if all bits tested are ZERO

BO    branch if all bits tested are ONE

BM    branch if tested bits are MIXED

BNZ   branch if tested bits are NOT ZERO

BNO   branch if tested bits are NOT ONE

BNM   branch if tested bits are NOT MIXED