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

   
快乐虾
http://blog.csdn.net/lights_joy/
lights@hb165.com
  
 
本文适用于
ADI bf561 DSP
uclinux-2008r1-rc8(移植到vdsp5)
Visual DSP++ 5.0
 
欢迎转载,但请保留作者信息
  
在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函数时,它将产生一个重复标签的错误。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

嵌云阁主

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值