C++ (Qt)unsigned char invert( unsigned char src ){ unsigned char dst = 0; int cnt = 8; for(;;) { dst |= src & 0x01; if( !--cnt ) break; dst <<= 1; src >>= 1; } return dst;}
C++ (Qt)unsigned char invert(unsigned char src){ const char bits = 8; unsigned char dst = 0; for (char i = 1; i <= bits; ++i) { unsigned char power = qPow(2, i-1), bit = src & power ? 1 : 0, invertedBit = bit << (bits - i); dst += invertedBit; } return dst;}
C++ (Qt)template<typename T>T invert( T src ){ T dst = 0; size_t cnt = sizeof( T ) * 8; for(;;) { dst |= src & 0x01; if( !--cnt ) break; dst <<= 1; src >>= 1; } return dst;}
asm { mov al, DataByte mov ecx, 8 @1: shr al rcl bl loop mov DataByte, bl}