Given the following code:
L1 db \"word\", 0
mov al, [L1]
mov eax, L1
What do the brackets ([L1]) represent?
Operands of this type, such as [ebp]
, are called memory operands.
All the answers here are good, but I see that none tells about the caveat in following this as a rigid rule - if brackets, then dereference, except when it's the lea
instruction.
lea
is an exception to the above rule. Say we've
mov eax, [ebp - 4]
The value of ebp
is subtracted by 4 and the brackets indicate that the resulting value is taken as an address and the value residing at that address is stored in eax
. However, in lea
's case, the brackets wouldn't mean that:
lea eax, [ebp - 4]
The value of ebp
is subtracted by 4 and the resulting value is stored in eax
. This instruction would just calculate the address and store the calculated value in the destination register. See What is the difference between MOV and LEA? for further details.