Below is some code implemented on an 8 bit microcontroller.

The following comment was posted to [another question](https://electronics.stackexchange.com/questions/91238/crc-for-eeprom-data-check/91246#91246):

> 
> As your code doesn't use the `i` variable, why not just `while(length--)`
>  instead of the first `for` loop?
> 
> 
> 

It suggests changing the `for(..)` loop for a `while(..)`, will this make any practical difference to how optimised the code is for an embedded microcontroller?

```
uint32_t MyFunction(uint32_t crc, uint8_t *buffer, uint16_t length) {
    for (uint16_t i=0; i < length; i++) { 
        crc = crc ^ *buffer++; 

        for (uint16_t j=0; j < 8; j++) { 
           if (crc & 1) 
              crc = (crc >> 1) ^ 0xEDB88320; 
           else 
              crc = crc >> 1; 
        } 
    } 

   return crc; 
}

```

**Note:** I wrote this question and answered it myself after posting a comment earlier this week. That comment was upvoted but I felt I should back it up with some actual testing. Other answers would be useful, but this was intended as generic proof of a point rather than a specific question about the algorithm.