Multiple choice

Consider the following program segment for a hypothetical CPU having three user registers Rl R2 and R3. Instruction Operation Instruction Size in word. MOV Rl,5000 ; Rl ¬ Memory[5000] 2 MOV R2,(R1) ; R2 ¬ Memory[(Rl)] ADD R2,R3 ; R2 ¬ R2 + R3 1 MOV 6000, R2 ; Memory[6000] ¬ R2 2 HALT; Machine halts 1 Let the clock cycles required for various operations be as follows. 1 Register to/from memory transfer : 3 clock cycles ADD with both operands in register: 1 clock cycle Instruction fetch and decode : 2 clock cycles per word The total number of clock cycles required to execute the program is

  1. 29

  2. 24

  3. 23

  4. 20

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Instruction fetch/decode: 2 cycles per word. Memory transfer: 3 cycles. ADD: 1 cycle. MOV R1,5000 (2 words): 4 cycles + 3 (mem) = 7. MOV R2,(R1) (1 word): 2 cycles + 3 (mem) = 5. ADD R2,R3 (1 word): 2 cycles + 1 = 3. MOV 6000,R2 (2 words): 4 cycles + 3 (mem) = 7. HALT (1 word): 2 cycles. Total: 7+5+3+7+2 = 24.