Originally Posted by
brewbuck
This is all unnecessary. GCC will automatically save and restore any registers it needs to. Just make sure that EBX is listed in the clobber list or the output list.
That's strange, because I did this after a tester of my tool reported the following error compiling my program:
Code:
error: can't find a register in class ‘BREG’ while reloading ‘asm’
With Google I found the following: http://sam.zoy.org/blog/2007-04-13-s...d-pic-mix-well
So I decided to save the EBX register in my "keeper" variable and AFAIK it worked for that guy...
My original code looks like this, maybe you can tell me if there's another culprit that could lead to the reported problem:
Code:
void cpuid(int *a, int *b, int *c, int *d)
{
__asm__ __volatile__ (" mov %4, %%eax;"
" mov %5, %%ecx;"
" cpuid;"
" mov %%eax, %0;"
" mov %%ebx, %1;"
" mov %%ecx, %2;"
" mov %%edx, %3;"
/* Output */ : "=a" (*a), "=r" (*b), "=c" (*c), "=d" (*d)
/* Input */ : "a" (*a), "c" (*c) );
}
Peter