Consider a three word machine instruction ADD A[R0], @ B The first operand…

2005

Consider a three word machine instruction

ADD A[R0], @ B 

The first operand (destination) "A [R0]" uses indexed addressing mode with R0 as the index register. The second operand (source) "@ B" uses indirect addressing mode. A and B are memory addresses residing at the second and the 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 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

  1. A.

    3

  2. B.

    4

  3. C.

    5

  4. D.

    6

Attempted by 148 students.

Show answer & explanation

Correct answer: B

Answer: 4 memory cycles.

Explanation: Count only the memory accesses performed during the execution phase (do not include fetching the three instruction words).

  • Read the operand at A[R0] (indexed addressing): 1 memory read.

  • For the indirect source @ B: read memory at address B to obtain the effective address: 1 memory read.

  • Read the operand from the effective address obtained via B: 1 memory read.

  • Write the computed sum to the destination memory location (effective address of A[R0]): 1 memory write.

Total memory cycles during execution = 1 + 1 + 1 + 1 = 4.

Explore the full course: Gate Guidance By Sanchit Sir