Answer the question
In order to leave comments, you need to log in
How to translate inline assembler to file?
Hello, I found such a function
void mycpuid(int CPUInfo[4], int InfoType)
{
__asm
{
mov esi, CPUInfo
mov eax, InfoType
xor ecx, ecx
cpuid
mov dword ptr[esi + 0], eax
mov dword ptr[esi + 4], ebx
mov dword ptr[esi + 8], ecx
mov dword ptr[esi + 12], edx
}
}
#include <iostream>
extern "C"
{
void getCpuID(int CPUInfo[4], int InfoType);
}
int main()
{
int CPUInfo[4];
int InfoType = 0;
getCpuID(CPUInfo, InfoType);
std::cout << CPUInfo[0] << "\n";
std::cout << CPUInfo[1] << "\n";
std::cout << CPUInfo[2] << "\n";
std::cout << CPUInfo[3] << "\n";
}
.386
.model tiny, C
.code
getCpuID PROC PUBLIC
push ebp
mov ebp, esp
mov esi, CPUInfo
mov eax, InfoType
xor ecx, ecx
cpuid
mov dword ptr[esi + 0], eax
mov dword ptr[esi + 4], ebx
mov dword ptr[esi + 8], ecx
mov dword ptr[esi + 12], edx
pop ebp
ret
getCpuID ENDP
end
mov esi, CPUInfo
mov eax, InfoType
undefined
Answer the question
In order to leave comments, you need to log in
the compiler complains that
mov esi, CPUInfo
mov eax, InfoType is
undefined
getCpuID PROC PUBLIC, CPUInfo, InfoType
. Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question