直接在XCode中编译Arm Assembly [英] Compile Arm Assembly directly in XCode
问题描述
将arm汇编代码编译成xcode的最佳方法是什么。我有生成的那些汇编文件。有没有办法我可以直接将.s文件包含在我拥有的c代码中。或者我将需要首先运行一个预处理器,它将生成.o文件,我可以链接到我的文件。如果是这种情况,你如何在XCode中进行。
What is the best way to go about compiling arm assembly code into xcode. I have those assembly files which are generated. Is there a way i can just include the .s file directly into the c code that i have. Or i will need to run an preprocessor first which would generate the .o file which i can link with my files. If that is the case, how do you do it in XCode.
推荐答案
如果你可以发布确切的编译器错误xcode是随地吐痰那么我可能会想出一个更好的解决方案,但我现在的猜测是你忘记添加_前缀你是否在汇编中起作用。
If you could post the exact compiler error xcode is spitting out then I might be able to come up with a better solution but my guess as of now is that you are forgetting to add the _ prefix do you functions in assembly.
.globl _add_in_asm
_add_in_asm:
add r0,r0,#1
bx lr
现在在C源文件中
#include <stdio.h>
extern int add_in_asm(int i);
int main(int argc, char* argv[]) {
printf("result:%i\n", add_in_asm(10));
return 0;
}
该程序应打印
result:11
这篇关于直接在XCode中编译Arm Assembly的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!