Page 1 of 1

intel inline assembly with gcc

Posted: Sun Jun 26, 2005 11:00 pm
by kan
hi,
i want to use inline assembly (with INTEL syntax) in my C Kernel code.
can i code like this in one of my C functions :

void CheckProcessor(void)
{
asm
{
mov eax,0x00;
cpuid;
.........
}
}

i give following compile options :

gcc -o KLoader.o -c KLoader.c -Wall -Werror -W --no-warn -nostdlib -nostartfiles -nodefaultlibs -masm=intel

given above options gcc doesn't compile source code. i think it has some problem with 'asm' keyword?
any solution would be highly appreciated!

Re: intel inline assembly with gcc

Posted: Mon Jun 27, 2005 11:00 pm
by bregma
kan wrote:

Code: Select all

void CheckProcessor(void)
{
  asm 
  {
     mov eax,0x00;
     cpuid;
     .........
  }
}
That's not the right syntax for GCC inline assembler. Inline assembly is a non-standard extension to any compiler. Regardless of the assembler syntax itself, GCC's extended asm syntax is more like the following.

Code: Select all

void CheckProcessor(void)
{
  asm("mov eax,0x00\n\tcpuid"
           : /* output constraints */ 
           : /* input constraints */
           : /* clobbers */);
  .......
}
You might want to consult your GCC documentation for more information.

--
smw