Question

I am trying to get a good grip on the LEA instruction in x86:

leal (%edx, %edx, 4), %eax
leal (%edx, %edx, 2), %eax

Given these two lines, i know that:

eax = edx + edx*4

and then

eax = edx + edx*2

Two questions. First, if these instructions appear in sequence as in this example, the eax register is overwritten once the second line executes? And what exactly would be loaded into the register? Another address? Or is this doing arithmetic on the values that these registers point to?

Was it helpful?

Solution

if these instructions appear in sequence as in this example, the eax register is overwritten once the second line executes?

Yes (it is overwritten after both instructions)

And what exactly would be loaded into the register? Another address?

The memory address described by EDX + the offset stored as value in EDX multiplied by 2

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top