2006-10-30 16:53:38 +01:00
|
|
|
#
|
|
|
|
! sections
|
|
|
|
|
|
|
|
.sect .text; .sect .rom; .sect .data; .sect .bss
|
|
|
|
|
|
|
|
.define _read_tsc ! read the cycle counter (Pentium and up)
|
|
|
|
|
|
|
|
.sect .text
|
|
|
|
!*===========================================================================*
|
|
|
|
! PUBLIC void read_tsc(unsigned long *high, unsigned long *low);
|
|
|
|
! Read the cycle counter of the CPU. Pentium and up.
|
|
|
|
.align 16
|
|
|
|
_read_tsc:
|
2007-03-08 16:39:14 +01:00
|
|
|
push edx
|
|
|
|
push eax
|
2006-10-30 16:53:38 +01:00
|
|
|
.data1 0x0f ! this is the RDTSC instruction
|
|
|
|
.data1 0x31 ! it places the TSC in EDX:EAX
|
|
|
|
push ebp
|
2007-03-08 16:39:14 +01:00
|
|
|
mov ebp, 16(esp)
|
2006-10-30 16:53:38 +01:00
|
|
|
mov (ebp), edx
|
2007-03-08 16:39:14 +01:00
|
|
|
mov ebp, 20(esp)
|
2006-10-30 16:53:38 +01:00
|
|
|
mov (ebp), eax
|
|
|
|
pop ebp
|
2007-03-08 16:39:14 +01:00
|
|
|
pop eax
|
|
|
|
pop edx
|
2006-10-30 16:53:38 +01:00
|
|
|
ret
|
|
|
|
|