xcode 5.1内联汇编
我正在努力将一段内联汇编代码放入我的xcode函数中。我需要做的是重写C++中的这段代码。谁能帮我一下吗?先谢谢你xcode 5.1内联汇编,xcode,inline-assembly,Xcode,Inline Assembly,我正在努力将一段内联汇编代码放入我的xcode函数中。我需要做的是重写C++中的这段代码。谁能帮我一下吗?先谢谢你 unsigned long myFunction(void) { static unsigned long rnd=0x4159c49; unsigned char y; __asm { rdtsc; mov [y], al; } //some other operations return (rnd); } 我试图在xcode中搜
unsigned long myFunction(void)
{
static unsigned long rnd=0x4159c49;
unsigned char y;
__asm
{
rdtsc;
mov [y], al;
}
//some other operations
return (rnd);
}
我试图在xcode中搜索内联程序集,但找不到任何相关的内容。
我尝试按以下方式使用内联程序集,但它给了我错误期望寄存器:
__asm__(
"rdtsc"
"mov [y], al"
);
此代码段获取完整的64位RDTSC值:
uint32_t eax, edx;
asm __volatile__ (
"rdtsc" "\n\t"
: "=a" (eax), "=d" (edx)
:
);
如果您只需要低8位,则可以执行以下操作:
y = (unsigned char)eax;
我的猜测是,这是某些RNG函数的一部分,您只是将此计时器值用作种子,在这种情况下,您最好使用不需要内联asm的更便携的工具。字节rnd[128];对于(int i=0;i<128;i+=4){(unsigned long)(&rnd[i])=myFunction();}这就是它的调用方式,问题是我甚至不知道这一切实际上都在做什么,这可能是主要的问题——否则我会非常高兴不使用任何内联asm。