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