#include <_stdio.h_>
char clrbit8( char x, char n);
char setbit8( char x, char n);
char notbit8( char x, char n);
short clrbit16( short x, char n);
short setbit16( short x, char n);
short notbit16( short x, char n);
long clrbit32( long x, char n);
long setbit32( long x, char n);
long notbit32( long x, char n);
/* 定義unsigned char, unsigned short,
long/unsigned long */
int main()
{
printf("Hello World \n ");
unsigned char a = 0xAB, b = 0x55, c = 0;
c = clrbit8( a, 3);
printf( "clrbit8 = X \n ",c );
c = setbit8( a, 2);
printf( "setbit8 = X \n ",c );
c = notbit8( a, 0);
printf( "notbit8 = X \n ",c );
return 0;
}
//---------------------------------------
char clrbit8( char x, char n) {
char y = x & ~(1<
return y;
}
char setbit8( char x, char n) {
char y = x | (1<
return y;
}
char notbit8( char x, char n) {
char y = x ^ (1<
return y;
}
//---------------------------------------
short clrbit16( short x, char n) {
short y = x & ~(1<
return y;
}
short setbit16( short x, char n) {
short y = x | (1<
return y;
}
short notbit16( short x, char n) {
short y = x ^ (1<
return y;
}
//---------------------------------------
long clrbit32( long x, char n) {
short y = x & ~(1<
return y;
}
long setbit32( long x, char n) {
long y = x | (1<
return y;
}
long notbit32( long x, char n) {
long y = x ^ (1<
return y;
}
/*
printf("a = %2X \n ", a);
printf("b = %2X \n ", b);
printf("b = %2X \n ", c);
printf("a = %d \n ", a);
printf("b = %d \n ", b);
printf("b = %d \n ", c);
c = a & b;
printf("a & b = X \n ", c);
c = a | b;
printf("a | b = X \n ", c);
c = a ^ b;
printf("a ^ b = X \n ", c);
}*/