ITPEC IP April 2020 Question 4
Which of the following is the result from the bit-wise logical product of an 8-bit binary data X and 00001111? Here, the left side of the data is the high-order, and the right side is the low-order.
Explanation
High-order four bits all 0, low-order four bits the same as X — AND with a mask keeps the bits where the mask has 1 and clears the bits where it has 0.
The logical product (AND) gives 1 only where both bits are 1. So for any bit of X: that bit AND 0 is always 0, and that bit AND 1 is the bit itself. The mask 00001111 has 0 in the four high-order positions and 1 in the four low-order ones.
Example: X = 10110110 gives 10110110 AND 00001111 = 00000110: the high half becomes 0000, and the low half 0110 is copied from X.
Answer (c)
Why not others:
- •(a) — the halves swapped: clearing the low-order bits and keeping the high-order ones is AND with
11110000 - •(b) — forcing bits to 1 is the logical sum: X OR
00001111sets the low-order four bits to 1 and keeps the high-order ones; AND can never turn a 0 into 1 - •(d) — also an OR result, X OR
11110000; AND with 0 clears the high-order bits instead of setting them
Key rule: A mask picks bits by operation: AND with 0 clears a bit and AND with 1 keeps it, OR with 1 sets a bit, XOR with 1 inverts it.
Basic Theory · AI-written, may contain errors
This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official IP past-paper collection or Report an issue.