eax has the number to be multiplied
Code: Select all
mov edx, 10
mul edx
mov edx, eax
shl eax, 3
add eax, edx
add eax, edx
mov edx, eax
shl eax, 2
add eax, edx
shl eax, 1
Code: Select all
#include <stdio.h>
#include <windows.h>
#define N 1000
#define I 10000
void InitSystemTime();
double SystemTime();
unsigned int a(const char *string);
unsigned int b(const char *string);
unsigned int c(const char *string);
////////////////////////////////////////////////////////////////
int main()
{
InitSystemTime();
const char *string = "421";
double time;
double stats[3];
unsigned int n, i;
stats[0] = stats[1] = stats[2] = 0.0;
for (n = 0; n < N; n++)
{
time = SystemTime();
for (i = 0; i < I; i++)
{
a(string);
}
stats[0] += SystemTime() - time;
time = SystemTime();
for (i = 0; i < I; i++)
{
b(string);
}
stats[1] += SystemTime() - time;
time = SystemTime();
for (i = 0; i < I; i++)
{
c(string);
}
stats[2] += SystemTime() - time;
}
printf("%g\n", stats[0] / 1);
printf("%g\n", stats[1] / 1);
printf("%g\n", stats[2] / 1);
return 0;
}
////////////////////////////////////////////////////////////////
LARGE_INTEGER Frequency;
BOOL UseHighPerformanceTimer;
void InitSystemTime()
{
BOOL UseHighPerformanceTimer = QueryPerformanceFrequency(&Frequency);
}
double SystemTime()
{
if (UseHighPerformanceTimer)
{
LARGE_INTEGER CurrentTime;
QueryPerformanceCounter(&CurrentTime);
return (double) ((CurrentTime.QuadPart) / Frequency.QuadPart);
}
else
{
return GetTickCount() * 0.001;
}
}
Thanks!