Re: How to comprehend this code snippet: __asm__ __volatile__("rdtsc" : "=A"(t))?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jul 16, 2020 at 8:22 AM 孙世龙 sunshilong <sunshilong369@xxxxxxxxx> wrote:
>
> Here is the code snippet:
> #define ipipe_read_tsc(t)              \
> __asm__ __volatile__("rdtsc" : "=A"(t))

I hope that is i386 only, and not x86_64.

> I found that the rdtsc (Read Time-Stamp Counter) instruction is used
> to determine how many CPU ticks took place since the processor was
> reset.
>
> But what does
> "=A"(t)
> mean?

The '=A' is a GCC machine constraint for i386 and an output operand.
The 'A' is the constraint EAX:RDX register pair. The '=' means it is
being written to.

Also see https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html
and https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html.

Also read the note in the Machine Constraints for:

    unsigned long long rdtsc (void)
    {
      unsigned long long tick;
      __asm__ __volatile__("rdtsc":"=A"(tick));
      return tick;
    }

The manual says the pattern is wrong for x86_64.

Jeff

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies




[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]

  Powered by Linux