-
Consider a new instruction named branch-on-bit-set (mnemonic bbs). The instruction “bbs reg, pos, label” jumps to label if bit in position pos of register operand reg is one. A register is 32 bit wide and the bits are numbered 0 to 32, bit in position 0 being the least significant. Consider the following emulation of this instruction on a processor that does not have bbs implemented. tem ← reg and mask Branch to lable if temp is non-zero The variable temp is a temporary register. For correct emulation, the variable mask must be generated by
-
- mask ← 0 × 1 << pos
- mask ← 0 × ffffffff << pos
- mask ← pos
- mask ← 0 × f
- mask ← 0 × 1 << pos
Correct Option: A
From the given conditions it can be determined that we have to set all the other bits to 0 in temp, as the position pos is the only deciding factor in jumping to the label. If the left shift over 1 is done by the pos number then the mask register can have 1 in pos place, which is required. Thus, is the option mask ← 0 × 1 << pos is correct.