AnsweredAssumed Answered

BF533 - ASM double loop - Fract16 indexing

Question asked by icamaster on Jan 12, 2018
Latest reply on Jan 19, 2018 by Jithul_Janardhanan

Hi there!

I have a basic application using the BF533 where I have two pictures of size 128*128 of Fract16 format. I want to compute the average of every pixel from the top left corner (size 64*64) and put it into another Fract16 array. 

 

I have my tables initialisation written in C and I call externally this function. (sizeX and sizeY are not used, but will be used later on). 

extern void fuziune_L_ASM(fract16 * in1, fract16 * in2, fract16 * out, int sizeX, int sizeY);

 

.section program;
.GLOBAL _fuziune_L_ASM;
_fuziune_L_ASM:

 

R6=0; 
R7=63;

LC0 = R7;
LC1 = R7;

LSETUP (start1, end1) LC0;
start1: LC1 = R7;
R3 = 128; //Used to move line by line
R3 *= R6;
R4 = 0;
R4 = R0 + R3;
P0 = R4;
R4 = R1 + R3;
P1 = R4;
R4 = R2 + R3;
P2 = R4;
LSETUP (start2, end2) LC1;
start2: R3 = W[P0++](z);
R4 = W[P1++](z);
R3 = R3 >> 1;
R4 = R4 >> 1;
R5.L = R3.L+R4.L(s);
W[P2]=R5.L;
end2: P2+=2;
end1: R6 += 2;

RTS;
_fuziune_L_ASM.end:

 

 

Unfortunately, I cannot seem to get it working. Anyone has any ideea? The below equivalent in C works:

 

void fuziune_L (fract16 * ent1, fract16 * ent2, fract16 * iesire, int latime, int inaltime){
//Average on LL
int i, j;
for(i = 0; i<latime/2; i++){
for(j = 0; j<inaltime/2; j++){
iesire[i+latime*j] = add_fr1x16(ent1[i+latime*j], ent2[i+latime*j]);
iesire[i+latime*j] = iesire[i+latime*j] >> 1;
}
}
}

Outcomes