00001 /*
00002 File: PentiumCycleCount.h
00003
00004 Function: Cycle counting on intel pentium chips
00005
00006 Author: Andrew Willmott
00007
00008 Copyright: (c) 2000, Andrew Willmott
00009 */
00010
00011 #ifndef __PentiumCycleCount__
00012 #define __PentiumCycleCount__
00013
00014 typedef struct PCC_Counter
00015 {
00016 unsigned long int low;
00017 unsigned long int high;
00018 } PCC_Counter;
00019
00020 void PCC_GetCounter(PCC_Counter *stamp)
00021 {
00022 __asm__(".byte 0x0f,0x31" :
00023 "=a" (stamp->low),
00024 "=d" (stamp->high)
00025 );
00026 }
00027
00028 inline unsigned int PCC_Elapsed(PCC_Counter start, PCC_Counter stop)
00029 {
00030 if (stop.high == start.high)
00031 return(stop.low - start.low);
00032 else
00033 return(start.low -((signed int)(stop.low)));
00034 }
00035
00036 #endif