快乐虾
http://blog.csdn.net/lights_joy/
本文适用于
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函数时,它将产生一个重复标签的错误。