是怎么做的?我需要采取哪些步骤以及需要考虑哪些陷阱和问题?
How is it done? What steps do I need to take and what pitfalls and gotchas are there to consider?
推荐答案感谢 Apple Devforums,如果您是专门的 iPhone 开发者,则应该注册.
I've gotten this to work, thanks to some inside help over at the Apple Devforums, you should sign up if you're a dedicated IPhone developer.
首先,它是 __asm__(),而不是普通的 asm().
First thing's first, it's __asm__(), not plain asm().
其次,默认情况下,XCode 会生成一个编译目标,该目标会针对 ARM Thumb 指令集编译内联汇编,因此 usat 未被识别为正确的指令.要解决此问题,请在目标上执行获取信息".向下滚动到GCC 4.0 - 代码生成"部分并取消选中为 Thumb 编译".然后,如果您将 Active SDK 设置为设备"
Secondly, by default, XCode generates a compilation target that compiles inline assembly against the ARM Thumb instruction set, so usat wasn't recognized as a proper instruction. To fix this, do "Get Info" on the Target. Scroll down to the section "GCC 4.0 - Code Generation" and uncheck "Compile for Thumb". Then this following snippet will compile just fine if you set the Active SDK to "Device"
inline int asm_saturate_to_255 (int a) { int y; __asm__("usat %0, #8, %1 " : "=r"(y) : "r"(a)); return y; }当然,现在它不适用于 iPhone 模拟器.但是 TargetConditionals.h 已经定义了你可以 #ifdef 反对.即 TARGET_OS_IPHONE 和 TARGET_IPHONE_SIMULATOR.
Naturally, now it won't work with the IPhone Simulator. But TargetConditionals.h has defines you can #ifdef against. Namely TARGET_OS_IPHONE and TARGET_IPHONE_SIMULATOR.
更多推荐
如何在 iPhone 上进行内联汇编?
发布评论