使用gcc内联asm
我有这部分代码是用ARMASM编译的:使用gcc内联asm,gcc,assembly,arm,Gcc,Assembly,Arm,我有这部分代码是用ARMASM编译的: /* Software Interrupt */ /* we must save lr in case it is called from SVC mode */ #define ngARMSwi( code) __asm { SWI code,{},{},{lr} } 使用示例: ngARMSwi(0x23) 我尝试使用gcc(代码源代码gcc-4.6.2 eabi)将其转换为编译。我找到了这个链接,但是我找不到正确编译这一行的方法 我最好的尝试是
/* Software Interrupt */
/* we must save lr in case it is called from SVC mode */
#define ngARMSwi( code) __asm { SWI code,{},{},{lr} }
使用示例:
ngARMSwi(0x23)
我尝试使用gcc(代码源代码gcc-4.6.2 eabi)将其转换为编译。我找到了这个链接,但是我找不到正确编译这一行的方法
我最好的尝试是
#define ngARMSwi( code) __asm__ ("SWI " (code) : : :"lr" )
但我得到了编译错误:
error: expected ':' or ')' before '(' token
感谢您的帮助 你可能想要
#define ngARMSwi(code) __asm__("SWI %0" : : "I"(code) : "lr")
请注意,
code
是指令的一个输入,因此它将在第三节中介绍。它在指令中的位置由字符串中的%0
标记。I
是对code
的约束,表示它必须是8位常量。非常感谢!这段代码编译。。。我只是要确保现在它做的事情和以前一样!