DSP汇编中的循环问题

2019-03-26 16:36发布

  我的板子是c6740,编写测试程序想把两个数组对应的数相乘存到第三个数组中,主文件是:
#include <stdio.h> int MPY_1(int *m, int *n, int *result, int count); void main()
{
 int n[10] = {1,2,3,4,5,6,7,8,9,10};
 int m[10] = {11,12,13,14,15,16,17,18,19,20};
 int tmp,i;
 int *result;
 result = (int *)malloc(10*sizeof(int));
 tmp = MPY_1(m,n,result,10);
 for(i=0;i<10;i++)
  printf("m=%d,n=%d,result=%d,d=%d ",m,n,result,tmp); }
/**************调用汇编函数文件****************/
 .text
 .global _MPY_1
_MPY_1:     .asg A4, p_m
  .asg B4, p_n
  .asg A6, p_result
  .asg B6, B_count
  .asg A1, A_m
  .asg B1, B_n
  .asg A3, A_loopcount
  .asg A7, A_s
* ================= LOOP PROLOG ============================ *
   MV .S1 B6, A_loopcount    || MV .L1 A4,B4   || MV .L2 A5,B5
 SUB .S1 A_loopcount, 1,A_loopcount
* ===================== LOOP KERNEL ============================== *
loop:
    LDW .D1 *A5++[1], A_m ;A_m = *m
  ||  LDW .D2 *B5++[1], B_n ;A_n = *n
   MPY .M1 A_m,B_n,A_s ; A_S = m * n 
    NOP 1
 STW .D1 A_s,*A6++[1]  ; result = A_S
  
 ||[A_loopcount] B .S2 loop    ; branch ,Illegal register for conditional
    ||[A_loopcount]SUB .S1 A_loopcount, 1,A_loopcount
 
* ===================== LOOP EPILOG ============================== *
 B .S2 B3   ;return
 MVK .S1 1,A4 ;return 1
 nop 1
 .end   这程序编译没通过,在||[A_loopcount] B .S2 loop   这条语句下报错Illegal register for conditional。
第一次写汇编循环,请大侠帮看下这个程序哪些地方出错了?需要怎么改才能实现所想要的功能,谢谢! [ 本帖最后由 breeze505 于 2012-4-27 14:35 编辑 ] 此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
18条回答
breeze505
2019-03-27 16:44

(1)那这样的话,需要在主函数进入汇编前把数据流处理成0RGB0RGB格式的,这样需要遍历64*64,还要写操作,这些耗费的时间应该也不会少,所以我觉得这样的话,总体的效率应该不会比直接单字节高吧?我写了单字节处理的RGB-YCbCr位移的汇编程序,发现瓶颈都集中在.S单元,因为位移运算只有用到.S单元,所以一次只能并行2条指令。所以,我想是否有可以采取某种数据打包方式+提高并行处理度,来提高总体的程序性能?

(2)嗯,我想错了,但是那应该怎么去跳转才能实现双循环功能呢

[ 本帖最后由 breeze505 于 2012-5-2 09:07 编辑 ]

一周热门 更多>