我想执行asm行代码的循环。实际上我正在尝试读取我的核心的CPUID,需要读取CPUID的所有参数。如果我将0写入eax寄存器,然后我会得到制造商名称,如果我写1到eax,那么下一组CPUID信息将会收到。等等...现在,我想执行多达15组asm指令,以获得完整的CPUID输出。
例如:
unsigned int cpuid_reg[4];
__asm__ volatile("mov $1, %eax");
__asm__ volatile("cpuid" : "=a" (cpuid_reg[0]), "=b" (cpuid_reg[1]), "=c" (cpuid_reg[2]), "=d" (cpuid_reg[3]));
printf("reg[0] 0x%x , cpuid_reg[1] 0x%x, cpuid_reg[2] 0x%x, cpuid_reg[3] 0x%x\n", cpuid_reg[0], cpuid_reg[1], cpuid_reg[2], cpuid_reg[3]);
__asm__ volatile("mov $2, %eax");
__asm__ volatile("cpuid" : "=a" (cpuid_reg[0]), "=b" (cpuid_reg[1]), "=c" (cpuid_reg[2]), "=d" (cpuid_reg[3]));
printf("cpuid_reg[0] 0x%x , cpuid_reg[1] 0x%x, cpuid_reg[2] 0x%x, cpuid_reg[3] 0x%x\n", cpuid_reg[0], cpuid_reg[1], cpuid_reg[2], cpuid_reg[3]);
代替这两组代码,我需要一组,我可以写0到15到'eax'寄存器,以获得完整的CPUID数据了。谢谢帮助。
1条答案
按热度按时间vmdwslir1#
您可以读取类似this和this的内容