Consider a three word machine instruction
The first operand (destination) uses indexed addressing mode with as the index register. The second operand (source) uses indirect addressing mode. and 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 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:
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 (1 memory read)
- Word 3: Address (1 memory read)
After this phase, the values of and 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:
-
Source Operand ( - Indirect Addressing):
- Memory Access 1: Read memory at address to get the effective address of the source operand, say .
- Memory Access 2: Read memory at to fetch the actual source operand value.
-
Destination Operand ( - Indexed Addressing):
- The effective address is calculated internally as (no memory access needed for this addition).
- Memory Access 3: Read memory at to fetch the destination operand value (required because we need to perform ).
-
ALU Operation:
- Add the source and destination values (performed inside the CPU, 0 memory accesses).
-
Write Back:
- Memory Access 4: Write the result back to the destination memory location .
Summing these up, the total number of memory cycles during the execution cycle is:
Therefore, the correct option is B.
Free practice · Your answers on this page are not saved.
