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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:13:48+00:00 2026-06-01T04:13:48+00:00

If I declare these 3 arrays int a[10][10]; int b[10][15]; int c[10][30]; For which

  • 0

If I declare these 3 arrays

int a[10][10];
int b[10][15];
int c[10][30];

For which of these three arrays, would the assembly code return the [i][j] element? Assuming that the starting address of the array is stored in %ebx.

pushl   %ebp
movl    %esp, %ebp
movl    8(%ebp), %edx          /* index i */
movl    12(%ebp), %ecx         /* index j */
movl    %edx, %eax
sall    $4, %eax
subl    %edx, %eax
addl    %ecx, %eax
movl    (%ebx,%eax,4), %eax
popl    %ebp
ret

How do you solve this type of questions

  • 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-06-01T04:13:49+00:00Added an answer on June 1, 2026 at 4:13 am

    I’d approach this by doing some hand-written math with notes, such as this:

    movl    8(%ebp), %edx          /* index i */
    -> edx = i
    movl    12(%ebp), %ecx         /* index j */
    -> ecx = j
    movl    %edx, %eax
    -> eax = i
    sall    $4, %eax
    -> eax = 16 * i
    subl    %edx, %eax
    -> eax -= i, thus:
    -> eax = 16 * i - i = 15 * i
    addl    %ecx, %eax
    -> eax += j, thus: 
    -> eax = 15 * i + j 
    movl    (%ebx,%eax,4), %eax
    -> eax = array[4 * eax], thus:
    -> eax = array[sizeof(int) * (15 * i + j)]
    

    So, in eax at the end you get what’s in the given array (pointed by ebx at the beginning) at position 15 * i + j. This can properly address:

    • An int array
    • An array that has 15 for its first (right-most) dimension

    Given that and your three arrays:

    int a[10][10];
    int b[10][15];
    int c[10][30];
    

    this addresses b properly, but not a nor c.

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

Sidebar

Related Questions

I am unsure which way to declare my arrays with fixed size of 10
I am working on editing some old C++ code that uses global arrays defined
suppose I declare a dynamic array like int *dynArray = new int [1]; which
I was writing a code which requires a large 'int' array to be allocated
I want to declare some application level variables. These variables changes with values on
This is SQL Server 2008. I have these two tables and a join: DECLARE
Is there a way to declare that the variable type of a generic class
Is there a way to declare which signals are subscribed by a Python application
Is there a way to declare an unsigned int in Java? Or the question
in C I can simply declare an array like this: int array[500]; to declare

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.