c - Why should I use 'rdtsc' differently on x86 and x86_x64? -
i know rdtsc
loads current value of processor's time-stamp counter 2 registers: edx , eax. in order on x86 need (assuming using linux):
unsigned long lo, hi; asm( "rdtsc" : "=a" (lo), "=d" (hi)); return lo;
and x86_x64:
unsigned long lo, hi; asm( "rdtsc" : "=a" (lo), "=d" (hi) ); return( lo | (hi << 32) );
why that? can explain me?
in x86-64 mode, rdtsc clears higher 32 bits of rax. compensate bits have shift hi left 32 bits.
Comments
Post a Comment