• Advertisement


This topic is now archived and is closed to further replies.

Color Shift Tidbit

This topic is 6348 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post

Link to post
Share on other sites

  • Advertisement