Skip to content
Official PYQ · 2016

GATE CS 2016 Set 2 Q31 — Machine Instructions and Addressing Modes

Explain with AI
Consider a processor with 6464 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 twelve-bit immediate value. Each instruction must be stored in memory in a byte-aligned fashion. If a program has 100100 instructions, the amount of memory (in bytes) consumed by the program text is _________.
View worked solution

Answer: 500

To find the total memory consumed by the program, we first determine the size of a single instruction in bits, align it to the nearest byte, and then multiply by the total number of instructions.

1. Calculating the size of each field in an instruction:

  • Opcode: Since there are 1212 instructions in the instruction set, the number of bits required is:⌈log⁡2(12)⌉=4 bits\lceil \log_2(12) \rceil = 4 \text{ bits}
  • Source Registers: There are 6464 registers, requiring ⌈log⁡2(64)⌉=6\lceil \log_2(64) \rceil = 6 bits per register. For two source registers:2×6=12 bits2 \times 6 = 12 \text{ bits}
  • Destination Register: One destination register requires:6 bits6 \text{ bits}
  • Immediate Value: Given as:12 bits12 \text{ bits}

2. Total size per instruction:

Summing the bits of all five fields:

Total bits=4 (opcode)+6 (src1)+6 (src2)+6 (dest)+12 (immediate)=34 bits\text{Total bits} = 4 \text{ (opcode)} + 6 \text{ (src1)} + 6 \text{ (src2)} + 6 \text{ (dest)} + 12 \text{ (immediate)} = 34 \text{ bits}

3. Byte-alignment:

Each instruction must be stored in a byte-aligned fashion (i.e., its size must be a multiple of 88 bits). Therefore, we round up the size of each instruction to the nearest byte:

Size per instruction=⌈348⌉=5 bytes\text{Size per instruction} = \left\lceil \frac{34}{8} \right\rceil = 5 \text{ bytes}

4. Total memory for 100 instructions:

Total Memory=100 instructions×5 bytes/instruction=500 bytes\text{Total Memory} = 100 \text{ instructions} \times 5 \text{ bytes/instruction} = 500 \text{ bytes}

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Machine Instructions and Addressing Modes questions