GATE / CS ARCHIVE

GATE CSE 2018 / QUESTION 51

Expanding opcodes and register fields

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

GATE 2018, Q51 2 marks · NAT
Report issue

Instructions & Addressing Modes

Question 51, GATE 2018: A 16-bit instruction set has 16 integer and 64 floating registers. Four type-1 instructions use 3 integer operands; eight type-2 use 2 floating operands; fourteen type-3 use 1 integer+1 floating; N type-4 use 1 floating. Find maximal N.
Tap to enlarge
Answer & solution

Official answer: 32

Method

An integer register needs 4 bits and a floating register 6 bits. Operand bits are therefore 12,12,10,6 for the four categories, leaving variable opcode widths 4,4,6,10. Counting complete instruction words avoids assigning incompatible fixed-length opcodes. Each opcode must reserve all combinations of its operands. After subtracting the first three categories from the 65536 available words, divide the remaining words by 64 per type-4 instruction. The prefix construction below verifies that this counting bound can actually be encoded.

Solution

There are 216 instruction encodings. A three-integer-register instruction uses 212 encodings, as does a two-floating-register instruction. Each mixed register instruction uses 210 encodings. The remaining space is 65536−4*4096−8*4096−14*1024=2048. Each type4 opcode needs 64 encodings, so N≤2048/64=32. This bound is achievable with expanding opcodes: allocate 12 four-bit prefixes to types 1/2; the remaining 4 prefixes yield 16 six-bit prefixes, 14 for type3, leaving 2 prefixes expandable to 32 ten-bit type4 opcodes.

Original paper, page 21 · Answer key