【发布时间】:2014-12-03 11:25:55
【问题描述】:
假设如下函数:
void asmFunction(const int *first, ...) {
__asm {
xor eax, eax
add eax, [first][0]
; ...
}
}
这样称呼它:
int first[] = { 0, 0, 0, 0, 0, 0, 0, 5, 7, 6, 2, 4, 3, 5 };
asmFunction2(first, ...);
据我了解,第二条流水线必须将数组first的0元素添加到eax。但是,正在添加一个随机值。调试时,first[0] 必须等于 0。代码有什么问题?
我在 64 位机器上使用 Visual Studio 2013 编写代码。
【问题讨论】:
-
我不是专家,但不应该是
add eax, [first + 0]吗?使用[],您可以取消引用first指针/地址。对于元素 1:add eax, [first + 4]等 -
@meaning-matters 据我所知,
[first][0]的含义与[first + 0]相同,但我不确定。
标签: c visual-c++ assembly x86 inline-assembly