Hello guys,
Im trying to understand the how to code asm inside a C code. So, i want to use the "cpuid" assembly instruction, but im doing something wrong on the code:
Code:
#include <stdio.h>
int main()
{
unsigned int maxBasicCPUID;
char vendorString[13];
char *vendorStringPtr=(char *)vendorStringPtr;
__asm__("movl %a,%%edi\n\t"
"movl $0,%eax\n\t"
"cpuid\n\t"
"movl %%eax,%0\n\t"
"movl %ebx,(%edi)\n\t"
"movl %edx,4(%edi)\n\t"
"movl %ecx,8(%edi)\n\t"
:"=g" (maxBasicCPUID)
:"m" (vendorStringPtr)
:"memory"
);
vendorString[12]=9;
printf("maxBasicCPUID=%x, vendorString=%s\n", maxBasicCPUID,vendorString);
return 0;
}
When i try to compile, i got the following error:
# gcc -o cpuid cpuid.c
cpuid.c: In function ‘main’:
cpuid.c:9: error: invalid 'asm': operand number missing after %-letter
cpuid.c:9: error: invalid 'asm': operand number missing after %-letter
cpuid.c:9: error: invalid 'asm': operand number missing after %-letter
cpuid.c:9: error: invalid 'asm': operand number missing after %-letter
cpuid.c:9: error: invalid 'asm': operand number missing after %-letter
cpuid.c:9: error: invalid 'asm': operand number missing after %-letter
cpuid.c:9: error: invalid 'asm': operand number missing after %-letter
cpuid.c:9: error: invalid 'asm': operand number missing after %-letter
Can anyone help me with that!?
Tks guys!
Bookmarks