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 3271646
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:44:54+00:00 2026-05-17T18:44:54+00:00

I am trying to acces values from an array of integers and have been

  • 0

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;
}
  • 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-17T18:44:55+00:00Added an answer on May 17, 2026 at 6:44 pm

    Let’s assume the index of the item you want is in eax, you would write

    lea edx, [arr+eax*4]
    mov edx, [edx]
    

    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:

    mov eax, 1;   //index you want to access
    mov ebx, arr;
    lea edx, [ebx+eax*4];
    mov edx, [edx];
    
    
    
    int  binarySearch (int* arr)
    {
        int test;
    
        __asm
        {
            push eax;
            push ebx;
            push edx;
    
            mov eax, 2;
            mov ebx, arr;
            lea edx, [ebx+eax*4];
            mov edx, [edx];
            mov test, edx
    
            pop edx;
            pop ebx;
            pop eax;
        }
    
        return test;
    }
    
    int main(void)
    {
        int a[5];
    
        a[0] = 0;
        a[1] = 1;
        a[2] = 21;
    
        int t = binarySearch(a);
    
        return 0;
    }
    

    t == 21 after this program executes. I believe that is what you are looking for.

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

Sidebar

Related Questions

I'm trying to access the values from a CFDictionary. I've started by implementing code
I'm trying to access my array values by calling them from another script. I
I'm trying to unparse a string into an array, here is my code: EDIT:
I'm trying to access an associative array's key and value from within the same
I'm trying to autocomplete a textbox. I'm retrieving values from Access Database. Just one
I am trying to figure out how to properly parse some values returned from
From my understanding Sizzle returns an array of objects (DOMElements), I am trying to
For a 4-D array, I'm trying to average the values using compact pointer notation.
I am trying to access a String array which i have created in my
I'm fairly new to PHP and I am trying to return an array from

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.