Made inline-assembly more readable
Former-commit-id: 82d94d3c7f314d7d8396c0a73a53d2ffea7b4d3c
This commit is contained in:
parent
f4591bd331
commit
158fdbf62b
|
|
@ -15,13 +15,12 @@
|
|||
void NzHardwareInfoImpl::Cpuid(nzUInt32 code, nzUInt32 result[4])
|
||||
{
|
||||
#if defined(NAZARA_COMPILER_MSVC)
|
||||
__cpuid(reinterpret_cast<int*>(result), static_cast<int>(code));
|
||||
__cpuid(reinterpret_cast<int*>(result), static_cast<int>(code)); // Visual propose une fonction intrinsèque pour le cpuid
|
||||
#elif defined(NAZARA_COMPILER_CLANG) || defined(NAZARA_COMPILER_GCC) || defined(NAZARA_COMPILER_INTEL)
|
||||
// Source: http://stackoverflow.com/questions/1666093/cpuid-implementations-in-c
|
||||
asm volatile
|
||||
("cpuid"
|
||||
:"=a" (result[0]), "=b" (result[1]), "=c" (result[2]), "=d" (result[3])
|
||||
:"a" (code), "c" (0));
|
||||
asm volatile ("cpuid" // Besoin d'être volatile ?
|
||||
: "=a" (result[0]), "=b" (result[1]), "=c" (result[2]), "=d" (result[3]) // output
|
||||
: "a" (code), "c" (0)); // input
|
||||
#else
|
||||
NazaraInternalError("Cpuid has been called although it is not supported");
|
||||
#endif
|
||||
|
|
@ -43,37 +42,37 @@ bool NzHardwareInfoImpl::IsCpuidSupported()
|
|||
__asm
|
||||
{
|
||||
pushfd
|
||||
pop eax
|
||||
mov ecx, eax
|
||||
xor eax, 0x200000
|
||||
push eax
|
||||
pop eax
|
||||
mov ecx, eax
|
||||
xor eax, 0x200000
|
||||
push eax
|
||||
popfd
|
||||
pushfd
|
||||
pop eax
|
||||
xor eax, ecx
|
||||
mov supported, eax
|
||||
push ecx
|
||||
pop eax
|
||||
xor eax, ecx
|
||||
mov supported, eax
|
||||
push ecx
|
||||
popfd
|
||||
};
|
||||
|
||||
return supported != 0;
|
||||
#elif defined(NAZARA_COMPILER_CLANG) || defined(NAZARA_COMPILER_GCC) || defined(NAZARA_COMPILER_INTEL)
|
||||
int supported;
|
||||
asm volatile
|
||||
(" pushfl\n"
|
||||
" pop %%eax\n"
|
||||
" mov %%eax, %%ecx\n"
|
||||
" xor $0x200000, %%eax\n"
|
||||
" push %%eax\n"
|
||||
" popfl\n"
|
||||
" pushfl\n"
|
||||
" pop %%eax\n"
|
||||
" xor %%ecx, %%eax\n"
|
||||
" mov %%eax, %0\n"
|
||||
" push %%ecx\n"
|
||||
" popfl\n"
|
||||
: "=m" (supported)
|
||||
: :"eax", "ecx", "memory");
|
||||
asm volatile (" pushfl\n"
|
||||
" pop %%eax\n"
|
||||
" mov %%eax, %%ecx\n"
|
||||
" xor $0x200000, %%eax\n"
|
||||
" push %%eax\n"
|
||||
" popfl\n"
|
||||
" pushfl\n"
|
||||
" pop %%eax\n"
|
||||
" xor %%ecx, %%eax\n"
|
||||
" mov %%eax, %0\n"
|
||||
" push %%ecx\n"
|
||||
" popfl"
|
||||
: "=m" (supported) // output
|
||||
: // input
|
||||
: "eax", "ecx", "memory"); // clobbered register
|
||||
|
||||
return supported != 0;
|
||||
#else
|
||||
|
|
|
|||
Loading…
Reference in New Issue