I read of the following in the description of LEA:

"- the MOV instruction can often save clock cycles when used in place of LEA on 8088 processors"

So mov is faster than lea?

mov eax, offset dwAAA

should replace

lea eax, dwAAA

In Iczelion's tutorial it says when using INVOKE with local vars as parameter, the assembler will generate

lea eax,[ebp + x]
push eax

But why not

push [ebp + x]
Posted on 2002-05-11 22:16:49 by C.Z.
Come on bomb01. You just asked two questions in 15 minutes. Sorry be telling you this, but do you think you can learn assembly in a day? If you like it, practise, google around, use the search option of the forum, and use your brain a little bit. Isn't that easier than posting each question that comes to your head? ;)
Posted on 2002-05-11 23:01:45 by CodeLover
When i comes to the basics of *learning* assembly with windows 32. I would say niether is any better *practically*.

Im sure someone will attest that one is better for various reasons, and uses. But for the sake of handling and sending windows messages, i would not worry about one way or the other.

Myself, i lean on the lea side. However, offset is better when your getting the address of somthing "Static" in memory, ie. It was there when you assemble your source. However, i find i rarely write with mov-offset in mind, usually only when filling structures.

Guess im more dynamic that way ;)

Posted on 2002-05-12 01:59:06 by NaN
LEA is used in things like variables that are created on the stack as these variables do not have a static offset.

They are different instructions that do different things, even though they overlap in function at times.

MOV is a useful instruction that also pairs well most of the time but LEA allows you to do some reasonably complex addressing in a single instruction so it is very useful when working with indexes in memory.


Posted on 2002-05-12 02:19:58 by hutch--
NaN and hutch, thanks for clearing this up for me.
Posted on 2002-05-12 03:48:25 by C.Z.
Hi bomb01, specifically answering your Q1:
The answer is "Yes" IF you still bother about 8088's, otherwise use whatever is shorter (which will be LEA or MOV depending if you write 16bit or 32bit code).
Posted on 2002-05-12 04:53:08 by Maverick
Maverick, a lot of thanks!! Pity that I didn't notice "8088"..:grin:
Posted on 2002-05-12 06:59:27 by C.Z.
You're wellcome.
Posted on 2002-05-12 07:51:55 by Maverick
I use mov to keep it simple. *FACT* Sometimes mov will not work and when that happen that is to perfect time to use lea than figure out the difference for each situation when this happens...
Posted on 2002-05-12 11:06:31 by cmax
mov won't work if u did
mov eax, offset var
and var is a LOCAL this is the time to use lea.
Posted on 2002-05-12 11:29:02 by Kudos