歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> uclinux-2008R1-RC8(bf561)到VDSP5的移植(45):__delay

uclinux-2008R1-RC8(bf561)到VDSP5的移植(45):__delay

日期:2017/3/3 16:43:29   编辑:關於Linux

在include/asm/delay.h中有一個函數:

static inline void __delay(unsigned long loops)
{
     if (ANOMALY_05000312) {
         /* Interrupted loads to loop registers -> bad */
         unsigned long tmp;
         __asm__ __volatile__(
              "[--SP] = LC0;"
              "[--SP] = LT0;"
              "[--SP] = LB0;"
              "LSETUP (1f,1f) LC0 = %1;"
              "1: NOP;"
              /* We take advantage of the fact that LC0 is 0 at
               * the end of the loop. Otherwise we'd need some
               * NOPs after the CLI here.
               */
              "CLI %0;"
              "LB0 = [SP++];"
              "LT0 = [SP++];"
              "LC0 = [SP++];"
              "STI %0;"
              : "=d" (tmp)
              : "a" (loops)
         );
     } else
         __asm__ __volatile__ (
              "LSETUP(1f, 1f) LC0 = %0;"
              "1: NOP;"
              :
              : "a" (loops)
              : "LT0", "LB0", "LC0"
         );
}

這個函數用於做指定次數的空指令循環。但它在VDSP下編譯時有問題:

[Error ea5004] "c:/temp/acc0d389ddc000/acc0d389ddc001.s":207 Syntax Error in :
[--SP] = LC0;[--SP] = LT0;[--SP] = LB0;LSETUP (1f,1f) LC0 = P1;1: NOP;CLI R0;LB0 = [SP++];LT0 = [SP++];LC0 = [SP++];STI R0;
syntax error is at or near text 'f'.
Attempting error recovery by ignoring text until the ';'
[Error ea5007] "c:/temp/acc0d389ddc000/acc0d389ddc001.s":207 The label "1:" is illegal because it begins with a digit. If this is GNU assembly source, rewrite to a local temporary name of your choosing. If the GNU assembly code was generated from a macro, the VisualDSP++ preprocessing label auto-generation feature ("?") can be used to generate a unique local label.
[Error ea5004] "c:/temp/acc0d389ddc000/acc0d389ddc001.s":334 Syntax Error in :
[--SP] = LC0;[--SP] = LT0;[--SP] = LB0;LSETUP (1f,1f) LC0 = P1;1: NOP;CLI R0;LB0 = [SP++];LT0 = [SP++];LC0 = [SP++];STI R0;
syntax error is at or near text 'f'.
Attempting error recovery by ignoring text until the ';'
[Error ea5007] "c:/temp/acc0d389ddc000/acc0d389ddc001.s":334 The label "1:" is illegal because it begins with a digit. If this is GNU assembly source, rewrite to a local temporary name of your choosing. If the GNU assembly code was generated from a macro, the VisualDSP++ preprocessing label auto-generation feature ("?") can be used to generate a unique local label.
Previous errors prevent assembly

主要是因為VDSP中的匯編不支持1f之類的跳轉,因此這個函數應該改為:

static /*inline*/ void __delay(unsigned long loops)
{
     if (ANOMALY_05000312) {
         /* Interrupted loads to loop registers -> bad */
         unsigned long tmp;
         __asm__ __volatile__(
              "[--SP] = LC0;"
              "[--SP] = LT0;"
              "[--SP] = LB0;"
              "LSETUP (__delay_anomaly_1,__delay_anomaly_1) LC0 = %1;"
              "__delay_anomaly_1: NOP;"
              /* We take advantage of the fact that LC0 is 0 at
               * the end of the loop. Otherwise we'd need some
               * NOPs after the CLI here.
               */
              "CLI %0;"
              "LB0 = [SP++];"
              "LT0 = [SP++];"
              "LC0 = [SP++];"
              "STI %0;"
              : "=d" (tmp)
              : "a" (loops)
         );
     } else
         __asm__ __volatile__ (
              "LSETUP(__delay_1, __delay_1) LC0 = %0;"
              "__delay_1: NOP;"
              :
              : "a" (loops)
              : "LT0", "LB0", "LC0"
         );
}

之所以去掉了inline,是因為當在一個c文件中有超過一個地方調用__delay函數時,它將產生一個重復標簽的錯誤。

Copyright © Linux教程網 All Rights Reserved