GATE / CS ARCHIVE

GATE CSE 2024 SET 2 / QUESTION 57

Allocate fixed-width instruction fields

Computer Organization & Architecture · Instructions & Addressing Modes · Full GATE CSE 2024 Set 2 paper

GATE 2024 Set 2, Q57 2 marks · NAT
Report issue

Instructions & Addressing Modes

Question 57, GATE 2024: A 32-bit instruction contains opcode, addressing-mode field, two register operands, and a 16-bit scalar. The processor has 16 general-purpose registers and 8 addressing modes. What maximum number of opcodes is possible for each mode?
Tap to enlarge
Answer & solution

Official answer: 32

Approach: Reserve enough binary codes for each independent fixed-width field, then count the remaining opcode patterns.

1. Derivation. Each of 16 registers requires 4 bits, so the two register fields use 8 bits. Eight addressing modes require 3 bits and the scalar field uses 16. The opcode therefore has 32−8−3−16=5 bits, supporting 2⁵=32 unique opcodes for each mode under the separate fixed-field format.

2. Explanation and checks. A register identifier uses ceil(log2 16)=4 bits even though an operand value may occupy many more bits. The two fields therefore cost eight bits, not sixteen or thirty-two. The mode field needs ceil(log2 8)=3 bits. After allocating these and the scalar there are five opcode bits. The question asks per addressing mode, so the eight mode patterns are not multiplied into the number of distinct opcode-field encodings.

Original paper, page 37 · Answer key