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

来源:互联网 发布:软件测试的目的 编辑:程序博客网 时间:2024/04/20 12:02
#include<iostream>using namespace std;int main(){unsigned int meax;unsigned int mebx;unsigned int mecx;unsigned int medx;__asm{xor eax,eaxcpuidmov meax,eaxmov mebx,ebxmov mecx,ecxmov 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 := 0xdebx := 0x756e6547ecx := 0x6c65746eedx := 0x49656e69cpu info := GenuineIntel

0 0
原创粉丝点击