Question
Consider a processor with 64 registers and an instruction set of size twelve. Each instruction has five distinct fields, namely, opcode, two source register identifiers, one destination register identifier, and a twelve-bit immediate value. Each instruction must be stored in memory in a byte-aligned fashion. If a program has 100 instructions, the amount of memory (in bytes) consumed by the program text is ________.
Official answer and solution
- Official answer
- 500
- From
- Official GATE 2016 answer key
Solution
Calculate the bits required for each field of the instruction word and round up to the nearest byte boundary.
Analyze the bit fields of each instruction:
-
Opcode field: The instruction set has 12 distinct instructions.
-
Register identifier fields: The processor has 64 registers.
There are 2 source registers and 1 destination register, giving 3 register fields:
-
Immediate value field: Given as 12 bits.
Total bits per instruction:
Byte-alignment constraint: Each instruction must be stored in a byte-aligned fashion, meaning its memory footprint must be an integral multiple of 8 bits:
For a program containing 100 instructions:
500
Computing bytes without enforcing that each individual instruction must be byte-aligned.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2016 Computer Science and Information Technology (CS) Session 2
- Question
- 41 of 65, printed as CS Q.31
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.