OA. free
Free
Qualcomm Embedded Systems & Hardware Embedded Systems & Hardware Medium

A CPU organisation has 32 general purpose registers and the Arithmetic logic unit can...

Qualcomm technical mcq question, verified with a worked answer. Free to practise - no sign-up.

A CPU organisation has 32 general purpose registers and the Arithmetic logic unit can perform about 256 different operations. How many bits are present in the operation code?

Choose one option.
Show answer & explanation
Answer: A. 8 bits

The operation code (opcode) must be able to uniquely encode all 256 different operations supported by the ALU. Since 2^8 = 256, exactly 8 bits are required to represent 256 distinct operations. The number of registers (32) is irrelevant to the opcode width; it would affect the register address field width, which requires log₂(32) = 5 bits. Note: Options A and C are identical, which appears to be a transcription error in the original question.

Step-by-step Derivation:
To determine the minimum number of bits needed to represent n distinct values, use the formula: bits = ⌈log₂(n)⌉

For 256 operations:
bits = log₂(256) = log₂(2^8) = 8 bits

Verification: 2^8 = 256 ✓

For comparison (to explain why 5 bits is incorrect for this context):

  • 5 bits can represent 2^5 = 32 values (this would be for addressing 32 registers, not operations)
  • 8 bits can represent 2^8 = 256 values (this correctly encodes 256 operations)