Consider a processor with 16 general-purpose registers and a 2-byte…

2026

Consider a processor with 16 general-purpose registers and a 2-byte instruction format for every instruction. Variable-sized prefix opcodes are permitted. There are three instruction types: M-type, R-type, and C-type. Each M-type instruction has two register operands and a 6-bit immediate operand. Each R-type instruction has three register operands. Each C-type instruction has one register operand and a 6-bit offset. If there are 2 unique M-type opcodes and 7 unique R-type opcodes, what is the maximum possible number of unique C-type opcodes?

Answer: B. 4ConceptFor a fixed 16-bit instruction word with variable-length prefix opcodes, each opcode reserves every bit pattern formed by its operand fields.…

  1. A.

    8

  2. B.

    4

  3. C.

    64

  4. D.

    16

Attempted by 99 students.

Show answer & explanation

Correct answer: B

Concept

For a fixed 16-bit instruction word with variable-length prefix opcodes, each opcode reserves every bit pattern formed by its operand fields. Therefore, the fractions of the instruction space occupied by all instruction classes must add to at most 1.

If a class has k operand bits and n opcodes, it occupies n × 2k encodings out of 216. This is the prefix-space constraint expressed by the Kraft inequality.

Application

  1. Each register number needs log2(16) = 4 bits.

  2. An M-type instruction has 2 × 4 + 6 = 14 operand bits. Its 2 opcodes occupy 2 × 214 = 32768 encodings.

  3. An R-type instruction has 3 × 4 = 12 operand bits. Its 7 opcodes occupy 7 × 212 = 28672 encodings.

  4. A C-type instruction has 4 + 6 = 10 operand bits. If N C-type opcodes are provided, they occupy N × 210 encodings.

  5. The total cannot exceed 216: 2 × 214 + 7 × 212 + N × 210216.

  6. Dividing by 210 gives 32 + 28 + N ≤ 64, so N ≤ 4. Therefore, the maximum number of C-type opcodes is 4.

Cross-check

Using opcode-prefix fractions directly: 2/22 + 7/24 + N/26 ≤ 1. Thus 1/2 + 7/16 + N/64 ≤ 1, which again gives N ≤ 4.

Explore the full course: Iocl Engineers Officers Grade A Paper 2

Loading lesson…