Question: use C++ language Using timing code design a program that times the how long it takes to write a byte to 2048 memory locations with

use C++ language

Using timing code design a program that times the how long it takes to write a byte to 2048 memory locations with a variable 'skip'. The skip number should be placed in a loop and should be iterated from 0 to 20000. At each iteration, use printf to write out the number of clock cycles it takes to complete that iteration For example, a 0 skip would write to the 0 memory location 2048 times. A skip of 1 would write to memory location 0, memory location 1.... all the way to memory location 2047. Skip 2 would write to 0,2,4,6, and etc.

The timing program:

#include "stdafx.h" int _tmain(int argc, _TCHAR* argv[])

{ char format[] = "Time: %d";

int val; char cache[1000000];

__asm

{

mov ecx, 2048;

lea edi, cache;

RDTSC; //Start Time EDX:EAX

mov[edi], al;

add edi, 16;

mov ebx, eax;

mov ecx, edx;

RDTSC; //End Time

sub eax, ebx;

sbb edx, ecx;

push eax;

lea esi, format;

push esi;

call printf;

pop esi;

pop esi;

nop;

}

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!