8

what does

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

do?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Onkar Mahajan
  • 944
  • 2
  • 13
  • 16

2 Answers2

24

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".

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
zeuxcg
  • 9,216
  • 1
  • 26
  • 33
-1

Load Effective Address- it's the equivalent of the C unary & operator.

Puppy
  • 144,682
  • 38
  • 256
  • 465