Assume the following function:
void asmFunction(const int *first, ...) {
__asm {
xor eax, eax
add eax, [first][0]
; ...
}
}
It is being called this way:
int first[] = { 0, 0, 0, 0, 0, 0, 0, 5, 7, 6, 2, 4, 3, 5 };
asmFunction2(first, ...);
As far as I understand, the second assembly line must add 0 element of array first to eax. However, a random value is being added. When debugging, first[0] equals 0, as it must be. What is the problem with the code?
I code in Visual Studio 2013 on 64-bit machine.
add eax, [first + 0]? With[]you dereference thefirstpointer/address. And for element 1:add eax, [first + 4], etc.[first][0]means the same as[first + 0], but I’m not sure.