// bits.c // Arquitectura de Computadores 2010/2011 // Departamento de Informatica FCT/UNL #include // escrever um numero em binario void print_bin( unsigned char c ) { int i ; for( i = 0; i < 8 ; i++ ) { if( c & 0x80 ) putchar( '1' ); else putchar( '0' ); c = c << 1; } putchar('\n'); } // aplicar operação lógica bit a bit void do_op( unsigned char *b ) { // por todos os bits a zero excepto o bit 0 que mantem o seu valor *b = *b & 1; } int main() { unsigned char b = 0x84; printf( "hex %x = bin ", b ); print_bin(b); do_op( &b ); printf( "hex %x = bin ", b ); print_bin(b); return 0; }