i have a problem when converting c++ program to assembly i have to do it for
here is my c++ code
for(int i=0;i<rows-4;i++,a+=4,b+=4,c+=4,d+=4,e+=4,f+=4,x+=4,o+=4){ for(int j=0;j<cols-4;j++,a++,b++,c++,d++,e++,f++,x++,o++){ *o=*a>*x; *o=*b>*x|(*o<<1); *o=*c>*x|(*o<<1); *o=*d>*x|(*o<<1); *o=*e>*x|(*o<<1); *o=*f>*x|(*o<<1); } } o is pointer for the output data while a,b,c,d,e,f and x are pointer to input data. what i want is just save the comparisons from the input data to a single variable, but the code above is not efficient when the data that being processed is big. The program need more times to save a data into memory compared to saving temporary data in register.
so what i want to do is just make this process done in register. What i've tried is i store the data that referred by x in EBX, compare EBX to ECX which hold the value referred by a (and b,c,d,e,f sequentially), save the comparison result to EAX and shift the EAX register to left so that all the comparison will be stored in one variable. after all 6 comparisons already processed the value from ECX is copied to memory.
here is what i did, my program can runs two times faster but all the values that i get i just zero. maybe i do it in a wrong way?
__asm__( "xorl %%eax,%%eax;" "xorl %%ebx,%%ebx;" "xorl %%ecx,%%ecx;" "movl %1, %%ebx;" //start here "movl %2,%%ecx;" "cmp %%ebx,%%ecx;" "jnz .one;" "orl $0x1,%%eax;" ".one:;" "shll $1,%%eax;" "movl %3,%%ecx;" "cmp %%ebx,%%ecx;" "jnz .two;" "orl $0x1,%%eax;" ".two:;" "shll $1,%%eax;" "movl %4,%%ecx;" "cmp %%ebx,%%ecx;" "jnz .three;" "orl $0x1,%%eax;" ".three:;" "shll $1,%%eax;" "movl %5,%%ecx;" "cmp %%ebx,%%ecx;" "jnz .four;" "orl $0x1,%%eax;" ".four:" "shll $1,%%eax;" "movl %6,%%ecx;" "cmp %%ebx,%%ecx;" "jnz .five;" "orl $0x1,%%eax;" ".five:" "shll $1,%%eax;" "movl %7,%%ecx;" "cmp %%ebx,%%ecx;" "jnz .six;" "orl $0x1,%%eax;" ".six:" //output "movl %%eax,%0;" :"=r"(sett) :"r"((int)*x),"r"((int)*a) ,"r"((int)*b) ,"r"((int)*c) ,"r"((int)*d),"r"((int)*e),"r"((int)*f) /* input */ );