A simple C routine counts the number of 1s in a 16-bit word. You can apply the general technique to a word of any length, but for purposes of explanation, assume a word length of 8 bits (Listing 1).