the universal solution is a AND with one mask (which has a 1 in every
position you wish to test for and a zero in each position you wish to
ignore) and an XOR with another mask (that has a 1 in each position that
you want to test for a 1 and a zero in each position that you wish to
test for a 0)), then a test if the result is == zero.
in a language like SQL, this could be simplified to a AND with MASK1 and
a COMPARE for equality with MASK2, with the same result.
-jrp
(old assembler programmer)