U-boot-1.1.6-2008R1到vdsp5(bf561)的移植记录(19):分号惹祸

本文探讨了在Blackfin处理器上使用嵌入式汇编语言时遇到的问题,并详细介绍了如何通过简单地添加分号来解决VDSP编译器产生的语法错误。
 
  
在移植汇编代码时,VDSP中的分号造成了一些小困扰,但是相比之下,C中嵌入汇编引起的问题则要隐蔽得多,如cpu/blackfin/reset.c中的函数:
__attribute__ ((__l1_text__, __noreturn__))
void bfin_reset(void)
{
     while (1) {
         /* No idea why this is needed, but with out this, the ssync()
          * after SWRST = 0x0 will hang indefinitely ...
          */
         __builtin_bfin_ssync();
 
         /* Initiate system software reset of peripherals */
         bfin_write_SWRST(0x7);
         /* Due to the way reset is handled in the hardware, we need
          * to delay for 5 SCLKS. The only reliable way to do this is
          * to calculate the CCLK/SCLK ratio and multiply 5. For now,
          * we'll assume worse case which is a 1:15 ratio.
          */
         asm(
              "LSETUP (.Lreset_nops,.Lreset_nops) LC0 = %0/n"
              ".Lreset_nops: nop;"
              :
              : "a" (15 * 5)
              : "LC0", "LB0", "LT0"
         );
         /* Clear system software reset */
         bfin_write_SWRST(0);
         __builtin_bfin_ssync();
         /* Issue core reset */
         asm("raise 1");
     }
}
这里有两行的嵌入汇编,当在VDSP下编译时,它的提示信息为:
[Error ea5004] "C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/acc0a74df1e000/acc0a74df1e001.s":59 Syntax Error in :
.Lreset_nops: nop;
syntax error is at or near text '.Lreset_nops'.
Attempting error recovery by ignoring text until the ';'
 
[Error ea5004] "C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/acc0a74df1e000/acc0a74df1e001.s":79 Syntax Error in :
.LN7:
syntax error is at or near text '.LN7'.
Attempting error recovery by ignoring text until the ';'
 
 Previous errors prevent assembly
第一个错误提示还好点,第二个提示就让人不知所云了。实际上,这两个错误都是由嵌入汇编中一个小小的分号引起的,修改后的代码如下:
__attribute__ ((__l1_text__, __noreturn__))
void bfin_reset(void)
{
     while (1) {
         /* No idea why this is needed, but with out this, the ssync()
          * after SWRST = 0x0 will hang indefinitely ...
          */
         __builtin_bfin_ssync();
 
         /* Initiate system software reset of peripherals */
         bfin_write_SWRST(0x7);
         /* Due to the way reset is handled in the hardware, we need
          * to delay for 5 SCLKS. The only reliable way to do this is
          * to calculate the CCLK/SCLK ratio and multiply 5. For now,
          * we'll assume worse case which is a 1:15 ratio.
          */
         asm(
              "LSETUP (.Lreset_nops,.Lreset_nops) LC0 = %0;/n"
              ".Lreset_nops: nop;"
              :
              : "a" (15 * 5)
              : "LC0", "LB0", "LT0"
         );
         /* Clear system software reset */
         bfin_write_SWRST(0);
         __builtin_bfin_ssync();
         /* Issue core reset */
         asm("raise 1;");
     }
}
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

嵌云阁主

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

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

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

打赏作者

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

抵扣说明:

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

余额充值