• Welcome to Valhalla Legends Archive.
 

lea vs mov

Started by Maddox, February 24, 2004, 08:15 PM

Previous topic - Next topic

Maddox

Basically, I just want to know the difference.
asdf.

K

This reference always helps me:

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

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

MOV is pretty self explanatory.

Maddox

#2
Quote from: K on February 24, 2004, 08:59 PM
This reference always helps me:

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

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

MOV is pretty self explanatory.

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

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.