Question

A machine has a 32-bit architecture, with 1-word long instructions. It has 64 registers, each of which is 32 bits long. It needs to support 45 instructions, which have an immediate operand in addition to two register operands. Assuming that the immediate operand is an unsigned integer, the maximum value of the immediate operand is ____________.

Official answer and solution
Official answer
16383
From
Official GATE 2014 answer key

Solution

Determine the bit width of each instruction field and subtract from the 32-bit total instruction length to find the bits available for the immediate operand.

  1. Instruction length = 1 word = 32 bits.
  2. Number of distinct instructions = 45.
    The number of bits required for the opcode is:
    ⌈log⁡245⌉=6 bits(25=32<45≤64=26)\lceil \log_2 45 \rceil = 6 \text{ bits} \quad (2^5 = 32 < 45 \le 64 = 2^6)
  3. Number of registers = 64.
    The number of bits required to specify one register is:
    log⁡264=6 bits\log_2 64 = 6 \text{ bits}
    There are 2 register operands, so the register fields take:
    2×6=12 bits2 \times 6 = 12 \text{ bits}
  4. Remaining bits for the immediate operand:
    Immediate bits=32−(Opcode bits+Register bits)\text{Immediate bits} = 32 - (\text{Opcode bits} + \text{Register bits})
    Immediate bits=32−(6+12)=32−18=14 bits\text{Immediate bits} = 32 - (6 + 12) = 32 - 18 = 14 \text{ bits}
  5. For an unsigned 14-bit integer, the maximum value is:
    214−1=16384−1=163832^{14} - 1 = 16384 - 1 = 16383
Final answer

16383

Common trap

Using 5 bits for opcode (25=322^5 = 32, which cannot support 45 instructions) or giving 2142^{14} instead of 214−12^{14} - 1.

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

Source

Paper
GATE 2014 Computer Science and Information Technology (CS) Session 1
Question
19 of 65, printed as CS Q.9
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.