Question 105

Computer Awareness Structure of instructions in CPU Hard

Consider a system with a CPU having 6 registers and 32-bit instructions. The maximum possible size of the main memory is 512 KB (1K = 2^10). Each instruction takes two registers and one memory address as operands. Which one of the following correctly gives the maximum possible distinct instructions that can be there in the instruction set of the CPU?

(A) 128
(B) 64
(C) 256
(D) 1024
View Dynamic Solution & Explanation
Correct Solution: Option A

Step-by-step Solution:

Given:

\[ \begin{aligned} &\text{CPU registers} = 6 \\ &\text{Instruction length} = 32\ \text{bits} \\ &\text{Main memory size} = 512\ \text{KB} = 512\times 2^{10}=2^{9}\times 2^{10}=2^{19}\ \text{bytes} \end{aligned} \]

Assumption: memory is byte-addressable (each distinct address selects one byte).

Number of bits required for a memory address = \(\log_2(2^{19}) = 19\ \text{bits}\).

Number of bits to encode one register = \(\left\lceil \log_2 6 \right\rceil = 3\ \text{bits}\), so two registers need \(3+3=6\ \text{bits}\).

Total bits used by operands = \(19\ (\text{address}) + 6\ (\text{two registers}) = 25\ \text{bits}\).

Remaining bits for opcode = \(32 - 25 = 7\ \text{bits}\).

\[ \therefore\ \text{Maximum distinct instructions} = 2^{7} = \boxed{128}. \]

(Note: if addresses were word-addressable or some other addressing unit were used, the address-bit count — and hence the result — would change.)