www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/11/20/14:30:32

Message-ID: <32935A5C.33A8@skygames.com>
Date: Wed, 20 Nov 1996 11:22:04 -0800
From: Kevin Baca <kbaca AT skygames DOT com>
Organization: BlueSky Software
MIME-Version: 1.0
To: mat_carter AT bio-rad DOT com
CC: djgpp AT delorie DOT com
Subject: Re: Encoding Pentium RDTSC Instruction
References: <56umct$hh5 AT news2 DOT noc DOT netcom DOT net>

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019