noob
noob

Reputation: 51

(Assembly 32 bit) can't use lea without the brackets?

I haven't seen anyone touch on this as far as i can tell, so i'm using a flat assembler and if i try to do something like this "lea eax,testing" it won't work but if i do this "lea eax,[testing]" it works? Lots of examples i come across i see people being able to do it without the brackets but i don't know if that's possible to do on a flat assembler since i keep getting the error invalid operands, also "testing" is a dd (double word).

Last thing lea eax,[testing] and mov eax,testing is equivalent on my flat assembler. I tested the eax register with ollydbg debugger, in both cases eax equals address 00401006. So in this case they are equivalent correct?

Upvotes: 3

Views: 1819

Answers (1)

FlatAssembler
FlatAssembler

Reputation: 782

Because LEA is like the "&" in C, it expects that you pass a variable to it, not an address to that variable. In FASM, when you write "[a]", you are reffering to the variable 'a', and when you write just "a", you are reffering to its address. So, "lea eax,[a]" and "mov eax,a" mean exactly the same. I hope this helps.

Upvotes: 1

Related Questions