Question

A processor has 64 general-purpose registers and 50 distinct instruction types. An instruction is encoded in 32-bits. What is the maximum number of bits that can be used to store the immediate operand for the given instruction?

ADD R1, #25             // R1 = R1 + 25
Choose one option
Official answer and solution
Official answer
B
From
Official GATE 2025 answer key

Solution

Subtract the minimum bits needed for the opcode and the single register field R1 from the 32-bit instruction length.

  1. Opcode field: To encode 5050 distinct instruction types, we need ⌈log⁡250⌉=6\lceil \log_2 50 \rceil = 6 bits (25=32<50≤26=642^5 = 32 < 50 \le 2^6 = 64).
  2. Register field (R1): To address 6464 general-purpose registers, we need log⁡264=6\log_2 64 = 6 bits.
  3. Immediate operand field (#25): Since the instruction ADD R1, #25 specifies only one register (R1, which serves as both source and destination) and one immediate operand, the maximum number of bits left for the immediate operand is:
32−6−6=20 bits32 - 6 - 6 = 20\text{ bits}
Final answer

Option (B)

Common trap

Subtracting two 6-bit register fields (32−6−12=1432 - 6 - 12 = 14) when the instruction encoding only specifies a single register R1.

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2025 Computer Science and Information Technology - Session 1 (CS1)
Question
37 of 65
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.