Color Shift Tidbit

Started by
-1 comments, last by LilBudyWizer 23 years, 5 months ago
While trying to optimize a routine I was looking at the assembler code for the statement I used to generate a grey scale. The statement was iColor = cz | (cz << 8) | (cz << 16). I wanted a move, shift, or, shift, or, move, but that wasn''t what I got. There was an extra move in it. When I changed it to iColor = (((cz << 8) | cz) << 8) | cz I got the pattern I wanted. Although it is a greyscale and just one instruction it is something a program does a heck of a lot of. I suppose it depends upon the compiler and the rules for optimization that it has, but I thought it might be worth mentioning.
Keys to success: Ability, ambition and opportunity.

This topic is closed to new replies.

Advertisement