【发布时间】:2013-02-23 00:11:20
【问题描述】:
我看过关于同样错误的帖子,但我仍然收到错误:
too many memory references for `mov'
junk `hCPUIDmov buffer' after expression
...这是代码(mingw 编译器/C::B):
#include iostream
using namespace std;
union aregister
{
int theint;
unsigned bits[32];
};
union tonibbles
{
int integer;
short parts[2];
};
void GetSerial()
{
int part1,part2,part3;
aregister issupported;
int buffer;
__asm(
"mov %eax, 01h"
"CPUID"
"mov buffer, edx"
);//do the cpuid, move the edx (feature set register) to "buffer"
issupported.theint = buffer;
if(issupported.bits[18])//it is supported
{
__asm(
"mov part1, eax"
"mov %eax, 03h"
"CPUID"
);//move the first part into "part1" and call cpuid with the next subfunction to get
//the next 64 bits
__asm(
"mov part2, edx"
"mov part3, ecx"
);//now we have all the 96 bits of the serial number
tonibbles serial[3];//to split it up into two nibbles
serial[0].integer = part1;//first part
serial[1].integer = part2;//second
serial[2].integer = part3;//third
}
}
【问题讨论】:
-
您不应该使用
%进行所有注册访问吗? -
我认为您在注册名称之前忘记了一些 % 符号。
-
问题末尾的那 3 行告诉我我的帖子主要是代码是什么?
-
看来你的帖子主要是代码;请添加更多详细信息。
-
您必须在 Intel 和 AT&T asm 语法之间进行选择。