I'm having trouble writing a modulo 2 modulus function. I need to divide a 260 byte unsigned integer by a 4 byte unsigned integer without carrying bits (modulo 2) and return the remainder. Currently I'm using loops to perform bitshift and logical operations and I'm thinking it might be cleaner if I wrote separate functions for performing binary operations on arbitrarily large amounts of data. The reason why I know my function isn't currently working is that if I divide a dividend by a divisor, then add the remainder to the dividend and divide again, the second remainder is not zero. I would appreciate some help getting this function working.

My current function is:

In case it helps, I uploaded my whole source to show some context.Code:char *divide(char *message, char *divisor, char *remainder) { unsigned int *poly=divisor; unsigned int *result=remainder; int i, j; for (i=0; i<260; i++) { for (j=7; j>=0; j--) { int action=(*result>>31)&1; *result<<=1; *result|=(*(message+i)>>j)&1; *result^=action*i; } } for (i=0; i<32; i++) { int action=(*result>>31)&1; *result<<=1; *result^=action*i; } unsigned int temp=(1<<31)-1; return (*result & temp); }