Common: Change cpuid code again

Looks like compilers tend to use EBX for parameters if not told otherwise and
don't bother to update SP in leaf functions, so PUSH/POP kill local variables.


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7151 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
pierre 2011-02-12 18:40:02 +00:00
parent 94176c02a8
commit e81ccd7f33
1 changed files with 12 additions and 10 deletions

View File

@ -39,27 +39,29 @@ static inline void do_cpuid(unsigned int *eax, unsigned int *ebx,
// Note: EBX is reserved on Mac OS X and in PIC on Linux, so it has to // Note: EBX is reserved on Mac OS X and in PIC on Linux, so it has to
// restored at the end of the asm block. // restored at the end of the asm block.
__asm__ ( __asm__ (
"push %%rbx;" "mov %%rbx,%%rdi;"
"cpuid;" "cpuid;"
"movl %%ebx,%1;" "movl %%ebx,%1;"
"pop %%rbx;" "mov %%rdi,%%rbx;"
: "=a" (*eax), : "=a" (*eax),
"=r" (*ebx), "=g" (*ebx),
"=c" (*ecx), "=c" (*ecx),
"=d" (*edx) "=d" (*edx)
: "a" (*eax) : "a" (*eax)
: "rdi", "rbx"
); );
#else #else
__asm__( __asm__(
"pushl %%ebx;" "movl %%ebx,%%edi;"
"cpuid;" "cpuid;"
"movl %%ebx,%1;" "movl %%ebx,%1;"
"popl %%ebx;" "movl %%edi,%%ebx;"
: "=a" (*eax), : "=a" (*eax),
"=r" (*ebx), "=g" (*ebx),
"=c" (*ecx), "=c" (*ecx),
"=d" (*edx) "=d" (*edx)
: "a" (*eax) : "a" (*eax)
: "edi", "ebx"
); );
#endif #endif
} }