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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started