#include <stdio.h>
void binary_print( unsigned int value) {
unsigned int mask = 0xff000000 ;
unsigned int shift = 256 * 256 * 256 ;
unsigned int byte, byte_iterator, bit_iterator;
for ( byte_iterator = 0 ; byte_iterator < 4 ; byte_iterator++ ) {
byte = ( value & mask) / shift;
printf ( " " ) ;
for ( bit_iterator = 0 ; bit_iterator < 8 ; bit_iterator++ ) {
if ( byte & 0x80 )
printf ( "1" ) ;
else
printf ( "0" ) ;
byte * = 2 ;
}
mask / = 256 ;
shift / = 256 ;
}
printf ( "\n " ) ;
}
int main( )
{
int x = 173 ;
binary_print ( x) ;
__asm
{
pushad
mov eax, x
xor ebx, ebx
xor ecx, ecx
mov cl, 32
next_bit:
rcl eax, 1
rcr ebx, 1
loop next_bit
mov x, ebx
popad
}
binary_print ( x) ;
return 0 ;
}
I2luY2x1ZGUgPHN0ZGlvLmg+Cgp2b2lkIGJpbmFyeV9wcmludCh1bnNpZ25lZCBpbnQgdmFsdWUpIHsKICAgdW5zaWduZWQgaW50IG1hc2sgPSAweGZmMDAwMDAwOwogICB1bnNpZ25lZCBpbnQgc2hpZnQgPSAyNTYqMjU2KjI1NjsKICAgdW5zaWduZWQgaW50IGJ5dGUsIGJ5dGVfaXRlcmF0b3IsIGJpdF9pdGVyYXRvcjsKCiAgIGZvcihieXRlX2l0ZXJhdG9yID0gMDsgYnl0ZV9pdGVyYXRvciA8IDQ7IGJ5dGVfaXRlcmF0b3IrKykgewogICAgICBieXRlID0gKHZhbHVlICYgbWFzaykgLyBzaGlmdDsKICAgICAgcHJpbnRmKCIgIik7CiAgICAgIGZvcihiaXRfaXRlcmF0b3IgPSAwOyBiaXRfaXRlcmF0b3IgPCA4OyBiaXRfaXRlcmF0b3IrKykgewogICAgICAgICBpZihieXRlICYgMHg4MCkKICAgICAgICAgICAgcHJpbnRmKCIxIik7CiAgICAgICAgIGVsc2UKICAgICAgICAgICAgcHJpbnRmKCIwIik7CiAgICAgICAgIGJ5dGUgKj0gMjsKICAgICAgfQogICAgICBtYXNrIC89IDI1NjsKICAgICAgc2hpZnQgLz0gMjU2OwogICB9CiAgIHByaW50ZiAoIlxuIik7Cn0KCmludCBtYWluKCkKewoJaW50IHggPSAxNzM7CgliaW5hcnlfcHJpbnQgKHgpOwoKCV9fYXNtCgl7CgkJcHVzaGFkCgkJbW92IGVheCwgeAoJCXhvciBlYngsIGVieAoJCXhvciBlY3gsIGVjeAoJCW1vdiBjbCwgMzIKbmV4dF9iaXQ6CgkJcmNsIGVheCwgMQoJCXJjciBlYngsIDEKCQlsb29wIG5leHRfYml0CgkJbW92IHgsIGVieAoJCXBvcGFkCgl9CgliaW5hcnlfcHJpbnQgKHgpOwoJcmV0dXJuIDA7Cn0=