Re: About instruction lea



"jukka@xxxxxxxxxxxx" <spamtrap@xxxxxxxxxx> wrote in message news:1130183511.793228.306550@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Yes, because it is instruction which exposes the address generation
> logic
>
> If you do this:
>
> add eax,ebx
> vs.
> lea eax,[ebx+eax]
>
> You won't gain anything, but when you do something like this instead:
[...]

LEA also implements a three operand addition, which is useful in the
context of the otherwise two-operand x86 architecture. Instead of
coding c = a + b as

mov ecx, eax
add ecx, ebx

one can use a single LEA instruction as follows

lea ecx, [eax + ebx]

In some cases, one might even want to do c = a + b + <const>, which maps
still to a single LEA instruction

lea ecx, [eax + ebx + <const>]


-- Norbert



.



Relevant Pages