Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Suppose that you are working with a CISC machine using a 3 GHz clock (i.e., the

ID: 3847897 • Letter: S

Question

Suppose that you are working with a CISC machine using a 3 GHz clock (i.e., the clock ticks 3 billion times per second). This particular computer uses MASM-like instructions with the following timings:

Suppose that the following code fragment is used to sum elements of a numeric array. For this problem, assume that memory limitations are non-existent and that there is no limit to the size of the array.

loop more ;auto-decrement ecx, jump to more if ecx 0

After initialization, how many array elements can be processed in 2.9 ms? Round your answer to the nearest integer. Note that 1 ms. = 0.001 second.

esi

Explanation / Answer

   mov bx, 0            ;initialize sum
   mov ecx, MAX_SIZE     ;initialize loop counter
   mov esi, OFFSET list ;initialize array pointer
more:
   add bx, [esi] ;add current list element {8 clocks}

add esi, 2 ;move array pointer to next element {3 clocks}

loop more ;auto-decrement ecx, jump to more if ecx 0 {5 clocks}


each loop consumes 16clocks

In 2.9ms we have 8700000 clocks

So in 8700000 we can loop for 543750 times

So in 2.9ms the processor can process 543750 array elements

-----------------------------------------------------------------------------------------,-------------------------

Calculations:

In 1 second we have 3,000,000,000 clocks
in 0.0029sec we have 3000000000 * 0.0029 clocks

3000000000 * 0.0029 = 8700000

in 16clocks we can iterate for 1 time
in 8700000 clks we can iterate for 8700000/16 or 543750 times

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote