This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

c程序中包含汇编程序的问题



工程是用c语言写的,但其中包含了用汇编写成的一些函数。

c函数可以指定确定的flash存储位置,使用#pragma location = “xxxx”来实现。

现在我想把汇编函数也指定flash位置,请问如何实现?

具体的例子:汇编写成的看门狗中断函数。如下

WDT_ISR                                 ; wd timer ISR
    PUSHM.A     #12, R15

    BIC.W       #0x01, SFRIE1           ; disable wd timer interrupt

    CMP.B       #0, &OSIntNesting       ; if (OSIntNesting == 0)
    JNE         WDT_ISR_1

    MOVX.A      &OSTCBCur, R13          ;     save task stack
    MOVX.A      SP, 0(R13)

    MOVX.A      &OSISRStkPtr, SP        ;     load interrupt stack

WDT_ISR_1
    INC.B       &OSIntNesting           ; increase OSIntNesting
   
    BIS.W       #0x01, SFRIE1           ; enable wd timer interrupt

    EINT                                ; enable general interrupt to allow for interrupt nesting

    CALLA       #OSTimeTick             ; call ticks routine

    DINT                                ; IMPORTANT: disable general interrupt BEFORE calling OSIntExit()

    CALLA       #OSIntExit

    CMP.B       #0, &OSIntNesting       ; if (OSIntNesting == 0)
    JNE         WDT_ISR_2

    MOVX.A      &OSTCBHighRdy, R13      ;     restore task stack SP
    MOVX.A      @R13, SP

WDT_ISR_2
    POPM.A      #12, R15

    RETI                                ; return from interrupt