A 32-bit instruction has a 6-bit opcode and two register fields for a 32-register file, with the rest used for a signed two’s complement immediate. What range can the immediate hold?
Correct answer C. -32768 to 32767
Explanation
32 registers need 5 bits each, so 6 + 5 + 5 = 16 bits are used and 16 remain for the immediate. A 16-bit two's complement field spans -2^15 to 2^15 - 1, that is -32768 to 32767. 0 to 65535 is the unsigned range of the same field, and -2048 to 2047 is the range of a 12-bit field. Instruction format design always trades register count against immediate width.
Answer checked How we write and check questions
Discussion