EasyManua.ls Logo

AMD K5

AMD K5
406 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
3-32 Software Environment and Extensions
AMD-K5 Processor Technical Reference Manual 18524C/0Nov1996
3.3.4 RDTSC
mnemonic opcode description
RDTSC 0F31 Read time stamp counter
Privilege: Selectable by TSD bit in CR4
Registers Affected: EAX, EDX
Flags Affected: none
Exceptions Generated: Real, Virtual-8086 modeInvalid Opcode
Protected modeGP (0) if CPL not = 0 when CR4.TSD = 1
The processor’s 64-bit time stamp counter (TSC) increments on each processor clock.
In Real or Protected mode, the counter can be read with the RDMSR instruction and
written with the WRMSR instruction when CPL = 0. However, in Protected mode the
RDTSC instruction can be used to read the counter at privilege levels higher than
CPL = 0.
The required privilege level for using the RDTSC instruction is determined by the
Time Stamp Disable (TSD) bit in CR4, as follows:
CPL = 0Set the TSD bit in CR4 to 1
Any CPLClear the TSD bit in CR4 to 0
The RDTSC instruction reads the counter value into the EDX and EAX registers as
follows:
EDXUpper 32 bits of TSC
EAXLower 32 bits of TSC
The following example shows how the RDTSC instruction can be used. After this
code is executed, EAX and EDX contain the time required to execute the RDTSC
instruction.
mov ecx,10h ;Time Stamp Counter Access via MSRs
mov eax,00000000h ;Initialize the Counter to zero
db 0Fh, 30h ;WRMSR
db 0Fh, 31h ;RDTSC
db 0Fh, 31h ;RDTSC

Table of Contents

Related product manuals