GATE / CS ARCHIVE

GATE CSE 2020 / QUESTION 44

GATE CSE 2020 Q44

Computer Organization & Architecture · Instructions & Addressing Modes · Full GATE CSE 2020 paper

GATE 2020, Q44 2 marks · NAT
Report issue

Instructions & Addressing Modes

Question 44, GATE 2020: A processor has 64 registers and 16-bit instructions. I-type has opcode, one register and a 4-bit immediate; R-type has opcode and two registers. Given 8 I-type opcodes, what is the maximum number of distinct R-type opcodes?
Tap to enlarge
Answer & solution

Official answer: 14

Worked explanation

A register number occupies log2 64=6 bits. I-type operands occupy 6+4=10 bits, leaving a 6-bit opcode; R-type operands occupy 12 bits, leaving a 4-bit opcode. Their opcode spaces cannot be independently filled because every complete 16-bit word needs an unambiguous interpretation. Each chosen I opcode consumes 210 words, so eight consume 8192. R opcodes each need 212 distinct operand combinations; the 57344 words left permit 14. Constructively, use four-bit prefixes 0000 through 1101 for R instructions. Reserve 1110 and 1111, extending each by two bits to obtain the eight six-bit I opcodes. This proves attainability as well as the counting bound.

Derivation and answer

Each register field needs 6 bits. An I-type opcode leaves 10 operand bits, so 8 I-type opcodes reserve 8*210=8192 of the 65536 instruction words. An R-type opcode needs 12 operand bits, consuming 4096 words. The remaining 57344 words allow 57344/4096=14 R-type opcodes. Achievability: reserve two four-bit opcode prefixes for the eight six-bit I-opcodes and use the other 14 four-bit prefixes for R-type instructions.

Original paper, page 14 · Answer key