Consider I have a label in assembly (at&t syntax, x86-64) like this:
test_tabel:
mov test_label,%eax #1
mov (test_label),%eax #2
mov $test_label,%eax #3
Can someone kindly tell what's the difference between these three as I saw them a lot but can't really understand what each really means (address, value etc...)
Now in case I have a variable in .data section (let's suppose it's of size int ie 4 bytes) what's the difference between those 3:
mov var,%eax #4
mov var,%eax #5
mov $var,%eax #6
(1) and (2) are identical and load 4 bytes from memory at test_label
into eax
. (3) loads the address of test_label
into eax
.
A variable is just a label, so there's nothing special going on with your second set of examples.
(4) and (5) are identical to (1) and (2) in behaviour, (6) is identical to (3) in behaviour.