I am trying to acces values from an array of integers and have been trying for hours with no luck. Here is my code so far:
All I am trying to do is acces the values in the array “arr”, i have seen how to do it with characters but not with integers.
int binarySearch (int* arr, int arrSize, int key, int* count)
{
int result=-1;
int tempCount=0;
__asm
{
push esi;
push edi;
push eax;
push ebx;
push ecx;
push edx;
// START CODING HERE
mov edx, dword ptr arr[1] ;
// move the value of appropriate registers into result and tempCount;
// END CODING HERE
pop edx;
pop ecx;
pop ebx;
pop eax;
pop edi;
pop esi;
}
*count = tempCount;
return result;
}
Let’s assume the index of the item you want is in eax, you would write
This is equivalent to
edx = arr[eax]
Edit:
Sorry but I forgot that this is inline asm. lea edx, [arr] will load the effective address of the parameter arr on the stack, not the pointer itself. Try this:
t == 21 after this program executes. I believe that is what you are looking for.