"rdtsc":"= a"(a0),"= d"表示(d0)这是做什么的? [英] "rdtsc": "=a" (a0), "=d" (d0) what does this do?

查看:103
本文介绍了"rdtsc":"= a"(a0),"= d"表示(d0)这是做什么的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是C ++和基准测试的新手

I'm new to C++ and benchmarking

我不明白这段代码的作用是什么?因此,我找到了一些有关edx,eax寄存器的信息,但我不完全了解它如何在代码中发挥作用.所以我理解这段代码本质上返回了cpu周期的当前滴答声.因此,它将当前滴答存储在寄存器中,一部分存储在hi中,另一部分存储在lo中.并且,"= a"和"= d"是否指定了将其存储在哪个寄存器中.

I don't understand what the this part of the code does? So I found something about the edx, eax registers, but I don't fully understand how that plays into the code. So I understand this code essentially returns the current tick of the cpu cycle. So, does it store the current tick into the registers, one part in the hi and the other part in the lo. And, does the "=a", and "=d" specify which register to store it in.

将其分为两部分的意义何在?

And what is the significance of breaking it into two parts.

"rdtsc" : "=a" (lo), "=d" (hi) 

上下文中的代码:

int64_t rdtsc(){
    unsigned int lo,hi;
    __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi));
    return ((uint64_t)hi << 32) | lo;
}

推荐答案

它使用内联汇编以调用 rdtsc 操作码,该操作码将返回64位整数.高位存储到 hi ,低位存储到 lo .

It uses inline assembly to call the rdtsc opcode which returns an 64 bit integer. The high part is stored to hi and the low to lo.

在Windows和Visual Studio中,内联汇编在x64中不可用,您可以使用

In Windows and Visual Studio where inline assembly is not available in x64, you would use the __rdtsc.

这篇关于"rdtsc":"= a"(a0),"= d"表示(d0)这是做什么的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆