我一直使用Google搜索了很长时间,但仍然找不到解决方案。我希望有人能帮助我。inline asm在XCode for Simulator中编译但未能编译为设备
我有如下三个一字排列的ASM功能:
static __inline__ int Bsf(uint32_t Operand) {
int eax;
asm __volatile__ (
"bsfl %0, %0" "\n\t"
: "=a" (eax)
: "0" (Operand)
);
return eax;
}
static __inline__ int Bsr(uint32_t Operand) {
int eax;
asm __volatile__ (
"bsrl %0, %0" "\n\t"
: "=a" (eax)
: "0" (Operand)
);
return eax;
}
static __inline__ uint64_t TimeStampCounter(void) {
uint32_t eax, edx;
asm __volatile__ (
"rdtsc" "\n\t"
: "=a" (eax), "=d" (edx)
:
);
return MAKE_LONG_LONG(eax, edx);
}
他们都在XCode中编译成功的模拟器,但是当我切换到建立设备故障 - 4.1(iPhone版)。我得到的消息是“在asm中不可能的约束”。我相信问题是上述汇编代码不适用于基于ARM的cpu。有人可以阐明如何重新编写代码,以便编译为iPhone cpu吗?它可以是汇编或纯C代码。提前致谢!
利奥
你想做什么? – 2010-12-10 19:15:25
只是猜测,但你发布的程序集是x86和iOS设备是基于ARM的,所以你可能需要编写ARM程序集来做你想做的事情。 – 2010-12-12 09:44:10
@Dean。你是完全正确的,那实际上是我的问题。如何重新编写ARM cpu的代码?你有什么主意吗?如果您能够在使用ARM程序集或纯C代码重新编写代码的过程中对此有所了解,我们将非常感激。 – user538220 2010-12-13 15:42:07