In assembly, the square brackets []
seem to have the same meaning as *
in C programming language. They are used to dereference a pointer.
Dereferencing a pointer means going to refer to a specific memory location to read or write it.
So, it is quite logical to use square brackets in the case of a MOV
.
But what is the logical reason why they also use it for LEA?
LEA EAX, [EBP -4]
, looks like dereferencing a pointer, EBP - 4
, to refer to the pointed memory location but it will not read the value contained in the location but rather the address.
I'm a little confused about this. Could you give me the right way to think about this?
Does LEA
have any connection with the concept of dereferencing?
Clearly not intended as a memory reading, but mostly as referring to a location of memory not for its value, but for its address.
I wouldn't want this to become a philosophical question.