First post, by red-ray
- Rank
- Oldbie
I am trying to figure out the best way to implement the PowerPC equivalent of the x32/x64 RDTSC instruction on Windows NT V4.00 SP2 and it seems to be to use the PowerPC TB register. I have written some assembler and would be interested to know if others think it's optimal/correct. It gives values what seem correct when I run it on my 133 Mhz PowerPC 604 Motorola PowerStack system, but I need to multiply the value by 8.
Looking at http://www.cap-lore.com/code/TB/ it mentions x 16 is needed, it also has the http://www.cap-lore.com/code/TB/tb.s code that seems very strange to me, my code is:
.globl ..ppc_rdtsc.section .text..ppc_rdtsc:mftbu r4 # read TB uppermftb r3 # read TB lowermftbu r5 # read TB upper for checkcmpl 0,0,r4,r5 # TB upper changed ?bne ..ppc_rdtsc # if NE yes, try againblr # done
How can I know what to multiply by? Will I need a table for all the different CPU models (PVR values)?
Note: I am interested in solutions, not posts that simply imply it's tricky without links to justify the opinions.