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.

c64x+的C代码改写为汇编代码的参数传递问题

Other Parts Discussed in Thread: DM3730

最近写了一个图像模板匹配的代码速度过慢,准备将C代码改写为汇编,最后使用软件流水,以提升速度。但是不知道C中的参数变量怎样对应汇编代码中的寄存器。

我使用的是DM3730(其DSP核为C64x+),C64x+有两组共64个寄存器。

以下为C代码文件 sum.c .

int dotp(short a[], short b[] )
{
    int sum, i;
    sum = 0;
    for(i=0; i<100; i++){
        sum += a[i] * b[i];
    }
    return(sum);
}

将其改写为汇编文件 sum.asm,代码如下.

1
2
3
4
5
6
7
8
9
10
11
12
      MVK  .S1 100, A1 ; set up loop counter
   || ZERO .L1 A7 ; zero out accumulator
LOOP:
      LDH   .D1 *A4++,A2 ; load ai from memory
   || LDH   .D2 *B4++,B2 ; load bi from memory
      SUB  .S1 A1,1,A1 ; decrement loop counter
 [A1] B    .S2 LOOP ; branch to loop
      NOP        2 ; delay slots for LDH
      MPY  .M1X A2,B2,A6 ; ai * bi
      NOP           ; delay slots for MPY
      ADD .L1 A6,A7,A7 ; sum += (ai * bi)
      ; Branch occurs here

问题是 :

         有没有什么规则知道,C代码中的数组变量a和b,要映射到汇编中A4和B4寄存器,而不是C64x+中的其他的62个寄存器。如果有,请问在什么文档中可以查阅相关文档。