I literally picked up asm today. I have been trying to create a 3d software rendering engine in C++, and figured out doing things directly would be faster....but, I tried the following code:
int _tmain(int argc, _TCHAR* argv[])
{
int num, timestart, dur;
timestart = clock();
for(int i = 0 ; i < 10000000; i++)
{
__asm
{
MOV EAX, 11;
MOV ECX, 5;
XOR EDX, EDX;
DIV ECX;
MOV num, EDX;
}
//num = 11 / 5;
}
dur = clock() - timestart;
cout << dur << endl;
getch();
return 0;
}
first I tried it the way it is now, and then I un-commented "num = 11 / 5;" inside the for loop, and commented out the asm. For the above test, the variable dur read 156 milliseconds for the asm and only 78 milliseconds for the C++...
can anyone explain?
Thanks =)