GATE / CS ARCHIVE

GATE CSE 2004 / QUESTION 64

Instruction fetch and execution cycles

Computer Organization & Architecture · Processor Performance · Full GATE CSE 2004 paper

GATE 2004, Q64 2 marks · MCQ
Report issue

Processor Performance

Question 64, GATE 2004: A CPU has user registers R1,R2,R3. Program in order (operation; instruction size in words): MOV R1,5000 (R1←Memory[5000];2); MOV R2,(R1) (R2←Memory[R1];1); ADD R2,R3 (R2←R2+R3;1); MOV 6000,R2 (Memory[6000]←R2;2); HALT (machine halts;1). Each register/memory transfer costs 3 cycles, register ADD costs 1 cycle, and instruction fetch/decode costs 2 cycles per word. What is the total execution-cycle count?
Options:
(A) 29
(B) 24
(C) 23
(D) 20
Question 64, GATE 2004: A CPU has user registers R1,R2,R3. Program in order (operation; instruction size in words): MOV R1,5000 (R1←Memory[5000];2); MOV R2,(R1) (R2←Memory[R1];1); ADD R2,R3 (R2←R2+R3;1); MOV 6000,R2 (Memory[6000]←R2;2); HALT (machine halts;1). Each register/memory transfer costs 3 cycles, register ADD costs 1 cycle, and instruction fetch/decode costs 2 cycles per word. What is the total execution-cycle count?
Options:
(A) 29
(B) 24
(C) 23
(D) 20
Question 64, GATE 2004: A CPU has user registers R1,R2,R3. Program in order (operation; instruction size in words): MOV R1,5000 (R1←Memory[5000];2); MOV R2,(R1) (R2←Memory[R1];1); ADD R2,R3 (R2←R2+R3;1); MOV 6000,R2 (Memory[6000]←R2;2); HALT (machine halts;1). Each register/memory transfer costs 3 cycles, register ADD costs 1 cycle, and instruction fetch/decode costs 2 cycles per word. What is the total execution-cycle count?
Options:
(A) 29
(B) 24
(C) 23
(D) 20
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. There are 7 instruction words, so fetch/decode costs 7×2=14 cycles. The first MOV loads a memory word, the second MOV uses register-indirect addressing to load one memory word, and the last MOV stores one memory word:3 transfers×3=9 cycles.

2. ADD has register operands and costs 1. No extra HALT execution cost is specified.

3. Total14+9+1=24 cycles. Register-indirect addressing does not itself require another memory load because R1 already contains the address.

4. Teaching check: The instruction sizes sum to seven words, so fetch/decode alone costs fourteen cycles. Indirect MOV R2,(R1) uses R1’s value as an address; it does not first fetch that address from memory. This leaves exactly three data-memory transfers and one ADD.

Original paper, page 9