I am trying to find the index of a string in an array of Strings. I know the base address of the Array, now what I want to do is something like shown below:
- Point ESI to the entry in array
- Point EDI to the string we are searching for in the array
- cmps byte ptr ds:[esi], byte ptr es:[edi] to compare one byte at a time of esi and edi.
However, I am confused about how to point EDI register to the string I am searching for?
int main(int argc, char *argv[])
{
char entry[]="apple";
__asm
{
mov esi, entry
mov edi, [ebx] //ebx has base address of the array
and so on.
So, what would be the right way to point my esi register to the string that I am searching for?
I am programming in Visual Studio C++ Express Edition 2010 on Win XP SP3.
The Visual C++ compiler allows you to use variables directly in assembly code. Example from here: https://learn.microsoft.com/en-us/cpp/assembler/inline/calling-c-functions-in-inline-assembly
It doesn’t get any easier than this, IMO. You get all the speed, without all the hassle of trying to find out where variables are stored.