A processor has 64 general-purpose registers and 50 distinct instruction…

2025

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

  1. A.

    16

  2. B.

    20

  3. C.

    22

  4. D.

    24

Attempted by 335 students.

Show answer & explanation

Correct answer: B

Answer: 20 bits

Explanation:

  • Total instruction length = 32 bits.

  • Opcode bits = ceil(log2(50)) = 6 bits (since 2^5 = 32 < 50 ≤ 64 = 2^6).

  • Register bits = ceil(log2(64)) = 6 bits for each register identifier. This instruction uses one explicit register operand (the destination/source register), so use 6 bits.

  • Immediate bits = 32 - opcode bits - register bits = 32 - 6 - 6 = 20 bits.

Note: If an ISA required separate source and destination register fields for this instruction, that would consume more register bits and reduce the maximum immediate size. For the given assembly form which specifies a single register and an immediate, 20 bits is the maximum immediate field size.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir