First one takes the first 8 bits of the variable var.
Second one takes the second 8 bits of the variable var (drops other to zero) and moves those 8 bits to te begining of the word.
Third and fourth does the same, but for third and fourth 8 bits.
eg. if you have a 32bit number (in bit representation)
10111110 01111001 11100001 10110101
The first command returns,10110101.
Second 11100001. This is done by bitwise anding
00000000 00000000 11111111 00000000 (the 0x0000ff00) and
10111110 01111001 11100001 10110101
leaving a number
00000000 00000000 11100001 00000000.
Shifting this 8 bits to the right leaves (begining zeros omited): 11100001.
Similary the third is 01111001 and fourth is 10111110.
|