Show your support by donating any amount. (Note: We are still technically a for-profit company, so your
contribution is not tax-deductible.)
PayPal Acct:
Feedback:
Donate to VoyForums (PayPal):
[ Login ] [ Contact Forum Admin ] [ Main index ] [ Post a new message ] [ Search | Check update time ] |
#include <iostream.h>
#include <time.h>
//compare the speed of using assembly and C code
void main()
{
const long num=5000;
const long outloop=100000;
short a[num];
long lTime;
lTime=clock(); //begin
//======================================
//insert your code here
//===================================
lTime=clock()-lTime; //end
cout << "a[4999] = " << a[4999] << endl;
cout << "Your time = " << lTime <<endl;
lTime=clock(); //begin
_asm
{
mov ecx,outloop;
mov ebx,num;
Outloop:
mov edx, ecx;
mov ecx, ebx ;
xor esi, esi ;
xor eax, eax;
DoAgain:
mov word ptr a[esi], ax;
inc eax;
add esi,2;
loop DoAgain
mov ecx, edx;
loop Outloop
}
lTime=clock()-lTime; //end
cout << "a[4999] = " << a[4999] << endl;
cout << "Asm time= " << lTime <<endl;
}