A processor has 40 distinct instructions and 24 general purpose registers. A…
2016
A processor has 40 distinct instructions and 24 general purpose registers. A 32-bit instruction word has an opcode, two register operands and an immediate operand. The number of bits available for the immediate operand field is __________________ .
Attempted by 148 students.
Show answer & explanation
Correct answer: 16
Key idea: count how many bits are needed for the opcode and for the two register operands, then subtract from 32 to get the immediate field size.
Opcode bits: need enough bits to encode 40 instructions, so bits = ceil(log2(40)) = 6 bits (since 2^5 = 32 < 40 ≤ 64 = 2^6).
Register operand bits: need bits to encode 24 registers, so bits per register = ceil(log2(24)) = 5 bits (2^4 = 16 < 24 ≤ 32 = 2^5). Two register operands use 2 × 5 = 10 bits.
Immediate bits: 32 (total instruction length) − 6 (opcode) − 10 (two registers) = 16 bits.
Answer: The immediate operand field is 16 bits long.
A video solution is available for this question — log in and enroll to watch it.