Mail Archives: djgpp/1996/11/20/14:30:32
mat_carter AT bio-rad DOT com wrote:
>
> I'm trying to use the Pentium RDTSC instruction to time my code, but the GNU
> assembler (AS.EXE) tells me it's an unknown 386 instruction. I always compile
> via GCC using the -m486 option but if I use -m586 it chucks an error.
>
> Do I need a patch or the latest release of DJGPP (preferably not all of it - again)
> or can someone tell me how to code up the instruction so that it can be passed
> thru to AS.EXE via inline asm or an x.S file - I guess in binary format?
as does not recognize several x86 instructions. You must code their
byte codes explicitly.
A few months ago I posted some macros to implement RDTSC, RDMSR, and
WRMSR. You can probably find them by searching the mail archives at
http://www.delorie.com.
Anyway, here's the RDTSC macro
#define RDTSC(_dst) \
__asm__(".byte 0x0F,0x31
movl %%edx,(%%edi)
movl %%eax,4(%%edi)"\
: : "D" (_dst) : "eax", "edx", "edi")
int main(void)
{
unsigned int tst[2];
RDTSC(tst);
printf("0x%x%x\n", tst[0], tst[1]);
}
-Kevin
- Raw text -