I'm trying to understand some assembly code
with AT&T syntax
.
Here is a snippet:
"mov %eax, %ebx; "\
"mov %eax, %ecx;"\
"fxch %st(1);"\
This is what I understood from it.
the mov
copies (Am I correct?, or does it move?) the data from the source register
to the destination register
In line one:
we copy the data from registry eax
to ebx
.
Similarly, we copy the data from registry eax
to ecx
.
However, what I failed to understand is the following.
How does fxch
work? Here is a link that gives an example.
fxch st(2)
fsqrt
fxch st(2)
It says that this above code takes the sqrt
of st(2)
.
Correct me if I am wrong.
It swaps the top of the stack
with st(2)
and then takes the sqrt of what?
I don't understand that clearly.
Can you please help me out? How does that work in my case and in the above case?