From: cnc AT netcom DOT com (Christopher Christensen) Date: Thu, 13 Oct 1994 02:09:28 PDT To: "Eli Zaretskii" , djgpp AT sun DOT soe DOT clarkson DOT edu Subject: Re: 32/16bit? Here is the benchmark program I used. It times a 32-bit "xor eax, eax" instruction versus a 16-bit "xor ax, ax" instruction. I ran it on my system which is a 486sx 33Mhz. My results showed that the 16-bit instruction executs in 2 clocks and the 32-bit instruction executes in only 1. Note, I ran this benchmark program under Linux. I have not even tried to compile it for djgpp, but it should work. In order to get sufficiently accurate results, you may need to increase the value for ICOUNT depending on your machine's speed and timer resolution. /* the benchmark program (for GCC on i386 boxes) */ #include #include /* a tenth of my clock rate */ #define ICOUNT 3333333 #define BCOUNT 1 /* reference loop */ void test0() { asm("mov %0, %%ecx\n" "0: \n" " decl %%ecx\n" " jnz 0b\n" :: "i" (ICOUNT)); } /* 32-bit loop */ void test1() { asm("mov %0, %%ecx\n" "0: \n" " xorl %%eax, %%eax\n" " xorl %%eax, %%eax\n" " xorl %%eax, %%eax\n" " xorl %%eax, %%eax\n" " xorl %%eax, %%eax\n" " xorl %%eax, %%eax\n" " xorl %%eax, %%eax\n" " xorl %%eax, %%eax\n" " xorl %%eax, %%eax\n" " xorl %%eax, %%eax\n" " decl %%ecx\n" " jnz 0b\n" :: "i" (ICOUNT)); } /* 16-bit loop */ void test2() { asm("mov %0, %%ecx\n" "0: \n" " xorw %%ax, %%ax\n" " xorw %%ax, %%ax\n" " xorw %%ax, %%ax\n" " xorw %%ax, %%ax\n" " xorw %%ax, %%ax\n" " xorw %%ax, %%ax\n" " xorw %%ax, %%ax\n" " xorw %%ax, %%ax\n" " xorw %%ax, %%ax\n" " xorw %%ax, %%ax\n" " decl %%ecx\n" " jnz 0b\n" :: "i" (ICOUNT)); } int benchmark(void (*fptr)()) { int i; clock_t t1, t2; (*fptr)(); t1=clock(); for(i=0; i