From: <olo...@sw...> - 2002-02-11 23:01:35
|
Hi all. The code below seems to generate some waste of data space. _crcCalc_sloc0_1_0 to _crcCalc_sloc9_1_0 is created (20 byte in data = area), but these _sloc variables seem to only live for a short moment in the = code and i think that they could share some of the space. I compiled it for 8051 with today's SDCC snapshot. It generates simulare code for both large,small and reentrant. Ehh, and yes i know that if i move the inner loop to a separate function then the problem is solved. But it is not that unusual to have two loops with some if statement. Code snip.. unsigned int crcOne(unsigned int crc); unsigned int crcTwo(unsigned int crc); unsigned int crcFour(unsigned int crc); unsigned int crcCalc(unsigned char len,unsigned char *msg) { unsigned char i,j; unsigned int crc; crc=3D0xFFFF; for(i=3D0;i<len;i++) { crc^=3Dmsg[i]; for(j=3D0;j<8;j++) { if (crc & 0x0001)=20 crc =3D crcOne(crc & 0x1545); if (crc & 0x0002) crc =3D crcTwo(crc << 2); if (crc & 0x0004) crc =3D crcFour(crc | 0x8051); } } } |