Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7405993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:29:17+00:00 2026-05-29T05:29:17+00:00

I am trying to find the index of a string in an array of

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:29:18+00:00Added an answer on May 29, 2026 at 5:29 am

    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

    // InlineAssembler_Calling_C_Functions_in_Inline_Assembly.cpp
    // processor: x86
    #include <stdio.h>
    
    char format[] = "%s %s\n";
    char hello[] = "Hello";
    char world[] = "world";
    int main( void )
    {
       __asm
       {
          mov  eax, offset world
          push eax
          mov  eax, offset hello
          push eax
          mov  eax, offset format
          push eax
          call printf
          //clean up the stack so that main can exit cleanly
          //use the unused register ebx to do the cleanup
          pop  ebx
          pop  ebx
          pop  ebx
       }
    }
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to find what array index position contains part of a string.
I'm trying to find out a way to know the index of a anchor
I am trying to find a clean way of referencing an array's index using
Trying to find a clean way to find the index of an array item
I want to find the first index of substrings in a larger string. I
I'm trying to find the index of a row in a table. I'm trying
I'm trying to find out the index number of the last list item but
searching around trying to find a way to add index on suffix of a
I'm using Lucene, and I'm trying to find a way to index and retrieve
I am trying to find the shortest and longest word in a given string.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.