Mail Archives: djgpp/2007/10/25/05:25:19
> > asm ("cpuid" : "=a" (iRet) : : "ebx", "ecx", "edx");
> Thanks. Okay, it doesn't, so correct the code... I wasn't sure if the asm
> directive inserted a pusha; popa combination into the stackframe, say
> instead of push ebp; pop ebp, or used some other method. That might mess up
> returns...
Thanks DJ and RP - you put me on the right track.
My example was just a simplified version to show my main problem. For other people who
battle with the same problem, here is my full code. The stack frame and saving of registers
are taken care of by GCC - I checked with GDB and the code runs without crashing :)
int IsSc410Processor (void)
{
int iRet;
asm ( "xorl %%eax,%%eax\n\t"
"cpuid\n\t"
"cmpl $1,%%eax\n\t"
"jnz NotMine\n\t"
"cmpw $0x7541,%%bx\n\t" // Check low order string portions
"jnz NotSc410\n\t"
"cmpw $0x4163,%%cx\n\t"
"jnz NotSc410\n\t"
"cmpw $0x6e65,%%dx\n\t"
"jnz NotSc410\n\t"
"cpuid\n\t"
"orw %%cx,%%bx\n\t"
"orw %%bx,%%dx\n\t"
"jnz NotSc410\n\t" // Jump if FPU or other feature present
"movw %%ax,%%bx\n\t"
"andw $0x0f,%%bx\n\t"
"xorw %%bx,%%ax\n\t"
"cmpw $4,%%bx\n\t" // Check for stepping 4 or greater
"jb NotSc410\n\t"
"cmpw $0x4a0,%%ax\n\t" // Check features
"jnz NotSc410\n\t"
"movl $1,%%eax\n\t"
"jmp ok\n\t"
"NotSc410: xorl %%eax,%%eax\n\t"
"ok:\n\t" : "=a" (iRet) :: "ebx","ecx","edx");
return iRet;
}
--
Gerrit van Niekerk
GP van Niekerk Ondernemings BK
Roosstraat 211, Meyerspark, 0184, South Africa
Tel: +27(12)8036501 Fax SA: 0866 413 555
Cell: +27(73)6891370
Fax Int'l: +1(206)2034139
Email: gerritvn AT gpvno DOT co DOT za
Web: http://www.gpvno.co.za
- Raw text -