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 11:40
(1)我要计算的数据是RGB24格式,依照B1,G1,R1,B2,G2,R2..存储,这样它就是非32位对齐,用LDW就不好读进去算了吧?
(2)根据你的指导,打包指令看起来很强大,我需对照指令集文档再详细看下。
(3)还得麻烦你帮看下我在7楼所描述的双层循环问题,为什么我只能执行单层 的
求教,感谢!

一周热门 更多>