Message-ID: <32935A5C.33A8@skygames.com> Date: Wed, 20 Nov 1996 11:22:04 -0800 From: Kevin Baca 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> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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