www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/04/15/19:12:58

From: "Thomas Harte" <T DOT Harte AT btinternet DOT com DOT DELETE_HERE>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: CPUID Opcode
Date: Sun, 16 Apr 2000 00:43:18 +0100
Organization: BT Internet
Lines: 51
Message-ID: <8dav0m$1li$1@plutonium.btinternet.com>
References: <38F8B55B DOT 5BFDA8E0 AT home DOT com>
NNTP-Posting-Host: host213-1-152-179.btinternet.com
X-Newsreader: Microsoft Outlook Express 4.72.3155.0
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3155.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Robin Johnson wrote in message <38F8B55B DOT 5BFDA8E0 AT home DOT com>...
>Whenever I call the CPUID Opcode in the inline asm, my program seems to
fail.

First thing - don't forget that CPUID only works on Pentiums and above. I'm
sure you hadn't!

>{ __asm__ __volatile__
>  ( " pushl %%eax\n pushl %%ebx\n pushl %%ecx\n pushl %%edx\n

You don't actually have to do push'ing and pop'ing yourself if you're
including the registers in the list of those clobbered.

>          movl %4, %%eax \n
>          cpuid      \n
>   movl %%eax, %0 \n
>    movl %%ebx, %1 \n
>    movl %%ecx, %2 \n
>    movl %%edx, %3 \n

Perhaps I'm confused, but what are these lines meant to be doing? They look
to me like they will just move eax to memory location 0, ebx to location 1
and so on. Surely that is worth a SIGSEGV?

If they're meant to be moving the registers back into the variables, then
again this is handled for you by the "=g" section of your inline assembly.

>Exiting due to signal SIGSEGV
>General Protection Fault at eip=000015c8
>eax=00000001 ebx=756e6547 ecx=6c65746e edx=49656e69 esi=0008eec4
edi=0008eec0
>ebp=0008ee98 esp=0008ee6c program=G:\PROG\CPUDET~1\CPUID.EXE
>cs: sel=00a7  base=86008000  limit=0009ffff
>ds: sel=00af  base=86008000  limit=0009ffff
>es: sel=00af  base=86008000  limit=0009ffff
>fs: sel=0087  base=00011220  limit=0000ffff
>gs: sel=00bf  base=00000000  limit=0010ffff
>ss: sel=00af  base=86008000  limit=0009ffff
>App stack: [0008eef0..0000eef0]  Exceptn stack: [0000edd8..0000ce98]
>
>Call frame traceback EIPs:
>  0x000015c8
>  0x00001626
>  0x0000263a

Have you tried running symify or a step debugger?

-Thomas


- Raw text -


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