AnsweredAssumed Answered

Fast 2d correlation

Question asked by Vatu on Aug 15, 2012
Latest reply on Sep 6, 2012 by Vatu

Hi,

I need fast 2d correlation for computer vision project.

I develop simple assembler rutine for calculating correlation coeficient.

In simulator works fine, but on real HW raises exception (Int3).

I dont understand where is problem.

 

//******************************************
//2d fast corelation
//Parameters:
//  Src1 (r0) - unsigned char 1. buffer
//  Src2 (r1) - unsigned char 2. buffer
//  SrcRowAdd1 (r2) - columns in Src1 - Cols*8
//  SrcRowAdd2 (+20) - columns in Src2 - Cols*8
//      Cols (+24) - width
//      Rows (+28) - height
//******************************************
.global _Corel


_Corel:
link 0;
[--sp]=(r7:3);
[--sp]=p1;
[--sp]=p0;
[--sp]=I2;
[--sp]=I1;
[--sp]=I0;
[--sp]=M2;
[--sp]=M1;
[--sp]=M0;

    I1 = R0;                // Src1
    I2 = R1;                // Src2
    I0 = R1;
    R0 = R1-R0;
    M0 = R0;
    R0 = 8;
    R2 = R2-R0;
M1 = R2;    // SrcRowAdd1-8
R2 = [fp+20];   // SrcRowAdd2
    R2 = R2-R0;
M2 = R2;    // SrcRowAdd2-8
p1=[fp+24]; // Cols
p0=[fp+28]; // Rows

A1 = A0 = 0;

lsetup(_Corel2.Start, _Corel2.End) LC1=p0;
_Corel2.Start:
lsetup(_Corel1.Start, _Corel1.End) LC0=p1;
    DISALGNEXCPT || R0 = [I1++] || R2 = [I2++];
    DISALGNEXCPT || R1 = [I1++] || R3 = [I2++];
//    I0=I2;
_Corel1.Start:
(r7, r6)=byteunpack r3:2 || R2 = [I2++] || I0-=M0;
(r5, r4)=byteunpack r1:0 || R0 = [I1++] || I0+=M0;

A0+=r7.h*r5.h, A1+=r7.l*r5.l (FU);
A0+=r6.h*r4.h, A1+=r6.l*r4.l (FU);

(r7, r6)=byteunpack r3:2 (R) || R3 = [I2++] || I0-=M0;
(r5, r4)=byteunpack r1:0 (R) || R1 = [I1++] || I0+=M0;

A0+=r7.h*r5.h , A1+=r7.l*r5.l (FU);
_Corel1.End: A0+=r6.h*r4.h , A1+=r6.l*r4.l (FU);

I1+=M1; // go to next row in Src1
_Corel2.End: I2+=M2; // go to next row in Src2

    R1=A1;
    R2=A0;   
    R0 = R2 + R1 (S);       // Add the accumulated values in both MACs


M0=[sp++];
M1=[sp++];
M2=[sp++];
I0=[sp++];
I1=[sp++];
I2=[sp++];
p0=[sp++];
p1=[sp++];
(r7:3)=[sp++];
unlink;
rts;
_Corel.end:

Outcomes