Skip to content
Official PYQ · 2005

GATE CS 2005 Q65 — Machine Instructions and Addressing Modes

Explain with AI

Consider a three word machine instruction

ADDA[R0],@B\text{ADD} A[R_0], @B

The first operand (destination) “A[R0]”“A[R_0]” uses indexed addressing mode with R0R_0 as the index register. The second operand (source) “@B”“@B” uses indirect addressing mode. AA and BB are memory addresses residing at the second and third words, respectively. The first word of the instruction specifies the opcode, the index register designation and the source and destination addressing modes. During execution of ADD\text{ADD} instruction, the two operands are added and stored in the destination (first operand).

The number of memory cycles needed during the execution cycle of the instruction is:

Choose one option
View worked solution

Answer: B

An instruction cycle is divided into two main phases: the Fetch Cycle and the Execution Cycle. The question specifically asks for the number of memory cycles during the execution cycle.

1. Fetch Cycle (Not counted in the execution cycle)

During the fetch phase, the 3-word instruction is fetched from memory:

  • Word 1: Opcode and addressing mode specifications (1 memory read)
  • Word 2: Address AA (1 memory read)
  • Word 3: Address BB (1 memory read)

After this phase, the values of AA and BB are already available in the CPU's internal registers.

2. Execution Cycle

During the execution phase, the CPU performs the actual operations and accesses memory to read/write operands:

  1. Source Operand (@B@B - Indirect Addressing):
    • Memory Access 1: Read memory at address BB to get the effective address of the source operand, say EAsrc=M[B]EA_{\text{src}} = M[B].
    • Memory Access 2: Read memory at EAsrcEA_{\text{src}} to fetch the actual source operand value.
  2. Destination Operand (A[R0]A[R_0] - Indexed Addressing):
    • The effective address is calculated internally as EAdest=A+R0EA_{\text{dest}} = A + R_0 (no memory access needed for this addition).
    • Memory Access 3: Read memory at EAdestEA_{\text{dest}} to fetch the destination operand value (required because we need to perform Destination+Source\text{Destination} + \text{Source}).
  3. ALU Operation:
    • Add the source and destination values (performed inside the CPU, 0 memory accesses).
  4. Write Back:
    • Memory Access 4: Write the result back to the destination memory location EAdestEA_{\text{dest}}.

Summing these up, the total number of memory cycles during the execution cycle is:

Total Execution Memory Cycles=2 (for source)+1 (read destination)+1 (write destination)=4\text{Total Execution Memory Cycles} = 2 \text{ (for source)} + 1 \text{ (read destination)} + 1 \text{ (write destination)} = 4

Therefore, the correct option is B.

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

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