So first i assign edx = y by doing movl 12(%ebp) %edx.
why does leal (%edx, %edx, 2) , %edx = edx = 3*y
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
Literally translated, it is “Load the effective address EDX + EDX * 2 into EDX”.
The 80×86 has some relatively powerful addressing modes. For example, “movl (%edx, %edx, 2), %edx” would be “load the value at the effective address EDX + EDX << 1 into EDX”. The LEA instruction allows the circuitry for this relatively powerful addressing to be recycled and used for other purposes.
Part of your confusion is likely to be caused by AT&T syntax – the way addresses are written is far from natural. For comparison; for Intel syntax it would be much clearer (e.g. “lea edx, [edx+edx*2]”).