This loop doubles all the values stored in an array of 10 elements.
The loop involves 3 + 1 + 3 + 1 + 1 + 2 = 11 memory cycles,
The loop executes 10 times and so would take a total of 11 x 10 cycles = 110 cycles. If each
memory cycle takes 10ns that comes to 1100ns. Including the code outside the loop, there are an
additional 2 + 2 + 2 + 1 = 7 memory cycles (70ns), so the total program execution time would be
1100 + 70 = 1170ns.
If there is a cache 81 of the 110 loop cycles would be cache hits: 9 loop executions x 9 already
fetched instruction words. (For this, include each instruction word after the first time round, but
exclude the data read in the LOAD since the value changes, and the data write in the STORE since
that is a write operation.)
This would give (81 x 1) + ((110 – 81) x 10) = 81 + 290 = 371ns for the duration of the loop with a
cache, and a total of 371+70 = 441ns for the duration of the whole program, including the code
outside the loop.