代码之家  ›  专栏  ›  技术社区  ›  GabrielT

Eroror编译内置asm

  •  0
  • GabrielT  · 技术社区  · 3 年前

    我最近从Keil Uvision切换到我自己的Makefile 我在编译文件port.c时遇到问题, 文件中的函数:

    __asm void vPortSVCHandler( void )
    {
        PRESERVE8
    
        /* Get the location of the current TCB. */
        ldr r3, =pxCurrentTCB
        ldr r1, [r3]
        ldr r0, [r1]
        /* Pop the core registers. */
        ldmia r0!, {r4-r11, r14}
        msr psp, r0
        isb
        mov r0, #0
        msr basepri, r0
        bx r14
    }
    

    编译时会出现以下错误:

    ../port.c:52:7: error: expected '(' before 'void'
       52 | __asm void vPortSVCHandler( void )
          |       ^~~~
          |       (
    ../port.c:64:13: error: stray '#' in program
       64 |     mov r0, #0
    

    我是否缺少include或编译器选项?

    1 回复  |  直到 3 年前
        1
  •  1
  •   0___________    3 年前

    你用 gcc gcc没有“asm”功能。

    您需要在汇编程序中编写它或编写内联程序集。 __asm 也是无效的 海湾合作委员会

    https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html