While disassembling simple C code with GCC I came across:
mov (%eax), eax
My understanding of assembly is that when you have () surrounding a register, you are adding some number to the memory address, i.e., 0x4(%eax) would mean 4 bytes above the register %eax.
Here, however, there is no number before the (), so it appears to be copying the value in the register to itself.
I have noticed that the %eax register is used quite commonly to return variables and this line occurs immediately after a function call, so my guess is that this instruction is actually telling the machine to take whatever was in the %eax register for the called function (i.e., the return value) and put in the %eax register for the current function.
Is this correct? If not, what have I got wrong, and what is it actually doing?