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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:11:42+00:00 2026-06-13T12:11:42+00:00

Hello I need some help understanding what is going on in this assembly code:

  • 0

Hello I need some help understanding what is going on in this assembly code:

        .file   "mystery.c"

        .text

        .globl mystery

              .type mystery, @function

 mystery:
   pushq    %rbp
    movq    %rsp, %rbp

   movl %edi, -20(%rbp)
   movl $1, -16(%rbp)
   movl $0, -12(%rbp)
   movl $0, -8(%rbp)
   cmpl $2, -20(%rbp)
   jg   .L2
   movl $1, %eax
   jmp  .L3

  .L2:
movl    $2, -4(%rbp)
jmp .L4

  .L5:
movl    -12(%rbp), %eax
movl    -16(%rbp), %edx
leal    (%rdx,%rax), %eax
movl    %eax, -8(%rbp)
movl    -16(%rbp), %eax
movl    %eax, -12(%rbp)
movl    -8(%rbp), %eax
movl    %eax, -16(%rbp)
addl    $1, -4(%rbp)

.L4:
movl    -4(%rbp), %eax
cmpl    -20(%rbp), %eax
jle .L5
movl    -8(%rbp), %eax

.L3:
leave
ret

I understand exactly what is going on UNTIL I get to .L5, Here the command leal(%rdx, %rax), eax is what is confusing me. Up until now ive been moving values to eax and edx and now im adding the values in rdx and rax. Where is rdx and rax coming from and what values are they holding? Are they just another way of writing eax and edx? Thanks for any help.

  • 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-13T12:11:43+00:00Added an answer on June 13, 2026 at 12:11 pm

    See this related answer. It explains the different registers and their evolution. In this case, the %rax register is a 64 bit register. %eax is the 32 bit one, and %ax would be 16 bits. %ah refers to the high 8 bits of the 16 bits in the register, and %al refers to the lower end.

    This little diagram was taken from another answer to the same question, but it shows it well…

    |63..32|31..16|15-8|7-0|
                   |AH.|AL.|
                   |AX.....|
           |EAX............|
    |RAX...................|
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some what complex UI requirement, need help in understanding type of control/style/template
Hello I would need some help with the following code and memory leak. Error
I'm at a loss, I need some help. The string looks like: Hello World
Hello I need some help to set up the LDAP user store for WSO2
Hello everyone i need some help. I'm trying to make an application for mac
Hello I need some help with a bug in Internet Explorer 9. I am
Hello I need some help getting my mysql correct. I need to select one
Hello i have here a big file and i need to replace some values
I need some help here. I have a mysql table called dictionary like this:
I need some help with parsing a line of text. The line of text

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.