Learning to use PICS

Nov 23, 2004 41 Replies

compiler

Thank you for that.

It seems that the Hitech C compiler has noticed an optimisation in the "for loop" that the XCSB compiler missed, essentially converting:

;---------- k = 8 loop_start if k

Yes, that's amazing a compiler can be so efficient to produce a assembly code of similar size to a manually written assembly routine. The crc routine I wrote was developed from a drawing of the bit movements of the two CRC bytes as they are exored against sequential bits of the data byte. I don't know why the various bits were chosen, but probably because they yield the most unique crc. The flow is something like this:

Basically, the MSB bit of the data is XORed against bit 15 of the 16 bit crc. That result is XORed with bit 11 of the crc and the result is pushed up the stack underneath bit 12 (15 disappears). The first result is then XORed with bit 4 of the crc and pushed on the stack under bit 5 (old bit 11 is pushed off). The last step is to XOR the first result against 0 and the result pushed on the bottom of the stack (old bit 4 disappears). Here's a crude diagram: DATA IN (MSB)---> XOR | 11 11 | 10 | 9 | 8 | 7 | 6 | 5 |----XOR-->

| 4 4 | 3 | 2 | 1 | 0 |----XOR-->

0

-Bill

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required