System: LEA vs. MOV

The difference between mov and lea is mov does dereference while lea does not.

movq (%rax, %rbx, 2), %rsi 
C:  rsi = *(2 * rbx + rax)

leaq (%rax, %rbx, 2), %rsi
C: rsi = (2 * rbx + rax) => does not dereference 

Use mov when you need to access the value in the computed address

Use lea when you don't need the value, you only need the address

 

posted @ 2020-12-13 11:31  Jasper2003  阅读(126)  评论(0编辑  收藏  举报