Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LEA instruction? [duplicate]

Tags:

x86

assembly

what does

lea    (%edx,%eax,1),%eax 

do?

like image 760
Onkar Mahajan Avatar asked Dec 26 '10 16:12

Onkar Mahajan


1 Answers

It's the equivalent of "eax = edx + eax * 1".

This particular case of lea is an inefficient way to write add %edx, %eax; only useful if you need to avoid modifying flags. But unlike add, the output can be a register that isn't one of the inputs, and you can do more complex operations.

Generally, lea (address expression), register means "compute the address expression and change the register value to that"; other instructions use address expressions for memory access, i.e. mov (address expression), register means "compute the address expression and load the value from the resulting address into the register".

like image 127
zeuxcg Avatar answered Oct 04 '22 11:10

zeuxcg