GATE / CS ARCHIVE

GATE CSE 2006 / QUESTION 43

Single-bit branch mask

Computer Organization & Architecture · Instructions & Addressing Modes · Full GATE CSE 2006 paper

GATE 2006, Q43 2 marks · MCQ
Report issue

Instructions & Addressing Modes

Question 43, GATE 2006: The instruction bbs reg,pos,label branches if bit pos of a 32-bit register is 1; positions 0…31 start at the least-significant bit. Emulate it by temp←reg & mask, then branch if temp≠0. How should mask be computed?
Options:
(A) 0x1 << pos
(B) 0xffffffff >> pos
(C) pos
(D) 0xf
Question 43, GATE 2006: The instruction bbs reg,pos,label branches if bit pos of a 32-bit register is 1; positions 0…31 start at the least-significant bit. Emulate it by temp←reg & mask, then branch if temp≠0. How should mask be computed?
Options:
(A) 0x1 << pos
(B) 0xffffffff >> pos
(C) pos
(D) 0xf
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. The mask must contain exactly one set bit at position pos: mask=0x1 << pos. AND with the register is nonzero exactly when that bit is set.

2. Thus A. These are register-level pseudocode shifts; a literal C implementation should use an unsigned 32-bit 1 to handle position 31 safely.

3. Teaching check: A one-hot mask isolates exactly the requested bit; an all-ones mask shifted right would generally retain several bits. If implemented in C rather than register pseudocode, use a suitably wide unsigned constant to avoid undefined signed left-shift behavior at the top bit.

Original paper, page 6