News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

What the heck is RDTSC?

Started by n00b!, March 15, 2009, 12:40:36 AM

Previous topic - Next topic

n00b!

I searched for it in opcodes.chm and I used Google but I did not find out what "RDTSC" does...
OllyDbg says it's a correct mnemonic for a working machine opcode...

Thanks!


EDIT: Ah, was too lazy to read...

http://en.wikipedia.org/wiki/Time_Stamp_Counter
"It counts the number of ticks since reset, and is only accessible through the RDTSC instruction. This instruction returns the TSC in EDX:EAX"

donkey

ReaD Time Stamp Clock

moves the count of the time stamp clock (in ticks) into the EDX:EAX register pair. The time stamp clock keeps track of the number of ticks since the machine was turned on or reset.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

ecube

whats its downsides, why not use that instead of gettickcount?

BlackVortex

Quote from: E^cube on March 15, 2009, 03:32:58 PM
whats its downsides, why not use that instead of gettickcount?
GetTickCount is extremely inaccurate. RDTSC is inconsistent between different cpus though.

MichaelW

The problem with GetTickCount is not its accuracy - because it's probably using the same frequency reference as the other counters in the system - the problem is its relatively low resolution, 10ms by default, or 1ms at best. The Time Stamp Counter (TSC) is the highest resolution counter available, with a period that can be in the sub-nanosecond range. For a processor with a variable clock speed the TSC is not very useful as a time base (e.g. as the basis for a timer or a short programmable delay), but its usefulness for "timing" code (or whatever) in clock cycles is unaffected.
eschew obfuscation

Rainstorm

Thanks for the explanation, this answered a few questions i had in my mind too.