帮忙找错
#include <iostream.h>#include <conio.h>
#include <time.h>
int main()
{
int i = 0;
int a = 0;
int b = 0;
clrscr();
for(;i < 3 ; i++)
{
a = clock();
asm mov si,1
asm mov cx,60000
loop0:
asm push cx
asm mov cx,6000
metka:
asm push cx
switch(i)
{
case 0:
asm{
add ax,bx
add ax,bx
add ax,bx
add ax,bx
add ax,bx
add ax,bx
add ax,bx
add ax,bx
add ax,bx
add ax,bx
}
break;
case 1:
asm{
add ax,[bx]
add ax,[bx]
add ax,[bx]
add ax,[bx]
add ax,[bx]
add ax,[bx]
add ax,[bx]
add ax,[bx]
add ax,[bx]
add ax,[bx]
add ax,[bx]
}
break;
case 2:
//mov si,1
asm push cx
asm{
add ax,[bx+si]
add dx,[bx+si]
add cx,[bx+si]
add ax,[bx+si]
add dx,[bx+si]
add cx,[bx+si]
add ax,[bx+si]
add dx,[bx+si]
add cx,[bx+si]
add ax,[bx+si]
}
asm pop cx
break;
}
asm pop cx
asm loop metka
asm pop cx
asm loop loop0
b = clock();
cout << "Time"<<i<<"="<<(b-a)/CLK_TCK << endl;
}
for(i = 3 ; i < 5 ; i++)
{
a = clock();
asm mov cx,60000
loop2:
asm push cx
asm mov cx,6000
metka1:
asm push cx
switch(i)
{
case 3:
asm{
add ax,[bx+SI+5]
add ax,[bx+SI+5]
add ax,[bx+SI+5]
add ax,[bx+SI+5]
add ax,[bx+SI+5]
add ax,[bx+SI+5]
add ax, [bx+SI+5]
add ax,[bx+SI+5]
add ax,[bx+SI+5]
add ax,[bx+SI+5]
}
break;
case 4:
asm{
mov bx,0xb900
add [bx],ax
add [bx],ax
add [bx],ax
add [bx],ax
add [bx],ax
add [bx],ax
add [bx],ax
add [bx],ax
add [bx],ax
add [bx],ax
}
}
asm pop cx
asm loop metka1
asm pop cx
asm loop loop2
b = clock();
cout << "Time"<<i<<"="<<(b-a)/CLK_TCK << endl;
}
getch();
return 0;
}
我需要求几种情况循环时间,