Valhalla Legends Forums Archive | Assembly Language (any cpu) | lea vs mov

AuthorMessageTime
Maddox
Basically, I just want to know the difference.
February 25, 2004, 2:15 AM
K
This reference always helps me:

http://202.114.22.131/mirrors/www_litespeed_org/Tutorials/Drme2.htm

[quote]LEA means Load Effective Address.

Syntax:
LEA destination,source

Desination can be any 16 bit register and the source must be a memory operand (bit of data in memory). It puts the offset address of the source in the destination.
[/quote]

MOV is pretty self explanatory.
February 25, 2004, 2:59 AM
Maddox
[quote author=K link=board=7;threadid=5444;start=0#msg45910 date=1077677971]
This reference always helps me:

http://202.114.22.131/mirrors/www_litespeed_org/Tutorials/Drme2.htm

[quote]LEA means Load Effective Address.

Syntax:
LEA destination,source

Desination can be any 16 bit register and the source must be a memory operand (bit of data in memory). It puts the offset address of the source in the destination.
[/quote]

MOV is pretty self explanatory.
[/quote]

My question really was mean to be "how does lea relate to mov?" which was indicated by the "vs." Thanks for the reference, although I wish it was in alphabetical order.

Have you ever seen LEA AX,[SI]+7 before? I'm pretty sure this is the same thing as lea ax, [si+7].

And isn't that the same as
mov ax, si
add ax, 7

It looks like lea is just there to make the code smaller by taking out all the additional arithmetic instructions to the address that would be required with mov.
February 25, 2004, 6:09 AM
Adron
Yes, LEA is there to let you use the address calculation units to calculate something and store the result in a register. It was probably originally intended for calculating things like [BX + SI + 47], but since you can now address with any register, it has turned into a generic quick expression evaluator instruction. You can do addition of up to two registers, and a constant. You can also scale one of the registers with a small value.
February 25, 2004, 11:05 AM

Search