Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

More Books

Students also viewed these Databases questions

Question

What is electric dipole explain with example

Answered: 1 week ago

Question

What is polarization? Describe it with examples.

Answered: 1 week ago

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago