I can understand that an LEA instruction passes an address to a destination, but I can't understand how an LEA instruction performs the arithmetic operation.
I'm using ATT language (I guess).
say an arithmetic operation:
x = 3 * y + 5;
can be done:
leal 5(%esi, %esi, 2), %eax
What is the procedure of this LEA operation?
In my understanding, it takes the value stored on %esi and add and mult them, and store the result on a new address in memory, and finally pass this address to %eax. If this is correct, there's a seemingly unnecessary step of storing the value on a new address (why don't just store the value on %eax?)
If my understanding is incorrect, please investigate what the LEA actually do in order to pass an address to %eax
Thanks.