Reply by Clifford Heath April 18, 20052005-04-18
Bryan Hackney wrote:
> inline unsigned long long rdtsc( ) { > unsigned long long ull; > __asm__ __volatile__ ( "rdtsc" : "=&A" ( ull ) : ); > return ull; > }
... And don't forget to handle the illegal instruction trap on non-Intel processors that don't do RDTSC...
Reply by Bryan Hackney April 17, 20052005-04-17
Rami wrote:
> Thanks. This should do the job. > How can I access this register in C code using the GNU compiler? > Since RDTSC loads the counter to EDX:EAX, > I tried something like this: > __asm__("RDTSC"); > __asm__("MOV %0,EAX" : "=r"(ulVar) : "); > > The code compiled, but downloading it to the target gave an error > regarding EAX. > Any Ideas? > Thank you. >
inline unsigned long long rdtsc( ) { unsigned long long ull; __asm__ __volatile__ ( "rdtsc" : "=&A" ( ull ) : ); return ull; }
Reply by Rami April 17, 20052005-04-17
Thanks.  This should do the job.
How can I access this register in C code using the GNU compiler?
Since RDTSC loads the counter to EDX:EAX,
I tried something like this:
__asm__("RDTSC");
__asm__("MOV %0,EAX" : "=r"(ulVar) : ");

The code compiled, but downloading it to the target gave an error
regarding EAX.
Any Ideas?
Thank you.

Reply by Paul Keinanen April 17, 20052005-04-17
On 17 Apr 2005 02:25:47 -0700, "Rami" <rami48@gmail.com> wrote:

>I'm running VxWorks Os on a Pentium 3 processor. The VxWorks timers >are based on the OS ticks (several mili seconds), but I need a way to >measure small time intervals of micro seconds. >Is there a Real Time clock register to read, or a cotinueosly running >counter register to calculate the interval time from it?
The 64 bit Time Stamp Counter (TSC) and the RDTSC instruction should be available on all Pentiums. It counts clock cycles, so you need some means (e.g. the CMOS clock) to first measure the clock frequency, which is quite temperature dependent. Especially mobile processors entering some kind of sleep mode may give erratic readings. Paul
Reply by Rami April 17, 20052005-04-17
Hi,
I'm running VxWorks Os on a Pentium 3 processor.  The VxWorks timers
are based on the OS ticks (several mili seconds), but I need a way to
measure small time intervals of micro seconds.
Is there a Real Time clock register to read, or a cotinueosly running
counter register to calculate the interval time from it?
Thanks.