Skip to content
Official PYQ · 2006

GATE CS 2006 Q43 — Machine Instructions and Addressing Modes

Explain with AI

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 3232 -bits wide and the bits are numbered 00 to 31,31,  bit in position 00 being the least significant. Consider the following emulation of this instruction on a processor that does not have bbs implemented.

temp←reg&masktemp\leftarrow reg \& mask

Branch to label if temp is non-zero. The variable temp is a temporary register. For correct emulation, the variable  mask must be generated by

Choose one option
View worked solution

Answer: A

The bbs reg, pos, label (branch-on-bit-set) instruction branches to label if the bit at index pos of register reg is 11.

The emulation performs a bitwise AND operation:

temp←reg & masktemp \leftarrow reg \ \& \ mask

And branches if temp is non-zero.

For the emulation to work correctly:

  • If the bit at index pos in reg is 11, then reg & maskreg \ \& \ mask must be non-zero.
  • If the bit at index pos in reg is 00, then reg & maskreg \ \& \ mask must be zero.

This requires the mask to have a binary 11 at position pos and 00 at all other bit positions. Such a mask is generated by shifting the value 11 (represented in hex as 0x1) to the left by pos positions:

mask←0x1≪posmask \leftarrow \text{0x1} \ll pos

Therefore, the correct option is A.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Machine Instructions and Addressing Modes questions