|
3#
楼主 |
发表于 2006-12-17 22:41
|
只看该作者
//源代码
#include "stdio.h"
#include "time.h"
void main(void)
{
unsigned int r_eax0, r_edx0, r_eax2, r_edx2, clk;
double v0, v2;
printf("Pipeline test starts, please waiting for ......n");
_asm{
rdtsc
mov r_eax0,eax
mov r_edx0,edx
}
clk = clock();
_asm
{
mov ecx,2*970000
mov edi,211309892;
mov edx,738904833;
mov eax,23459;
mov ebx,586909;
L1:
L1a:
sub eax,ebx;
xor edx,eax;
jpe L1a;
add edi,edx;
xor ebx,edi;
jpe L1a;
L2a:
sub eax,ebx;
xor edx,eax;
jpe L2a;
add edi,edx;
xor ebx,edi;
jpe L1a;
L3a:
sub eax,ebx;
xor edx,eax;
jpe L3a;
add edi,edx;
xor ebx,edi;
jpe L1a;
L4a:
sub eax,ebx;
xor edx,eax;
jpe L4a;
add edi,edx;
xor ebx,edi;
jpe L1a;
L5a:
sub eax,ebx;
xor edx,eax;
jpe L5a;
add edi,edx;
xor ebx,edi;
jpe L1a;
L6a:
sub eax,ebx;
xor edx,eax;
jpe L6a;
add edi,edx;
xor ebx,edi;
jpe L1a;
dec ecx;
jnz L1;
}
clk=(clock()-clk);
_asm{
rdtsc
mov r_eax2,eax
mov r_edx2,edx
}
v0 = (double) r_eax0 + ((double) r_edx0 ) * 4294967296.0;
v2 = (double) r_eax2 + ((double) r_edx2 ) * 4294967296.0;
printf("Time = %5.3f s, %gMHz, Ratio = %gnn",(float)(clk)/1000.0,
(float)(v2 - v0) /(float)(clk)/1000.0,
(v2 - v0)/8520000000.0 * 14.0);
printf("Pipeline = %.2g stagesnTest ends. Press ENTER to exit.", (v2 - v0)/8520000000.0 * 14.0);
getchar();
} |
|