diff --git a/libcpuid/asm-bits.c b/libcpuid/asm-bits.c index af6fdcc..81d610a 100644 --- a/libcpuid/asm-bits.c +++ b/libcpuid/asm-bits.c @@ -85,12 +85,11 @@ void exec_cpuid(uint32_t *regs) #ifdef COMPILER_GCC # ifdef PLATFORM_X64 __asm __volatile( + " mov %0, %%rdi\n" + " push %%rbx\n" " push %%rcx\n" " push %%rdx\n" - " push %%rdi\n" - - " mov %0, %%rdi\n" " mov (%%rdi), %%eax\n" " mov 4(%%rdi), %%ebx\n" @@ -103,21 +102,20 @@ void exec_cpuid(uint32_t *regs) " movl %%ebx, 4(%%rdi)\n" " movl %%ecx, 8(%%rdi)\n" " movl %%edx, 12(%%rdi)\n" - " pop %%rdi\n" " pop %%rdx\n" " pop %%rcx\n" " pop %%rbx\n" : - :"rdi"(regs) - :"memory", "eax" + :"m"(regs) + :"memory", "eax", "rdi" ); # else __asm __volatile( + " mov %0, %%edi\n" + " push %%ebx\n" " push %%ecx\n" " push %%edx\n" - " push %%edi\n" - " mov %0, %%edi\n" " mov (%%edi), %%eax\n" " mov 4(%%edi), %%ebx\n" @@ -130,13 +128,12 @@ void exec_cpuid(uint32_t *regs) " mov %%ebx, 4(%%edi)\n" " mov %%ecx, 8(%%edi)\n" " mov %%edx, 12(%%edi)\n" - " pop %%edi\n" " pop %%edx\n" " pop %%ecx\n" " pop %%ebx\n" : :"m"(regs) - :"memory", "eax" + :"memory", "eax", "edi" ); # endif /* COMPILER_GCC */ #else