Consider a processor that has 16 general purpose registers and it uses 2-byte instruction format for all its instructions. Variable-sized opcodes are permitted. There are three different types of instructions; M-type, R-type, and C-type. Each M-type instruction has 2 register operands and a 6-bit immediate operand. Each R-type instruction has 3 register operands. Each C-type instruction has a register operand and a 6-bit offset value. If there are 2 unique M-type opcodes and 7 unique R-type opcodes, which one of the following options gives the maximum number of unique opcodes possible for C-type instructions?
B
Step-by-Step Solution
Key idea: This is an expanding opcode instruction encoding question, recognisable by the mention of "variable-sized opcodes" and multiple instruction types with different operand counts.
Why this method applies: In expanding opcode techniques, unused opcode patterns from a shorter opcode field are "expanded" into longer opcode fields by sacrificing operand bits. We must track the number of available patterns at each stage.
Step 1: Analyze the base constraints.
Total instruction length = 2 bytes = 16 bits.
Number of registers = 16. Bits per register field = bits.
Step 2: Analyze M-type instructions.
Format: Opcode + 2 Register operands + 6-bit immediate.
Operand bits = bits.
Opcode bits = bits.
Total possible 2-bit patterns = .
M-type uses 2 opcodes.
Remaining patterns for expansion = .
Step 3: Analyze R-type instructions.
Format: Opcode + 3 Register operands.
Operand bits = bits.
Opcode bits = bits.
Each of the 2 remaining 2-bit patterns can be expanded into four-bit patterns.
Total available 4-bit patterns = .
R-type uses 7 opcodes.
Remaining patterns for expansion = .
Step 4: Analyze C-type instructions.
Format: Opcode + 1 Register operand + 6-bit offset.
Operand bits = bits.
Opcode bits = bits.
The 1 remaining 4-bit pattern can be expanded into six-bit patterns.
Total available 6-bit patterns = .
Therefore, the maximum number of unique C-type opcodes is 4.
Answer: Option B.