汇编(指令cpuid)获取cpu信息

#include
using namespace std;
int main(){

	unsigned int meax;
	unsigned int mebx;
	unsigned int mecx;
	unsigned int medx;
	__asm{
		xor eax,eax
		cpuid
		mov meax,eax
		mov mebx,ebx
		mov mecx,ecx
		mov medx,edx
	}
	cout << "eax := 0x" << hex << meax << endl;
	
	cout << "ebx := 0x" << hex << mebx << endl;
	cout << "ecx := 0x" << hex << mecx << endl;
	cout << "edx := 0x" << hex << medx << endl;
	
	char cpuid[13]  = {0};
	memcpy(cpuid,&mebx,4);
	memcpy(cpuid+4,&medx,4);
	memcpy(cpuid+8,&mecx,4);
	cout << "cpu info := " << cpuid << endl;
	
	
	
	
	return 0;
}

eax := 0xd
ebx := 0x756e6547
ecx := 0x6c65746e
edx := 0x49656e69
cpu info := GenuineIntel

你可能感兴趣的:(C/C++,Windows,Assembler)