I'm a little confused about how variables are implemented in Assembly. I know that the following declaration creates a named memory location in a dataprogram section :
.section .data
var:
.long 23
Then you can access the variable, for example:
movl var, %eax
What I do not understand is how these instructions are actually implemented. I had the impression that a memory reference, even an absolute memory reference, had to be loaded into the register before it could be used.
Does the assembler need to convert the above statement into several instructions, for example:
leal var, %ebx
movl (%ebx), %eax
Or the assembler tracks the address varand gains access to that location as if it were absolute instant access, for example:
movl ($addr_of_var), %eax