X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dosdemo;a=blobdiff_plain;f=src%2Futil.h;fp=src%2Futil.h;h=6d200b7824f14dbcff470db501150d193d6b7920;hp=f8ae175a8af4128ac6268cf8db87ed8b059e41ad;hb=8c475e1fd504f46cbb8a882e760714925c012890;hpb=95432d94ee6d5cd0c1f71c36b78e195f1b96892f diff --git a/src/util.h b/src/util.h index f8ae175..6d200b7 100644 --- a/src/util.h +++ b/src/util.h @@ -24,42 +24,53 @@ static INLINE int32_t cround64(double val) return *(int32_t*)&val; } -uint32_t perf_start_count, perf_interval_count; +extern uint32_t perf_start_count, perf_interval_count; #ifdef __WATCOMC__ void perf_start(void); #pragma aux perf_start = \ + "xor eax, eax" \ + "cpuid" \ "rdtsc" \ "mov [perf_start_count], eax" \ - modify[eax edx]; + modify[eax ebx ecx edx]; void perf_end(void); #pragma aux perf_end = \ + "xor eax, eax" \ + "cpuid" \ "rdtsc" \ "sub eax, [perf_start_count]" \ "mov [perf_interval_count], eax" \ - modify [eax edx]; + modify [eax ebx ecx edx]; #endif #ifdef __GNUC__ #define perf_start() asm volatile ( \ + "xor %%eax, %%eax\n" \ + "cpuid\n" \ "rdtsc\n" \ "mov %%eax, %0\n" \ - : "=m"(perf_start_count) :: "%eax", "%edx") + : "=m"(perf_start_count) \ + :: "%eax", "%ebx", "%ecx", "%edx") #define perf_end() asm volatile ( \ + "xor %%eax, %%eax\n" \ + "cpuid\n" \ "rdtsc\n" \ "sub %1, %%eax\n" \ "mov %%eax, %0\n" \ : "=m"(perf_interval_count) \ : "m"(perf_start_count) \ - : "%eax", "%edx") + : "%eax", "%ebx", "%ecx", "%edx") #endif #ifdef _MSC_VER #define perf_start() \ do { \ __asm { \ + xor eax, eax \ + cpuid \ rdtsc \ mov [perf_start_count], eax \ } \ @@ -68,6 +79,8 @@ void perf_end(void); #define perf_end() \ do { \ __asm { \ + xor eax, eax \ + cpuid \ rdtsc \ sub eax, [perf_start_count] \ mov [perf_interval_count], eax \