edited by
10,911 views
44 votes
44 votes

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

$temp\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

  1. $ mask\leftarrow \text{0x1} << pos$
  2. $ mask\leftarrow \text{0xffffffff} << pos$
  3. $ mask\leftarrow pos $
  4. $ mask\leftarrow \text{0xf}$
edited by

5 Answers

0 votes
0 votes

AND operation between reg and mask is stored in temp. If the bit of mask (32 bits) corresponding to the position of pos in register. Say for ex. 8 bit no, 1100 1110 and pos = 3, then if mask is 0000 1000 (at position 3) then, AND operation between reg and mask will definately give non zero number. 0000 0001 « pos (pos = 3) will give 0000 1000  →  0x1 « pos

Answer:

Related questions