于 2010年02月17日 22:28, Tim Prince 写道:
On 2/17/2010 6:21 AM, Zuxy Meng wrote:
Hi,
According to "info gcc", the 'A' constraint denotes the `a' and `d'
registers, as a pair (for instructions that return half the result in
one and half in the other). However, in reality 'A' is treated simply as
a 64-bit long integer in %rax under x86-64. For example, the following
code piece:
#include<stdint.h>
uint64_t rdtsc(void)
{
uint64_t ret;
asm ("rdtsc":"=A"(ret));
return ret;
}
produces:
[zuxy@Rainbow31 bin]$ objdump -d a.o
a.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000<rdtsc>:
0: 0f 31 rdtsc
2: c3 retq
I'm using GCC 4.4.3 but I doubt the problem has been there since Day One.
--
Zuxy
The problem of incompatibility of gcc inline asm for rdtsc between 32-
and 64-bit mode "has been there since Day One". For 64-bit mode, you are
stuck with concatenating the 2 registers explicitly.
Tim Prince
Thanks Tim. So I guess the documentation needs fixing?
--
Zuxy