前情回顾:
android读时间戳
<font color="red">[已解决]</font>android读时间戳
https://fishc.com.cn/thread-233062-1-1.html
(出处: 鱼C论坛)
#ifdef __linux__
// GCC
void InternalSource::entropy_read_timestamp(unsigned long long* out) {
unsigned int re[2] = { 0 };
asm("RdTSC\nmov %0, %%eax\n" : "=r" (re[0]));
asm("mov %0, %%edx\n" : "=r" (re[1]));
*out = *(unsigned long long*)re;
}
#elif defined(_M_IX86)
// VisualStudio
void InternalSource::entropy_read_timestamp(uint64_t* out) {
uint64_t re = 0;
_asm {
RdTSC
mov DWORD PTR re, eax
mov DWORD PTR[re + 4], edx
}
*out = re;
}
#endif
有大佬给出了x86下的汇编void entropy_read_timestamp(uint64_t* out) {
uint32_t re[2] = { 0 };
asm volatile("RdTSC\nmov %0, %%eax\n" : "=r" (re[0]));
asm volatile("mov %0, %%edx\n" : "=r" (re[1]));
*out = *((uint64_t*)re);
}
以及ARM下的.global _entropy_read_timestamp
.type _entropy_read_timestamp, @function
_entropy_read_timestamp:
mrs x0, cntvct_el0 // 读取计时器的值到寄存器x0
ret
无奈笔者实在是不会汇编,大佬貌似不会回复楼中楼,只能再发个悬赏,求助符合原函数格式的(补充:Android Studio项目采用的C/C++开发),能在Mac系统下AS里能运行的ARM汇编指令,拜谢
|