I coded the following function into linear assembly:
double dotp(float * a, float *b,int cnt)
{ int i = 0;
double sum = 0.0;
for(i = 0; i < cnt ; i ++)
sum += a[I]*b[i];
return sum;
}
.def _dotp
_dotp: .cproc a, b ,cnt
.reg val0,val1
.reg prod1:prod0, sum1:sum0
loop:
LDW *a++, val0
LDW *b++, val1
MPYSP2DP val0, val1, prod1:prod0
ADDDP prod1:prod0, sum1:sum0, sum1:sum0
[cnt] SUB cnt,1,cnt
[cnt] B loop
.return sum1:sum0
.endproc
I used some data to test the above linear assembly code, but got wrong result. Using single step debug, I found that "LDW *a++, val0" can't get right value for val0. Does LDW can only load integrate data? What's wrong with the above linear assembly code?
Looking forward to somebody can help me!
May