Hi, I have a few questions I would like to clear out.
#1:
What is the diffrence between


1. MOV EAX,OFFSET VARNAME
and
2. LEA EAX,OFFSET VARNAME


I will ask questions as they come to me, of if this thread goes far down I'll recreate a new one.
Posted on 2002-09-26 17:18:04 by x86asm
different opcode, same result :)
Posted on 2002-09-26 18:26:33 by Tola
mov eax,offset varname : only works if varname can be resolved during assembly (variables defined in the .data(?) sections, and therefore cannot be used with stack variables(local).

lea:load effective adress is quite a versatile opcode

lea eax,varname :is resolved at runtime so it can be used with both global(.data(?) and stack based variables

lea can just as easily resolve calculations of the form.
lea eax, ebx+ecx*n+C ;where n can be 1,2,4,8 and C is a constant

the mov instruction has an equivalent complex addressing syntax but instead of loading the results of the calculation it loads the contents of the address resolved by the calculation

e.g.

ebx=1,ecx=2,n=4,c=5
ram address 14=20

lea eax,ebx+ecx*4+5 ;puts 14 into eax
while
mov eax,ebx+ecx*4+5 ;puts the contents of address 14 into eax=20

hope i didn't confuse you!
Posted on 2002-09-26 18:33:34 by MArtial_Code
So the "MOV" instruction moves the value at the specified address and "LEA" loads the computed address of the variable?
Posted on 2002-09-26 19:10:41 by x86asm
You got it, just like the name suggests, Load Effective Address :)
Posted on 2002-09-26 19:59:59 by S/390
Thanks guys :D
Posted on 2002-09-26 20:29:01 by x86asm