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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:49:22+00:00 2026-06-14T07:49:22+00:00

I’m running through some assembly code and I can’t figure out what a line

  • 0

I’m running through some assembly code and I can’t figure out what a line of code does. The code is:

 leaq   0(,%rax,4), %rdx

I know lea is basically a type of mov instruction, but it only moves the address. So we are moving the address of something to %rdx (making %rdx “point” to something on the stack). I know what %rax points to on the stack (say, -28(%rbp)), but I’m confused by how to multiply that with 4 to get my answer. Would %rdx point to 4*(-28) = -112(%rbp)?

Thanks!

EDIT:
For context, the following code precedes this instruction:

pushq   %rbp 
movq    %rsp, %rbp 
movl    %esi, -28(%rbp)
movl    -28(%rbp), %eax 
cltq 
leaq    0(,%rax,4), %rdx
  • 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-14T07:49:23+00:00Added an answer on June 14, 2026 at 7:49 am

    Your equivalent C code is something like:

    extern int32 arr[];
    int my_func(int32 n, ...) {
       int32 a=n;
       ...
       arr[a];
       ...
    }
    

    n is passed as a single 32-bit register esi, which is stored to local stack frame.
    The parameter is then used in evaluation the 64-bit expression 4*a. The ‘0’ can be explained if it’s supposed to be relocated by the linker to the address ‘arr’.

    Then my guess is that the assembly code is not generated by
    gcc -S foo.c, but by gcc -c foo.c; objdump -d foo.o

       // Similar code from a 32-bit machine
       0:   55                      push   %ebp
       1:   89 e5                   mov    %esp,%ebp
       3:   8b 45 08                mov    0x8(%ebp),%eax
       6:   8b 04 85 00 00 00 00    mov    0x0(,%eax,4),%eax
       d:   5d                      pop    %ebp
       e:   c3                      ret
       f:   90                      nop
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know how can I replace this 2 symbol below from the string
I know there's a lot of other questions out there that deal with this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a French site that I want to parse, but am running into
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.